Some doubts

Fabio Fraga [DS] fabio at dataspace.com.br
Fri Aug 2 21:49:47 CEST 2013


Folks,

It my first time here, i'm Fabio.
My apologizes if my questions looks like a children :D
I'm a newbie in Varnish Cache, but I'm studying hard.

I manage a web server with one single domain (popular fitness/health
wordpress blog in Brazil) which receives 50 K page views/day. When the
person goes to tv shows, we receive peaks of 230 K page views/day with 5 or
6 K simultaneous users.
I've got a very good hit ratio, and all pages are showing fast.

Everything works ok, except when the cache is purged after a new post or
causeless (I just can not understand it yet).
The css of home page gone away and wordpress admin not works properly.

When i clear the cache (with command: varnishadm "ban req.url ~ /"),
everything works ok again, but not for long time.

Can u help me, saying if i forgot or missed some syntax or parameter in my
configuration, which goes below.

#######################
default.vcl
#######################

backend default {
        .host = "127.0.0.1";
        .port = "8081";
                .connect_timeout = 300s;
                .first_byte_timeout = 300s;
                .between_bytes_timeout = 300s;
                .url = "/";
                .interval = 5s;
                .timeout = 1 s;
                .window = 5;
                .threshold = 3;
}

#acl purge {
#        "localhost";
#}
sub vcl_recv {

        # Allow the back-end to serve up stale content if it is responding
slowly.
        set req.grace = 2m;

        # Always cache the following file types for all users.
        if ( req.url ~
"(?i)\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm)(\?[a-z0-9]+)?$" ) {
                unset req.http.cookie;
        }

        # Don't serve cached pages to logged in users
        if ( req.http.cookie ~ "wordpress_logged_in" || req.url ~
"vaultpress=true" ) {
                return( pass );
        }

        # Drop any cookies sent to WordPress.
        if ( ! ( req.url ~ "wp-(login|admin)" ) ) {
                unset req.http.cookie;
        }
# Purge Cache
#        if (req.request == "PURGE") {
#                if (!client.ip ~ purge) {
#                        error 405 "Not allowed.";
#                }
#                return (lookup);
#        }

        # Handle compression correctly. Different browsers send different
        # "Accept-Encoding" headers, even though they mostly all support
the same
        # compression mechanisms. By consolidating these compression
headers into
        # a consistent format, we can reduce the size of the cache and get
more hits.
        # @see: http://varnish.projects.linpro.no/wiki/FAQ/Compression
        if ( req.http.Accept-Encoding ) {

                if ( req.http.Accept-Encoding ~ "gzip" ) {
                        # If the browser supports it, we'll use gzip.
                        set req.http.Accept-Encoding = "gzip";
                }

                else if ( req.http.Accept-Encoding ~ "deflate" ) {
                        # Next, try deflate if it is supported.
                        set req.http.Accept-Encoding = "deflate";
                }

                else {
                        # Unknown algorithm. Remove it and send unencoded.
                        unset req.http.Accept-Encoding;
                }

        }
  if ( req.request == "POST") {
        ban("req.http.host == " + req.http.Host);
        return(pass);
    }
}

sub vcl_fetch {

        # Allow items to be stale if needed.
        set beresp.grace = 2m;

        # Tempo de cache depois de transferido do Backend (Apache)
        set beresp.ttl = 48h;
                return (deliver);

        # Drop any cookies WordPress tries to send back to the client.
        if ( ! req.url ~ "wp-(login|admin)" && ! req.http.cookie ~
"wordpress_logged_in" ) {
                unset beresp.http.set-cookie;
        }

}

sub vcl_hit {
  if (req.request == "PURGE") {
    purge;
    error 200 "Purged.";
  }
}

sub vcl_miss {
        if (req.request == "PURGE") {
                purge;
                error 200 "Purged.";
        }
}

sub vcl_deliver {
  if (obj.hits > 0) {
    set resp.http.X-Varnish-Cache = "HIT";
  }
  else {
    set resp.http.X-Varnish-Cache = "MISS";
  }
}

