Hello Luca, This should give you some information: https://info.varnish-software.com/blog/understanding-varnish-cache-memory-usage . Notably, you need to account for some memory fragmentation.
Note that your formula is probably a bit optimistic: each thread is allowed to consume as much as workspace_client/workspace_backend, and workspace will be consumed by VCL operations, like regex matching and substitutions. One thing you can do is use vmod_vtc: https://varnish-cache.org/docs/trunk/reference/vmod_vtc.html#int-workspace-free-enum-client-backend-session-thread . You could log the remaining size for all requests and see how close you get to zero. I'd like to ask: which Varnish packages are you using? (i.e. version and origin). I know some people have been hurt before, by the jemalloc package I think, and depending on how Varnish is built, you can get better a smaller memory footprint. -- Guillaume Quintard On Mon, Jul 1, 2024 at 5:02 PM Luca Gervasi <[email protected]> wrote: > Hello, > I'm following an issue that caused some OOMs during a huge spike. > Currently I have the following properties set: > > -p thread_pool_max=2000 \ > -p thread_pool_min=35 \ > -p feature=+esi_disable_xml_check \ > -p feature=+esi_ignore_other_elements \ > -p feature=+esi_remove_bom \ > -p feature=+http2 \ > -p pcre_match_limit_recursion=64 \ > -p syslog_cli_traffic=off \ > -p sigsegv_handler=on \ > -p workspace_client=2m \ > -p workspace_backend=2m \ > -p http_max_hdr=128 \ > -p http_req_hdr_len=32k \ > -p http_resp_hdr_len=32k \ > -p http_req_size=2m \ > -p http_resp_size=2m \ > -p thread_pool_stack=256k \ > -s malloc,20G \ > -S /config/varnish/secret \ > -f /config/varnish/default.vcl \ > -p vsl_reclen=700 > > And I'm using this formula to somehow calculate how much memory is varnish > going to use: > thread_pool_max*thread_pool_stack+thread_pool_max*(workspace_client+http_req_hdr_len+http_req_size) > + > malloc > > And it is somewhere close to where I get OOM. I suspect that what did > screw up was the high esi-to-request ration that I normally have: > > MAIN.client_req 469.22 > MAIN.esi_req 5489.25 > > Hit rate on that esi requests is pretty high as we use high ttls and > invalidations, but I think that those ESIs have to be taken into account > too (as well as the backend requests too...). > > I wasn't able to find an official memory sizing guide, sorry. How do you > size correctly memory usage? > I know I should use MSE, at the moment is not on my list. > > Thanks > Luca > _______________________________________________ > varnish-misc mailing list > [email protected] > https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc >
_______________________________________________ varnish-misc mailing list [email protected] https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
