<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div id="yui_3_16_0_1_1429192664994_12851">Dear all,</div><div id="yui_3_16_0_1_1429192664994_12853"><br></div><div id="yui_3_16_0_1_1429192664994_12855" dir="ltr"> I have been testing my varnish configuration using tools.pingdom.com, webpagetest.org and loadimpact.com and apache benchmark.</div><div id="yui_3_16_0_1_1429192664994_12857" dir="ltr"><br></div><div id="yui_3_16_0_1_1429192664994_12859" dir="ltr"> I have Varnish 4.0 in front of an Apache installation from Cpanel in a VPS with 6 Gb with 100 mbps of bandwith.</div><div id="yui_3_16_0_1_1429192664994_12861" dir="ltr"><br></div><div id="yui_3_16_0_1_1429192664994_12863" dir="ltr"> I'm realizing that i can only get a hitrate around 0.6 and the throughput is around 43 request per second. What am I doing wrong? How can I troubleshoot what's going on?<br></div><div id="yui_3_16_0_1_1429192664994_12999" dir="ltr"><br></div><div id="yui_3_16_0_1_1429192664994_13031" dir="ltr"> Thanks</div><div id="yui_3_16_0_1_1429192664994_13033" dir="ltr"><br></div><div id="yui_3_16_0_1_1429192664994_13035" dir="ltr"> Miguel<br></div><div id="yui_3_16_0_1_1429192664994_12865" dir="ltr"><br></div><div id="yui_3_16_0_1_1429192664994_12875" dir="ltr"><br></div><div id="yui_3_16_0_1_1429192664994_12906" dir="ltr">This is my /etc/sysconfig/varnish daemon configuration:</div><div id="yui_3_16_0_1_1429192664994_12965" dir="ltr"><br></div><pre id="yui_3_16_0_1_1429192664994_12975" style="" class="">/usr/sbin/varnishd -P /var/run/varnish.pid -a :80 -f /etc/varnish/default.vcl -T 127.0.0.1:6082 -t 120 -p thread_pools=2 -p thread_pool_add_delay=1 -p thread_pool_min=500 -p thread_pool_max=2000 -p thread_pool_timeout=120 -u varnish -g varnish -S /etc/varnish/secret -s malloc,3G</pre><div id="yui_3_16_0_1_1429192664994_12908" dir="ltr"><br></div><div id="yui_3_16_0_1_1429192664994_12867" dir="ltr">This is my default.vcl configuration:</div><div id="yui_3_16_0_1_1429192664994_12869" dir="ltr"><br></div><div id="yui_3_16_0_1_1429192664994_12871" dir="ltr"> <br></div><div id="yui_3_16_0_1_1429192664994_12846" dir="ltr">vcl 4.0;<br style="" class=""><br style="" class="">import std;<br style="" class=""><br style="" class=""># Default backend definition. Set this to point to your content server.<br style="" class="">backend default {<br style="" class=""> .host = "192.168.1.10";<br style="" class=""> .port = "82";<br style="" class="">}<br style="" class=""><br style="" class="">acl purge {<br style="" class=""> "localhost";<br style="" class="">}<br style="" class=""><br style="" class=""># This function is used when a request is send by a HTTP client (Browser)<br style="" class="">sub vcl_recv {<br style="" class=""><br style="" class=""> # remove ?ver=xxxxx strings from urls so css and js files are cached.<br style="" class=""> # Watch out when upgrading WordPress, need to restart Varnish or flush cache.<br style="" class=""> set req.url = regsub(req.url, "\?ver=.*$", "");<br style="" class=""> <br style="" class=""> # Remove "replytocom" from requests to make caching better.<br style="" class=""> set req.url = regsub(req.url, "\?replytocom=.*$", "");<br style="" class=""><br style="" class=""> # We pass real IP to the backend<br style="" class=""><br style="" class=""> if (req.restarts == 0) {<br style="" class=""> if (req.http.X-Forwarded-For) {<br style="" class=""> set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip;<br style="" class=""> } else {<br style="" class=""> set req.http.X-Forwarded-For = client.ip;<br style="" class=""> }<br style="" class=""> }<br style="" class=""><br style="" class=""><br style="" class=""> <br style="" class=""><br style="" class=""><br style="" class=""> # Normalize the header, remove the port (in case you're testing this on various TCP ports)<br style="" class=""><br style="" class=""> set req.http.Host = regsub(req.http.Host, ":[0-9]+", "");<br style="" class=""><br style="" class=""> # Remove has_js and CloudFlare/Google Analytics __* cookies.<br style="" class=""> set req.http.Cookie = regsuball(req.http.Cookie, "(^|;\s*)(_[_a-z]+|has_js)=[^;]*", "");<br style="" class=""> # Remove a ";" prefix, if present.<br style="" class=""> set req.http.Cookie = regsub(req.http.Cookie, "^;\s*", "");<br style="" class=""><br style="" class=""><br style="" class=""> # Allow purging from ACL<br style="" class=""> if (req.method == "PURGE") {<br style="" class=""> # If not allowed then a error 405 is returned<br style="" class=""> if (!client.ip ~ purge) {<br style="" class=""> return(synth(405, "This IP is not allowed to send PURGE requests."));<br style="" class=""> }<br style="" class=""> # If allowed, do a cache_lookup -> vlc_hit() or vlc_miss()<br style="" class=""> return (purge);<br style="" class=""> }<br style="" class=""><br style="" class=""> # Post requests will not be cached<br style="" class=""> #if (req.http.Authorization || req.method == "POST") {<br style="" class=""> # return (pass);<br style="" class=""> #}<br style="" class=""><br style="" class=""> # Pass anything other than GET and HEAD directly.<br style="" class=""> if (req.method != "GET" && req.method != "HEAD") {<br style="" class=""> return( pass );<br style="" class=""> } /* We only deal with GET and HEAD by default */<br style="" class=""><br style="" class=""> # --- WordPress specific configuration<br style="" class=""><br style="" class=""> # Did not cache the admin and login pages<br style="" class=""> if (req.url ~ "wp-(login|admin)" || req.url ~ "preview=true") {<br style="" class=""> return (pass);<br style="" class=""> }<br style="" class=""><br style="" class=""> if (req.url ~ "(ajax|dynamic|custom)") {<br style="" class=""> return(pass);<br style="" class=""> }<br style="" class=""><br style="" class=""> # Remove the "has_js" cookie<br style="" class=""> set req.http.Cookie = regsuball(req.http.Cookie, "has_js=[^;]+(; )?", "");<br style="" class=""><br style="" class=""> # Remove any Google Analytics based cookies<br style="" class=""> set req.http.Cookie = regsuball(req.http.Cookie, "__utm.=[^;]+(; )?", "");<br style="" class=""><br style="" class=""> # Remove the Quant Capital cookies (added by some plugin, all __qca)<br style="" class=""> set req.http.Cookie = regsuball(req.http.Cookie, "__qc.=[^;]+(; )?", "");<br style="" class=""><br style="" class=""> # Remove the wp-settings-1 cookie<br style="" class=""> set req.http.Cookie = regsuball(req.http.Cookie, "wp-settings-1=[^;]+(; )?", "");<br style="" class=""><br style="" class=""> # Remove the wp-settings-time-1 cookie<br style="" class=""> set req.http.Cookie = regsuball(req.http.Cookie, "wp-settings-time-1=[^;]+(; )?", "");<br style="" class=""><br style="" class=""> # Remove the wp test cookie<br style="" class=""> set req.http.Cookie = regsuball(req.http.Cookie, "wordpress_test_cookie=[^;]+(; )?", "");<br style="" class=""><br style="" class=""> # Are there cookies left with only spaces or that are empty?<br style="" class=""> if (req.http.cookie ~ "^ *$") {<br style="" class=""> unset req.http.cookie;<br style="" class=""> }<br style="" class=""><br style="" class=""> # Cache the following files extensions<br style="" class=""> if (req.url ~ "\.(css|js|png|gif|jp(e)?g|swf|ico)") {<br style="" class=""> unset req.http.cookie;<br style="" class=""> }<br style="" class=""><br style="" class=""> # Normalize Accept-Encoding header and compression<br style="" class=""> # https://www.varnish-cache.org/docs/3.0/tutorial/vary.html<br style="" class=""> if (req.http.Accept-Encoding) {<br style="" class=""> # Do no compress compressed files...<br style="" class=""> if (req.url ~ "\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$") {<br style="" class=""> unset req.http.Accept-Encoding;<br style="" class=""> } elsif (req.http.Accept-Encoding ~ "gzip") {<br style="" class=""> set req.http.Accept-Encoding = "gzip";<br style="" class=""> } elsif (req.http.Accept-Encoding ~ "deflate") {<br style="" class=""> set req.http.Accept-Encoding = "deflate";<br style="" class=""> } else {<br style="" class=""> unset req.http.Accept-Encoding;<br style="" class=""> }<br style="" class=""> }<br style="" class=""><br style="" class=""> # Check the cookies for wordpress-specific items<br style="" class=""> if (req.http.Cookie ~ "wordpress_" || req.http.Cookie ~ "comment_") {<br style="" class=""> return (pass);<br style="" class=""> }<br style="" class=""> if (!req.http.cookie) {<br style="" class=""> unset req.http.cookie;<br style="" class=""> }<br style="" class=""><br style="" class=""> # --- End of WordPress specific configuration<br style="" class=""><br style="" class=""> # Did not cache HTTP authentication and HTTP Cookie<br style="" class=""> if (req.http.Authorization || req.http.Cookie) {<br style="" class=""> # Not cacheable by default<br style="" class=""> return (pass);<br style="" class=""> }<br style="" class=""><br style="" class=""> # Cache all others requests<br style="" class=""> return (hash);<br style="" class="">}<br style="" class=""><br style="" class="">sub vcl_pipe {<br style="" class=""> return (pipe);<br style="" class="">}<br style="" class=""><br style="" class="">sub vcl_pass {<br style="" class=""> return (fetch);<br style="" class="">}<br style="" class=""><br style="" class=""># The data on which the hashing will take place<br style="" class="">sub vcl_hash {<br style="" class=""> hash_data(req.url);<br style="" class=""> if (req.http.host) {<br style="" class=""> hash_data(req.http.host);<br style="" class=""> } else {<br style="" class=""> hash_data(server.ip);<br style="" class=""> }<br style="" class=""><br style="" class=""> # If the client supports compression, keep that in a different cache<br style="" class=""> if (req.http.Accept-Encoding) {<br style="" class=""> hash_data(req.http.Accept-Encoding);<br style="" class=""> }<br style="" class=""><br style="" class=""> return (lookup);<br style="" class="">}<br style="" class=""><br style="" class=""># This function is used when a request is sent by our backend (Nginx server)<br style="" class="">sub vcl_backend_response {<br style="" class=""> # Remove some headers we never want to see<br style="" class=""> unset beresp.http.Server;<br style="" class=""> unset beresp.http.X-Powered-By;<br style="" class=""><br style="" class=""> # For static content strip all backend cookies<br style="" class=""> if (bereq.url ~ "\.(css|js|png|gif|jp(e?)g)|swf|ico") {<br style="" class=""> unset beresp.http.cookie;<br style="" class=""> }<br style="" class=""> # Don't store backend<br style="" class=""> if (bereq.url ~ "wp-(login|admin)" || bereq.url ~ "preview=true") {<br style="" class=""> set beresp.uncacheable = true;<br style="" class=""> set beresp.ttl = 30s;<br style="" class=""> return (deliver);<br style="" class=""> }<br style="" class=""><br style="" class=""> # Only allow cookies to be set if we're in admin area<br style="" class=""> if (!(bereq.url ~ "(wp-login|wp-admin|preview=true)")) {<br style="" class=""> unset beresp.http.set-cookie;<br style="" class=""> }<br style="" class=""><br style="" class=""> # don't cache response to posted requests or those with basic auth<br style="" class=""> if ( bereq.method == "POST" || bereq.http.Authorization ) {<br style="" class=""> set beresp.uncacheable = true;<br style="" class=""> set beresp.ttl = 120s;<br style="" class=""> return (deliver);<br style="" class=""> }<br style="" class=""><br style="" class=""> # don't cache search results<br style="" class=""> if ( bereq.url ~ "\?s=" ){<br style="" class=""> set beresp.uncacheable = true;<br style="" class=""> set beresp.ttl = 120s;<br style="" class=""> return (deliver);<br style="" class=""> }<br style="" class=""><br style="" class=""> # only cache status ok<br style="" class=""> if ( beresp.status != 200 ) {<br style="" class=""> set beresp.uncacheable = true;<br style="" class=""> set beresp.ttl = 120s;<br style="" class=""> return (deliver);<br style="" class=""> }<br style="" class=""><br style="" class=""> # A TTL of 2h<br style="" class=""> set beresp.ttl = 2h;<br style="" class=""> # Define the default grace period to serve cached content<br style="" class=""> set beresp.grace = 30s;<br style="" class=""><br style="" class=""> return (deliver);<br style="" class="">}<br style="" class=""><br style="" class=""># The routine when we deliver the HTTP request to the user<br style="" class=""># Last chance to modify headers that are sent to the client<br style="" class="">sub vcl_deliver {<br style="" class=""> if (obj.hits > 0) {<br style="" class=""> set resp.http.X-Cache = "cached";<br style="" class=""> } else {<br style="" class=""> set resp.http.x-Cache = "uncached";<br style="" class=""> }<br style="" class=""><br style="" class=""> # Remove some headers: PHP version<br style="" class=""> unset resp.http.X-Powered-By;<br style="" class=""><br style="" class=""> # Remove some headers: Apache version & OS<br style="" class=""> unset resp.http.Server;<br style="" class=""><br style="" class=""> # Remove some heanders: Varnish<br style="" class=""> unset resp.http.Via;<br style="" class=""> unset resp.http.X-Varnish;<br style="" class=""><br style="" class=""> return (deliver);<br style="" class="">}<br style="" class=""><br style="" class="">sub vcl_init {<br style="" class=""> return (ok);<br style="" class="">}<br style="" class=""><br style="" class="">sub vcl_fini {<br style="" class=""> return (ok);<br style="" class="">}<br></div><div style="" class="" dir="ltr"><br style="" class=""></div></div></body></html>