Skip to content
Advertisement

Varnish process not closed and taking huge memory

We are using Varnish cache 4.1 in centos server, When we started Varnish server lots of varnish process starting and its not closing, due to this issue we are facing memory leak issue, pls let us know how we can resolve it

My Configuration is: /etc/sysconfig/varnish

#DAEMON_OPTS="-a :80 
#             -T localhost:6082 
#             -f /etc/varnish/default.vcl 
#             -S /etc/varnish/secret 
#             -p thread_pools=8 
#             -p thread_pool_max=4000 
#             -p thread_pool_add_delay=1 
#             -p send_timeout=30 
#             -p listen_depth=4096 
#             -s malloc,2G"

backend default {
    .host = "127.0.0.1";
    .port = "8080";
    .probe = {
         .url = "/";
         .interval = 5s;
         .timeout = 1s;
         .window = 5;
         .threshold = 3;
    }
}

34514 89208 83360 5 0.0 4.3 0:00.00 /usr/sbin/varnishd -a :80 -f /etc/varnish/default.vcl -T 127.0.0.1:6082 -t 120 -p thread pool min=50 -p t 1678 varnish 20 0 345M 89208 83360 S 0.0 4.3 0:00.03 /usr/sbin/varnishd -a :80 -f /etc/varnish/default.vcl -T 127.0.0.1:6082 -t 120 -p thread_pool_min=50 -p • 1679 varnish 20 0

Advertisement

Answer

You are not limiting space for transient objects. By default an unlimited malloc is used (see the official doc : https://www.varnish-cache.org/docs/4.0/users-guide/storage-backends.html#transient-storage )

From what I see in your message, you are not using the parameter DAEMON_OPT. What are the content of your varnishd.service file and /etc/varnish/varnish.params ?

EDIT

Nothing’s wrong with your init.d script. It should use the settings found in /etc/sysconfig/varnish. How many RAM is consumed by varnish? All the varnish threads are sharing the same storage (malloc 2G + Transient malloc 100M) so it should take up to 2.1G for storage. you need to add an average overhead of 1KB per object stored in cache to get the total memory used. I don’t think you are suffering memory leak, the process are normal. You told varnish to spawn 50 processes (with the thread_pools parameter) so they are expected.

I’d recommend decreasing the number of thread_pools, you are setting it to 50. You should be able to lessen it to something between 2 and 8, at the same time it will help to increase the thread_pool_max to 5000and set the thread_pool_min to 1000. We are running very large server with 2 pools * 1000-5000 threads and have no issue.

Advertisement