|Source Repository:||Gentoo Portage Tree|
Summary: Varnish is a state-of-the-art, high-performance HTTP accelerator
Varnish is a webcache & http accelerator. Varnish will either serve cached content, or retireve content from the server, and cache it. Varnish will reduce I/O pressure from webservers.
# emerge www-servers/varnish
as your varnish is local to your server, your server needs to be aware that it is behind a proxy, and configured for x-forwarded-for or similar to fetch real users ip addresses instead of displaying 127.0.0.1 or localhost.
Configuration is controlled by /etc/varnish/default.vcl & /etc/conf.d/varnishd
Varnish will fetch data from localhost:8080 and serve accelerated proxy data on localhost:80
For 10,000 concurrent connections (or not) a few configuration settings control the power of varnish. If you're having varnish directly serve to the outside world, dial back concurrency to say 50 or 100 connections per ip. You must take into account corporations, and universities hammering several connections from a singular ip. c10k is useful information for if varnish is behind a load balancer such as pound, nginx, or tengine, and all requests are internal and local.
To start varnish immediately:
# rc-service varnishd start
To start varnish at boot:
# rc-update add varnishd default
To verify that your traffic is going through varnish.
$ curl -I http://www.funtoo.org/Welcome
Apache-tools apache benchmark can show the power of varnish. The examples shown are running 500 requests with concurrency of 100 hits.
ab against a 3 worker cluster mode puma server
# ab -n 500 -c 100 http://127.0.0.1:3000/index.html | grep Request
Requests per second: 110.92 [#/sec] (mean)
ab against the same server served through varnish
# ab -n 500 -c 100 http://127.0.0.1/index.html | grep Request
Requests per second: 10268.42 [#/sec] (mean)
Varnish does not support ssl. There are packages to get around this limitation: