I'm trying to set up proxy content caching with Nginx inside of Docker, but am experiencing memory issues with my container. The actual Nginx implementation works fine (pages are being cached and served as expected), but as soon as pages start being cached, my container memory (measured with "docker stats") climbs extremely quickly.
I would expect about a 1MB increase for every 8,000 pages cached as per the Nginx docs (https://www.nginx.com/blog/nginx-caching-guide/), but the growth is far greater - probably around 40MB every 8000 pages. Additionally, when running "top" inside my container, the nginx process memory looks normal - a couple MB - while my container memory is skyrocketing.
It almost seemed liked the cached pages themselves, which are stored in a specific directory, are taking up memory? This shouldn't be the case, as only the cache keys should be in memory. I think I've tested to around 25,000 pages being cached - container memory never falls off. Additionally, if I'm just proxying requests with caching turned off, there is no container memory spike.
I'm running an extremely basic nginx configuration setup - pretty much what is detailed in the Nginx docs link.
proxy_cache_path /path/to/cache levels=1:2 keys_zone=my_cache:10m max_size=10g
inactive=60m use_temp_path=off;
server {
...
location / {
proxy_cache my_cache;
proxy_pass http://my_upstream;
}
}
Docker images tested - official nginx image, alpine:3.4 with nginx installed, centos:7 with nginx installed
Docker versions tested: Docker for Mac 1.12.1, Docker 1.11.2 (on Kubernetes)