Kamil Roman
Kamil Roman

Reputation: 1071

Multiple microservices and Redis - one database vs node per application in cloud

I would like to know what is the best practice for using Redis in cloud (Google Memorystore in my case, Standard Tier) for multiple microservices/applications. From what I have researched so far following options are available:

  1. Use single cluster and database, scaled horizontally for all the microservices. This seems most cost-effective as I will use the exact amount of nodes I will need for the whole system. The data isolation is impacted here, but I can reduce the impact e.g. by prefixing the keys with the microservice name.
  2. Use separate clusters and databases for each microservice. In this case the isolation is better, the scaling of the needed cluster will impact a single microservice only, but this doesn't seem cost effective, as many nodes may be underloaded (e.g. microservice M1 utilizes 50% capacity of a node, microservice M2 utilizes 40% capacity of a node so in case 1 both microservices would by served only by a single node).
  3. In theory I could use multiple databases to isolated data in a single cluster, but as far as I have read this is not supported by Redis (and using multiple databases on a single node causes performance issues).

I am leaning towards option 1., but perhaps I am missing something?

Upvotes: 0

Views: 1184

Answers (1)

Benedetto
Benedetto

Reputation: 749

Not sure about best practices, I will tell you my experience. In general I would go with Option #2.

Each microservices gets it's own redis instance or cluster. Redis clusters follow their own microservice life. Ex they might get respawned when you redeploy or restart a service.

You might pay a bit more but you gain in resiliency and maintenance hassle.

Upvotes: 1

Related Questions