Reputation: 22040
If I want to build an RSS reader then inserting all feeds in a MySQL would be too heavy for the DB server, CPU intensive.
So would having a Redis or cassandra, MySQL server with Apache help in the reducing the load on mysql server?
Upvotes: 1
Views: 173
Reputation: 39009
Short answer: Yes, but it will add complexity.
Long answer: If MySQL isn't fast enough for you (and I would first verify that this is, in fact, the case before adding the complexity of Redis), you could throw some of the more frequent update/insert load onto Redis. A few ways to do this (you don't have to do everything here, but each thing will help with your load):
Have a Redis pub/sub channel for each user. Publish directly to it whenever something is added to a user's feed. Have the RSS client subscribe to this channel, so if a user has his or her RSS reader open, they should just be subscribed to their pub/sub channel for updates, and never read from MySQL.
Batch insert into MySQL: If you have heavy write volume, don't endure the network traffic and locking/unlocking and query overhead of inserting into MySQL every time something new should be added to the feed. Instead, save all new items in a per-user cache. Then empty the cache and do a bulk write every n seconds. Set n as high as needed for your use case.
Cache feeds per user: If your read volume is very high despite #1, cache in Redis the last n items per user for m seconds (set n and m as befits your use case). Best way to cache these is most likely as a string. Use a list, if for some reason you need more dynamic access. Users should then read from MySQL only if their cache is unavailable.
Upvotes: 2