Search code examples
amazon-web-servicesdockercachingamazon-ecsapcu

APCu cache in docker container


Basic structure : We have enabled APCu cache in docker containers. We have auto-scaling container and using AWS ECS service. We have deployment pipeline where all containers get swap with new git data(the changes we push on git).

Question: When we deploy something to server OR when load increases/decrease number of containers are increase or decrease. APCu cache is within containers. So does we get benefit of caching where containers are swapping frequently?


Solution

  • You only get the benefit of the cache when a request comes in to a specific container that already has that data cached. Any time you deploy, your cache gets completely wiped out. Any time the ECS service scales up to add another container, the new container will not have any data cached until some requests come in and it starts caching that data.

    If you want a cache that can be shared by all containers, this is called a "distributed cache". The services on AWS you should look at for implementing a distributed cache are AWS ElastiCache and AWS MemoryDB.