varnish Monitoring threads


You need to keep track of some threads metrics to watch your Varnish Cache. Is it running out of OS resources or is it functioning well.

  • threads - Number of threads in all pools.
  • threads_created - Number of created threads.
  • threads_failed - Number of times Varnish failed to create a thread.
  • threads_limited - Number of times Varnish was forced not to create a thread since it was maxed out.
  • thread_queue_len - Current queue length. Number of requests waiting for a thread.
  • sess_queued - Number of times there wasn't any threads available so a request had to be queued.
varnishstat -1 | grep "threads\|thread_queue_len\|sess_queued"
MAIN.threads                     100          .   Total number of threads
MAIN.threads_limited               1         0.00 Threads hit max
MAIN.threads_created            3715         0.00 Threads created
MAIN.threads_destroyed          3615         0.00 Threads destroyed
MAIN.threads_failed                0         0.00 Thread creation failed
MAIN.thread_queue_len              0          .   Length of session queue
MAIN.sess_queued                2505         0.00 Sessions queued for thread

If thread_queue_len isn't 0 it means that Varnish is out of resources and have started to queue requests. This will decrease performance of those requests. You need to investigate why.

Watch also out for threads_failed. If this increases it means your server is out of resources somehow. Increasing numbers in threads_limited means you might need to increase your servers thread_pool_max.