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


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.

Leave a comment