Redis in kubernetes - sidecar or client-server model?

4/28/2020

What is the advantage and disadvantage of using redis as a sidecar in kubernetes?Is it possible to have persistence cache when redis container is added in each app pod? Will that affect the availability and scalability of cache?

-- sachin
caching
kubernetes
persistent-storage
redis
sidecar

1 Answer

4/28/2020

I'm hard-pressed to think of any advantages to running Redis as a sidecar. I would always run it as a separate deployment (or stateful set if persistence is enabled) with a separate service.

If Redis is in its own pod then:

  • If your application has multiple replicas, they'll all share the same Redis
  • When you redeploy your application, it doesn't also terminate and restart Redis
  • If persistence is enabled for Redis, you don't need to configure your application pods with the persistent storage

Given Redis's overall capabilities (principally in-memory storage, limited data-type support), simply storing this cache data in singleton objects in your application would be more or less equivalent to running Redis as a sidecar (one copy of the cache data per pod, data is lost when the pod is deleted).

-- David Maze
Source: StackOverflow