[Solved]-Using Redis as intermediary cache for REST API

19šŸ‘

āœ…

Sure, we do the same at our firm, using Redis to store not JSON but large XML strings which are generated from backend databases for RESTful requests, and it saves lots of network hops and overhead.

A few things to keep in mind if this is the first time youā€™re using Redisā€¦

Dedicated Redis Server
Redis is single-threaded and should be deployed on a dedicated server with sufficient CPU power. Donā€™t make the mistake of deploying it on your app or database server.

High Availability
Set up Redis with Master/Slave replication for high availability. I know thereā€™s been lots of progress with Redis cluster, so you may want to check on that too for HA.

Cache Hit/Miss
When checking Redis for a cache ā€œhitā€, if the connection is dead or any exception occurs, donā€™t fail the request, just default to the database; caching should always be ā€˜best effortā€™ since the database can always be used as a last resort.

šŸ‘¤raffian

Leave a comment