Reducing CPU usage

James Pearson james at ifixit.com
Tue Dec 18 22:12:37 CET 2012


Excerpts from Simon Lyall's message of 2012-12-15 02:25:41 -0800:
> 
> I wrote a little article on reducing CPU usage in my varnish cache that 
> some may find useful:
> 
> http://blog.darkmere.gen.nz/2012/12/speeding-up-varnish-cache/
> 
> The TLDR is that my vcl_recv was poorly structured and every request went 
> though around 32 "if" statements (some with huge regex matches). I was 
> seeing my CPU maxed out at just 4-5000 hits/second. I restructured 
> vcl_recv to reduce the average amount number of tests on each request and 
> halved the CPU used.

Towards the end, you mention moving a rule from being of the form

    if ((a || b ) && c) {

to

	if (a || b) {
		if (c) {

, where c is an expensive check and (a || b) rules out most pages, and seeing a
CPU usage decrease.  This seems odd to me, since I'd expect short-circuiting to
cut out the check for c if (a || b) is false.

Did I perhaps misunderstand what you were saying?




More information about the varnish-misc mailing list