<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_1429203791872_14009">Ok, I have just disabled w3 total cache, all deflate, expiresbytype and modpagespeed in .htaccess and now the hitrate is close to 1 and the load time is less than a second (before it was 1.5 seconds).<br></div><div id="yui_3_16_0_1_1429203791872_14045"><br></div><div id="yui_3_16_0_1_1429203791872_14046" dir="ltr">But still the number of requests per second reported by Apache Benchmark is low. <br></div><div id="yui_3_16_0_1_1429203791872_14073" dir="ltr"><br></div><div id="yui_3_16_0_1_1429203791872_14074" dir="ltr">Regards,</div><div id="yui_3_16_0_1_1429203791872_14075" dir="ltr"><br></div><div id="yui_3_16_0_1_1429203791872_14076" dir="ltr">Miguel<br></div><div id="yui_3_16_0_1_1429203791872_13952"><span></span></div><br>  <div id="yui_3_16_0_1_1429203791872_13941" style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div id="yui_3_16_0_1_1429203791872_13940" style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div id="yui_3_16_0_1_1429203791872_13939" dir="ltr"> <hr id="yui_3_16_0_1_1429203791872_13959" size="1">  <font id="yui_3_16_0_1_1429203791872_13947" face="Arial" size="2"> <b id="yui_3_16_0_1_1429203791872_14078"><span id="yui_3_16_0_1_1429203791872_14077" style="font-weight:bold;">De:</span></b> Miguel Gonzalez <miguel_3_gonzalez@yahoo.es><br> <b id="yui_3_16_0_1_1429203791872_13949"><span id="yui_3_16_0_1_1429203791872_13948" style="font-weight: bold;">Para:</span></b> "varnish-misc@varnish-cache.org" <varnish-misc@varnish-cache.org> <br> <b id="yui_3_16_0_1_1429203791872_13946"><span id="yui_3_16_0_1_1429203791872_13945" style="font-weight: bold;">Enviado:</span></b> Jueves 16 de abril de 2015 16:44<br> <b><span style="font-weight: bold;">Asunto:</span></b> increase hitrate<br> </font> </div> <div id="yui_3_16_0_1_1429203791872_13942" class="y_msg_container"><br><div id="yiv3618884895"><div id="yui_3_16_0_1_1429203791872_13944"><div id="yui_3_16_0_1_1429203791872_13943" style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;"><div id="yiv3618884895yui_3_16_0_1_1429192664994_12851">Dear all,</div><div id="yiv3618884895yui_3_16_0_1_1429192664994_12853"><br></div><div id="yiv3618884895yui_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="yiv3618884895yui_3_16_0_1_1429192664994_12857" dir="ltr"><br></div><div id="yiv3618884895yui_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="yiv3618884895yui_3_16_0_1_1429192664994_12861" dir="ltr"><br></div><div id="yiv3618884895yui_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="yiv3618884895yui_3_16_0_1_1429192664994_12999" dir="ltr"><br></div><div id="yiv3618884895yui_3_16_0_1_1429192664994_13031" dir="ltr"> Thanks</div><div id="yiv3618884895yui_3_16_0_1_1429192664994_13033" dir="ltr"><br></div><div id="yiv3618884895yui_3_16_0_1_1429192664994_13035" dir="ltr"> Miguel<br></div><div id="yiv3618884895yui_3_16_0_1_1429192664994_12865" dir="ltr"><br></div><div id="yiv3618884895yui_3_16_0_1_1429192664994_12875" dir="ltr"><br></div><div id="yiv3618884895yui_3_16_0_1_1429192664994_12906" dir="ltr">This is my /etc/sysconfig/varnish daemon configuration:</div><div id="yiv3618884895yui_3_16_0_1_1429192664994_12965" dir="ltr"><br></div><pre id="yiv3618884895yui_3_16_0_1_1429192664994_12975" style="" class="yiv3618884895">/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="yiv3618884895yui_3_16_0_1_1429192664994_12908" dir="ltr"><br></div><div id="yiv3618884895yui_3_16_0_1_1429192664994_12867" dir="ltr">This is my default.vcl configuration:</div><div id="yiv3618884895yui_3_16_0_1_1429192664994_12869" dir="ltr"><br></div><div id="yiv3618884895yui_3_16_0_1_1429192664994_12871" dir="ltr"> <br></div><div id="yiv3618884895yui_3_16_0_1_1429192664994_12846" dir="ltr">vcl 4.0;<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">import std;<br style="" class="yiv3618884895"><br style="" class="yiv3618884895"># Default backend definition. Set this to point to your content server.<br style="" class="yiv3618884895">backend default {<br style="" class="yiv3618884895">    .host = "192.168.1.10";<br style="" class="yiv3618884895">    .port = "82";<br style="" class="yiv3618884895">}<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">acl purge {<br style="" class="yiv3618884895">        "localhost";<br style="" class="yiv3618884895">}<br style="" class="yiv3618884895"><br style="" class="yiv3618884895"># This function is used when a request is send by a HTTP client (Browser)<br style="" class="yiv3618884895">sub vcl_recv {<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">        # remove ?ver=xxxxx strings from urls so css and js files are cached.<br style="" class="yiv3618884895">        # Watch out when upgrading WordPress, need to restart Varnish or flush cache.<br style="" class="yiv3618884895">        set req.url = regsub(req.url, "\?ver=.*$", "");<br style="" class="yiv3618884895"> <br style="" class="yiv3618884895">        # Remove "replytocom" from requests to make caching better.<br style="" class="yiv3618884895">        set req.url = regsub(req.url, "\?replytocom=.*$", "");<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">        # We pass real IP to the backend<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">        if (req.restarts == 0) {<br style="" class="yiv3618884895">            if (req.http.X-Forwarded-For) {<br style="" class="yiv3618884895">               set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip;<br style="" class="yiv3618884895">           } else {<br style="" class="yiv3618884895">            set req.http.X-Forwarded-For = client.ip;<br style="" class="yiv3618884895">           }<br style="" class="yiv3618884895">        }<br style="" class="yiv3618884895"><br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    <br style="" class="yiv3618884895"><br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    # Normalize the header, remove the port (in case you're testing this on various TCP ports)<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">        set req.http.Host = regsub(req.http.Host, ":[0-9]+", "");<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    # Remove has_js and CloudFlare/Google Analytics __* cookies.<br style="" class="yiv3618884895">    set req.http.Cookie = regsuball(req.http.Cookie, "(^|;\s*)(_[_a-z]+|has_js)=[^;]*", "");<br style="" class="yiv3618884895">    # Remove a ";" prefix, if present.<br style="" class="yiv3618884895">    set req.http.Cookie = regsub(req.http.Cookie, "^;\s*", "");<br style="" class="yiv3618884895"><br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    # Allow purging from ACL<br style="" class="yiv3618884895">    if (req.method == "PURGE") {<br style="" class="yiv3618884895">        # If not allowed then a error 405 is returned<br style="" class="yiv3618884895">        if (!client.ip ~ purge) {<br style="" class="yiv3618884895">            return(synth(405, "This IP is not allowed to send PURGE requests."));<br style="" class="yiv3618884895">        }<br style="" class="yiv3618884895">        # If allowed, do a cache_lookup -> vlc_hit() or vlc_miss()<br style="" class="yiv3618884895">        return (purge);<br style="" class="yiv3618884895">    }<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    # Post requests will not be cached<br style="" class="yiv3618884895">    #if (req.http.Authorization || req.method == "POST") {<br style="" class="yiv3618884895">    #    return (pass);<br style="" class="yiv3618884895">    #}<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">        # Pass anything other than GET and HEAD directly.<br style="" class="yiv3618884895">        if (req.method != "GET" && req.method != "HEAD") {<br style="" class="yiv3618884895">                return( pass );<br style="" class="yiv3618884895">        }      /* We only deal with GET and HEAD by default */<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    # --- WordPress specific configuration<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    # Did not cache the admin and login pages<br style="" class="yiv3618884895">    if (req.url ~ "wp-(login|admin)" || req.url ~ "preview=true") {<br style="" class="yiv3618884895">    return (pass);<br style="" class="yiv3618884895">    }<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    if (req.url ~ "(ajax|dynamic|custom)") {<br style="" class="yiv3618884895">             return(pass);<br style="" class="yiv3618884895">        }<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    # Remove the "has_js" cookie<br style="" class="yiv3618884895">    set req.http.Cookie = regsuball(req.http.Cookie, "has_js=[^;]+(; )?", "");<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    # Remove any Google Analytics based cookies<br style="" class="yiv3618884895">    set req.http.Cookie = regsuball(req.http.Cookie, "__utm.=[^;]+(; )?", "");<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    # Remove the Quant Capital cookies (added by some plugin, all __qca)<br style="" class="yiv3618884895">    set req.http.Cookie = regsuball(req.http.Cookie, "__qc.=[^;]+(; )?", "");<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    # Remove the wp-settings-1 cookie<br style="" class="yiv3618884895">    set req.http.Cookie = regsuball(req.http.Cookie, "wp-settings-1=[^;]+(; )?", "");<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    # Remove the wp-settings-time-1 cookie<br style="" class="yiv3618884895">    set req.http.Cookie = regsuball(req.http.Cookie, "wp-settings-time-1=[^;]+(; )?", "");<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    # Remove the wp test cookie<br style="" class="yiv3618884895">    set req.http.Cookie = regsuball(req.http.Cookie, "wordpress_test_cookie=[^;]+(; )?", "");<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    # Are there cookies left with only spaces or that are empty?<br style="" class="yiv3618884895">    if (req.http.cookie ~ "^ *$") {<br style="" class="yiv3618884895">            unset req.http.cookie;<br style="" class="yiv3618884895">    }<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    # Cache the following files extensions<br style="" class="yiv3618884895">    if (req.url ~ "\.(css|js|png|gif|jp(e)?g|swf|ico)") {<br style="" class="yiv3618884895">        unset req.http.cookie;<br style="" class="yiv3618884895">    }<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    # Normalize Accept-Encoding header and compression<br style="" class="yiv3618884895">    # https://www.varnish-cache.org/docs/3.0/tutorial/vary.html<br style="" class="yiv3618884895">    if (req.http.Accept-Encoding) {<br style="" class="yiv3618884895">        # Do no compress compressed files...<br style="" class="yiv3618884895">        if (req.url ~ "\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$") {<br style="" class="yiv3618884895">                   unset req.http.Accept-Encoding;<br style="" class="yiv3618884895">        } elsif (req.http.Accept-Encoding ~ "gzip") {<br style="" class="yiv3618884895">                set req.http.Accept-Encoding = "gzip";<br style="" class="yiv3618884895">        } elsif (req.http.Accept-Encoding ~ "deflate") {<br style="" class="yiv3618884895">                set req.http.Accept-Encoding = "deflate";<br style="" class="yiv3618884895">        } else {<br style="" class="yiv3618884895">            unset req.http.Accept-Encoding;<br style="" class="yiv3618884895">        }<br style="" class="yiv3618884895">    }<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    # Check the cookies for wordpress-specific items<br style="" class="yiv3618884895">    if (req.http.Cookie ~ "wordpress_" || req.http.Cookie ~ "comment_") {<br style="" class="yiv3618884895">        return (pass);<br style="" class="yiv3618884895">    }<br style="" class="yiv3618884895">    if (!req.http.cookie) {<br style="" class="yiv3618884895">        unset req.http.cookie;<br style="" class="yiv3618884895">    }<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    # --- End of WordPress specific configuration<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    # Did not cache HTTP authentication and HTTP Cookie<br style="" class="yiv3618884895">    if (req.http.Authorization || req.http.Cookie) {<br style="" class="yiv3618884895">        # Not cacheable by default<br style="" class="yiv3618884895">        return (pass);<br style="" class="yiv3618884895">    }<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    # Cache all others requests<br style="" class="yiv3618884895">    return (hash);<br style="" class="yiv3618884895">}<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">sub vcl_pipe {<br style="" class="yiv3618884895">    return (pipe);<br style="" class="yiv3618884895">}<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">sub vcl_pass {<br style="" class="yiv3618884895">    return (fetch);<br style="" class="yiv3618884895">}<br style="" class="yiv3618884895"><br style="" class="yiv3618884895"># The data on which the hashing will take place<br style="" class="yiv3618884895">sub vcl_hash {<br style="" class="yiv3618884895">     hash_data(req.url);<br style="" class="yiv3618884895">     if (req.http.host) {<br style="" class="yiv3618884895">         hash_data(req.http.host);<br style="" class="yiv3618884895">     } else {<br style="" class="yiv3618884895">         hash_data(server.ip);<br style="" class="yiv3618884895">     }<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    # If the client supports compression, keep that in a different cache<br style="" class="yiv3618884895">        if (req.http.Accept-Encoding) {<br style="" class="yiv3618884895">            hash_data(req.http.Accept-Encoding);<br style="" class="yiv3618884895">    }<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    return (lookup);<br style="" class="yiv3618884895">}<br style="" class="yiv3618884895"><br style="" class="yiv3618884895"># This function is used when a request is sent by our backend (Nginx server)<br style="" class="yiv3618884895">sub vcl_backend_response {<br style="" class="yiv3618884895">    # Remove some headers we never want to see<br style="" class="yiv3618884895">    unset beresp.http.Server;<br style="" class="yiv3618884895">    unset beresp.http.X-Powered-By;<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    # For static content strip all backend cookies<br style="" class="yiv3618884895">    if (bereq.url ~ "\.(css|js|png|gif|jp(e?)g)|swf|ico") {<br style="" class="yiv3618884895">        unset beresp.http.cookie;<br style="" class="yiv3618884895">    }<br style="" class="yiv3618884895">    # Don't store backend<br style="" class="yiv3618884895">    if (bereq.url ~ "wp-(login|admin)" || bereq.url ~ "preview=true") {<br style="" class="yiv3618884895">        set beresp.uncacheable = true;<br style="" class="yiv3618884895">        set beresp.ttl = 30s;<br style="" class="yiv3618884895">        return (deliver);<br style="" class="yiv3618884895">    }<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    # Only allow cookies to be set if we're in admin area<br style="" class="yiv3618884895">        if (!(bereq.url ~ "(wp-login|wp-admin|preview=true)")) {<br style="" class="yiv3618884895">            unset beresp.http.set-cookie;<br style="" class="yiv3618884895">    }<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    # don't cache response to posted requests or those with basic auth<br style="" class="yiv3618884895">    if ( bereq.method == "POST" || bereq.http.Authorization ) {<br style="" class="yiv3618884895">            set beresp.uncacheable = true;<br style="" class="yiv3618884895">        set beresp.ttl = 120s;<br style="" class="yiv3618884895">        return (deliver);<br style="" class="yiv3618884895">        }<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">        # don't cache search results<br style="" class="yiv3618884895">    if ( bereq.url ~ "\?s=" ){<br style="" class="yiv3618884895">        set beresp.uncacheable = true;<br style="" class="yiv3618884895">                set beresp.ttl = 120s;<br style="" class="yiv3618884895">                return (deliver);<br style="" class="yiv3618884895">    }<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    # only cache status ok<br style="" class="yiv3618884895">    if ( beresp.status != 200 ) {<br style="" class="yiv3618884895">        set beresp.uncacheable = true;<br style="" class="yiv3618884895">                set beresp.ttl = 120s;<br style="" class="yiv3618884895">                return (deliver);<br style="" class="yiv3618884895">    }<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    # A TTL of 2h<br style="" class="yiv3618884895">    set beresp.ttl = 2h;<br style="" class="yiv3618884895">    # Define the default grace period to serve cached content<br style="" class="yiv3618884895">    set beresp.grace = 30s;<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    return (deliver);<br style="" class="yiv3618884895">}<br style="" class="yiv3618884895"><br style="" class="yiv3618884895"># The routine when we deliver the HTTP request to the user<br style="" class="yiv3618884895"># Last chance to modify headers that are sent to the client<br style="" class="yiv3618884895">sub vcl_deliver {<br style="" class="yiv3618884895">    if (obj.hits > 0) {<br style="" class="yiv3618884895">        set resp.http.X-Cache = "cached";<br style="" class="yiv3618884895">    } else {<br style="" class="yiv3618884895">        set resp.http.x-Cache = "uncached";<br style="" class="yiv3618884895">    }<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    # Remove some headers: PHP version<br style="" class="yiv3618884895">    unset resp.http.X-Powered-By;<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    # Remove some headers: Apache version & OS<br style="" class="yiv3618884895">    unset resp.http.Server;<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    # Remove some heanders: Varnish<br style="" class="yiv3618884895">    unset resp.http.Via;<br style="" class="yiv3618884895">    unset resp.http.X-Varnish;<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">    return (deliver);<br style="" class="yiv3618884895">}<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">sub vcl_init {<br style="" class="yiv3618884895">     return (ok);<br style="" class="yiv3618884895">}<br style="" class="yiv3618884895"><br style="" class="yiv3618884895">sub vcl_fini {<br style="" class="yiv3618884895">     return (ok);<br style="" class="yiv3618884895">}<br></div><div style="" class="yiv3618884895" dir="ltr"><br style="" class="yiv3618884895"></div></div></div></div><br>_______________________________________________<br>varnish-misc mailing list<br><a ymailto="mailto:varnish-misc@varnish-cache.org" href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a><br><a href="https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" target="_blank">https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc</a><br><br></div> </div> </div>  </div></body></html>