######################
varnishstat
######################

[root~]# varnishstat -1
client_conn             256621        11.19 Client connections accepted
client_drop                  0         0.00 Connection dropped, no sess/wrk
client_req              878216        38.28 Client requests received
cache_hit               672456        29.31 Cache hits
cache_hitpass                0         0.00 Cache hits for pass
cache_miss              170160         7.42 Cache misses
backend_conn              5702         0.25 Backend conn. success
backend_unhealthy            0         0.00 Backend conn. not attempted
backend_busy                 0         0.00 Backend conn. too many
backend_fail                76         0.00 Backend conn. failures
backend_reuse           199994         8.72 Backend conn. reuses
backend_toolate           2152         0.09 Backend conn. was closed
backend_recycle         202152         8.81 Backend conn. recycles
backend_retry               11         0.00 Backend conn. retry
fetch_head                   0         0.00 Fetch head
fetch_length            201283         8.77 Fetch with Length
fetch_chunked             3968         0.17 Fetch chunked
fetch_eof                    0         0.00 Fetch EOF
fetch_bad                    0         0.00 Fetch had bad headers
fetch_close                 60         0.00 Fetch wanted close
fetch_oldhttp                0         0.00 Fetch pre HTTP/1.1 closed
fetch_zero                   0         0.00 Fetch zero len
fetch_failed                34         0.00 Fetch failed
fetch_1xx                    0         0.00 Fetch no body (1xx)
fetch_204                    0         0.00 Fetch no body (204)
fetch_304                  319         0.01 Fetch no body (304)
n_sess_mem                 220          .   N struct sess_mem
n_sess                     128          .   N struct sess
n_object                  7354          .   N struct object
n_vampireobject              0          .   N unresurrected objects
n_objectcore              7435          .   N struct objectcore
n_objecthead              7449          .   N struct objecthead
n_waitinglist               88          .   N struct waitinglist
n_vbc                        5          .   N struct vbc
n_wrk                      100          .   N worker threads
n_wrk_create               100         0.00 N worker threads created
n_wrk_failed                 0         0.00 N worker threads not created
n_wrk_max                    0         0.00 N worker threads limited
n_wrk_lqueue                 0         0.00 work request queue length
n_wrk_queued                 0         0.00 N queued work requests
n_wrk_drop                   0         0.00 N dropped work requests
n_backend                    1          .   N backends
n_expired               162687          .   N expired objects
n_lru_nuked                  0          .   N LRU nuked objects
n_lru_moved             457757          .   N LRU moved objects
losthdr                      0         0.00 HTTP header overflows
n_objsendfile                0         0.00 Objects sent with sendfile
n_objwrite              746317        32.53 Objects sent with write
n_objoverflow                0         0.00 Objects overflowing workspace
s_sess                  256609        11.18 Total Sessions
s_req                   878216        38.28 Total Requests
s_pipe                      32         0.00 Total pipe
s_pass                   35568         1.55 Total pass
s_fetch                 205596         8.96 Total fetch
s_hdrbytes           301843193     13156.22 Total header bytes
s_bodybytes        26851914941   1170375.06 Total body bytes
sess_closed              17724         0.77 Session Closed
sess_pipeline             6099         0.27 Session Pipeline
sess_readahead            2246         0.10 Session Read Ahead
sess_linger             856500        37.33 Session Linger
sess_herd               861705        37.56 Session herd
shm_records           46079248      2008.42 SHM records
shm_writes             2958209       128.94 SHM writes
shm_flushes                  0         0.00 SHM flushes due to overflow
shm_cont                  1658         0.07 SHM MTX contention
shm_cycles                  21         0.00 SHM cycles through buffer
sms_nreq                   132         0.01 SMS allocator requests
sms_nobj                     0          .   SMS outstanding allocations
sms_nbytes                   0          .   SMS outstanding bytes
sms_balloc               55176          .   SMS bytes allocated
sms_bfree                55176          .   SMS bytes freed
backend_req             205663         8.96 Backend requests made
n_vcl                        1         0.00 N vcl total
n_vcl_avail                  1         0.00 N vcl available
n_vcl_discard                0         0.00 N vcl discarded
n_ban                      661          .   N total active bans
n_ban_gone                 659          .   N total gone bans
n_ban_add                  661         0.03 N new bans added
n_ban_retire                 0         0.00 N old bans deleted
n_ban_obj_test          162881         7.10 N objects tested
n_ban_re_test           162891         7.10 N regexps tested against
n_ban_dups                 658         0.03 N duplicate bans removed
hcb_nolock              842631        36.73 HCB Lookups without lock
hcb_lock                  7470         0.33 HCB Lookups with lock
hcb_insert                7470         0.33 HCB Inserts
esi_errors                   0         0.00 ESI parse errors (unlock)
esi_warnings                 0         0.00 ESI parse warnings (unlock)
accept_fail                  0         0.00 Accept failures
client_drop_late             0         0.00 Connection dropped late
uptime                   22943         1.00 Client uptime
dir_dns_lookups              0         0.00 DNS director lookups
dir_dns_failed               0         0.00 DNS director failed lookups
dir_dns_hit                  0         0.00 DNS director cached lookups hit
dir_dns_cache_full           0         0.00 DNS director full dnscache
vmods                        0          .   Loaded VMODs
n_gzip                       0         0.00 Gzip operations
n_gunzip                 26083         1.14 Gunzip operations
sess_pipe_overflow           0          .   Dropped sessions due to session
pipe overflow
LCK.sms.creat                1         0.00 Created locks
LCK.sms.destroy              0         0.00 Destroyed locks
LCK.sms.locks              396         0.02 Lock Operations
LCK.sms.colls                0         0.00 Collisions
LCK.smp.creat                0         0.00 Created locks
LCK.smp.destroy              0         0.00 Destroyed locks
LCK.smp.locks                0         0.00 Lock Operations
LCK.smp.colls                0         0.00 Collisions
LCK.sma.creat                1         0.00 Created locks
LCK.sma.destroy              0         0.00 Destroyed locks
LCK.sma.locks            84162         3.67 Lock Operations
LCK.sma.colls                0         0.00 Collisions
LCK.smf.creat                1         0.00 Created locks
LCK.smf.destroy              0         0.00 Destroyed locks
LCK.smf.locks           689712        30.06 Lock Operations
LCK.smf.colls                0         0.00 Collisions
LCK.hsl.creat                0         0.00 Created locks
LCK.hsl.destroy              0         0.00 Destroyed locks
LCK.hsl.locks                0         0.00 Lock Operations
LCK.hsl.colls                0         0.00 Collisions
LCK.hcb.creat                1         0.00 Created locks
LCK.hcb.destroy              0         0.00 Destroyed locks
LCK.hcb.locks             7712         0.34 Lock Operations
LCK.hcb.colls                0         0.00 Collisions
LCK.hcl.creat                0         0.00 Created locks
LCK.hcl.destroy              0         0.00 Destroyed locks
LCK.hcl.locks                0         0.00 Lock Operations
LCK.hcl.colls                0         0.00 Collisions
LCK.vcl.creat                1         0.00 Created locks
LCK.vcl.destroy              0         0.00 Destroyed locks
LCK.vcl.locks              928         0.04 Lock Operations
LCK.vcl.colls                0         0.00 Collisions
LCK.stat.creat               1         0.00 Created locks
LCK.stat.destroy             0         0.00 Destroyed locks
LCK.stat.locks          256709        11.19 Lock Operations
LCK.stat.colls               0         0.00 Collisions
LCK.sessmem.creat            1         0.00 Created locks
LCK.sessmem.destroy            0         0.00 Destroyed locks
LCK.sessmem.locks         259356        11.30 Lock Operations
LCK.sessmem.colls              0         0.00 Collisions
LCK.wstat.creat                1         0.00 Created locks
LCK.wstat.destroy              0         0.00 Destroyed locks
LCK.wstat.locks            46183         2.01 Lock Operations
LCK.wstat.colls                0         0.00 Collisions
LCK.herder.creat               1         0.00 Created locks
LCK.herder.destroy             0         0.00 Destroyed locks
LCK.herder.locks               1         0.00 Lock Operations
LCK.herder.colls               0         0.00 Collisions
LCK.wq.creat                   2         0.00 Created locks
LCK.wq.destroy                 0         0.00 Destroyed locks
LCK.wq.locks             1805936        78.71 Lock Operations
LCK.wq.colls                   0         0.00 Collisions
LCK.objhdr.creat            7557         0.33 Created locks
LCK.objhdr.destroy           108         0.00 Destroyed locks
LCK.objhdr.locks         3858977       168.20 Lock Operations
LCK.objhdr.colls               0         0.00 Collisions
LCK.exp.creat                  1         0.00 Created locks
LCK.exp.destroy                0         0.00 Destroyed locks
LCK.exp.locks             518339        22.59 Lock Operations
LCK.exp.colls                  0         0.00 Collisions
LCK.lru.creat                  2         0.00 Created locks
LCK.lru.destroy                0         0.00 Destroyed locks
LCK.lru.locks             332730        14.50 Lock Operations
LCK.lru.colls                  0         0.00 Collisions
LCK.cli.creat                  1         0.00 Created locks
LCK.cli.destroy                0         0.00 Destroyed locks
LCK.cli.locks               7663         0.33 Lock Operations
LCK.cli.colls                  0         0.00 Collisions
LCK.ban.creat                  1         0.00 Created locks
LCK.ban.destroy                0         0.00 Destroyed locks
LCK.ban.locks             357251        15.57 Lock Operations
LCK.ban.colls                  0         0.00 Collisions
LCK.vbp.creat                  1         0.00 Created locks
LCK.vbp.destroy                0         0.00 Destroyed locks
LCK.vbp.locks                  0         0.00 Lock Operations
LCK.vbp.colls                  0         0.00 Collisions
LCK.vbe.creat                  1         0.00 Created locks
LCK.vbe.destroy                0         0.00 Destroyed locks
LCK.vbe.locks              11551         0.50 Lock Operations
LCK.vbe.colls                  0         0.00 Collisions
LCK.backend.creat              1         0.00 Created locks
LCK.backend.destroy            0         0.00 Destroyed locks
LCK.backend.locks         421628        18.38 Lock Operations
LCK.backend.colls              0         0.00 Collisions
SMF.s0.c_req              339798        14.81 Allocator requests
SMF.s0.c_fail                  0         0.00 Allocator failures
SMF.s0.c_bytes       14666334208    639250.94 Bytes allocated
SMF.s0.c_freed       14026391552    611358.22 Bytes freed
SMF.s0.g_alloc             14721          .   Allocations outstanding
SMF.s0.g_bytes         639942656          .   Bytes outstanding
SMF.s0.g_space        2006028288          .   Bytes available
SMF.s0.g_smf               16753          .   N struct smf
SMF.s0.g_smf_frag           1982          .   N small free smf
SMF.s0.g_smf_large            50          .   N large free smf
SMA.Transient.c_req        41668         1.82 Allocator requests
SMA.Transient.c_fail           0         0.00 Allocator failures
SMA.Transient.c_bytes    215142059      9377.24 Bytes allocated
SMA.Transient.c_freed    215142059      9377.24 Bytes freed
SMA.Transient.g_alloc            0          .   Allocations outstanding
SMA.Transient.g_bytes            0          .   Bytes outstanding
SMA.Transient.g_space            0          .   Bytes available
VBE.default(127.0.0.1,,8081).vcls            1          .   VCL references
VBE.default(127.0.0.1,,8081).happy           0          .   Happy health
probes


Atenciosamente,
Fábio Fraga Machado

: Telefone: (48) 4052-9252
: MSN:  fabio at dataspace.com.br
: GTalk: fabio at dataspace.com.br
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20130802/2a8c28e6/attachment-0001.html>


More information about the varnish-misc mailing list