nicolasazrak / caddy-cache

Caching middleware for caddy
Mozilla Public License 2.0
109 stars 30 forks source link

Memory leak #42

Open muralikg opened 5 years ago

muralikg commented 5 years ago

Thanks for you work. It has been very helpful :+1:

Is there a way I can limit the amount of memory used for caching. I have seen caddy run out of memory and not accept subsequent connections after a few hours when caching is enabled.

I would not expect it to use so much memory given that the amount of cache-able content we have is limited. Can you please tell me if there is anything wrong/missing with the configuration

https://domain:443, https://domain:443 {
  bind 0.0.0.0
  proxy / https://origin:443 {
    transparent
    keepalive 5
  }
  cache {
    match_path /static
    path /tmp/caddy_cache
    default_max_age 0
  }
  tls ./keys/cert ./keys/key
  errors /var/log/caddy_error.log {
    rotate_size 100
  }
}

Following graph shows memory usage climbing up when caching is enabled. With no caching and only as a reverse proxy memory usage seems stable.

caddy_memory

Any help would be greatly appreciated. Thanks!

muralikg commented 5 years ago

I take back that we have limited URLs to cache. We use nginx-pagespeed which generates quite a few static resource urls that are cacheable. And these optimized static resources are generated on the fly based on user agent and those resources have really long expiration(1 year).

Size of cached payloads seems to be way less than peak memory usage of caddy (~800 MB). So I still think there is a leak somewhere else.

du -h --max-depth=1 /tmp/caddy_cache
395M    /tmp/caddy_cache/
CristianCantoro commented 5 years ago

It seems that I am experiencing the same issue with wikiproxy. Caddy crashes with: fatal error: runtime: out of memory.

I am attaching the complete log for reference: cache-bug-report.log.

tearfulDalvik commented 5 years ago

It seems that I am experiencing the same issue with wikiproxy. Caddy crashes with: fatal error: runtime: out of memory.

I am attaching the complete log for reference: cache-bug-report.log.

the same for me 😢

haroon-ali commented 5 years ago

I can confirm the memory leak issue too!