Varnish Performance

Varnish settings

To see further description of these settings, also check param.show -l in the Varnish management interface. 
  • -p thread_pool_min=200 (default: 5)
Idle threads are harmless. This number is multipled by the number of thread pools you have available, and the total should be roughly what you need to run on a normal day. 
  • -p thread_pool_max=4000 (default 1000)
The maximum number of threads is in essence limited by available file descriptors, however, setting it too high does not increase performance. Having a number of idle threads is reasonably harmless, but do not increase this number above roughly 5000 or you risk running into file-descriptor related issues, among other things. 
  • -p thread_pool_add_delay=2 (default: 20ms, default in master: 2ms)
Reducing the add_delay lets you create threads faster which is essential - specially at startup - to avoid filling up the queue and dropping requests. 
  • -p session_linger=100 OR MORE (default: 0ms in <= 2.0.4 and 50ms in > 2.0.4)
To avoid too much context switching when you starve your CPU (and in general), letting each thread wait for new requests is essential. The value depends on how long it takes you to deliver the typical object. This will also reduce the amount of threads piling up (which is somewhat counter intuitive). 
  • -s malloc,(YOURMEMORY-20%)G
Keep data in memory using -s malloc.

     DAEMON_OPTS="-a :80,:443 \
             -T localhost:6082 \
             -f /etc/varnish/default.vcl \
             -u varnish -g varnish \
             -S /etc/varnish/secret \
             -p thread_pool_add_delay=2 \
             -p thread_pools=<Number of CPU cores> \
             -p thread_pool_min=<800 / Number of CPU cores> \
             -p thread_pool_max=4000 \
             -p session_linger=50 \
             -p sess_workspace=262144 \
             -s malloc,<yourmemory - 20%>G"

Nhận xét

Bài đăng phổ biến