Sure.<div><br></div><div>~~~default.vcl~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br><div><blockquote type="cite"><blockquote type="cite">NFILES=131072<br>MEMLOCK=90000<br>DAEMON_COREFILE_LIMIT="unlimited"<br>VARNISH_VCL_CONF=/etc/varnish/instructables.vcl<br>
VARNISH_LISTEN_ADDRESS=<br>VARNISH_LISTEN_PORT=80<br>VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1<br>VARNISH_ADMIN_LISTEN_PORT=82<br>VARNISH_MIN_THREADS=400<br>VARNISH_MAX_THREADS=4000<br>VARNISH_THREAD_TIMEOUT=60<br>VARNISH_STORAGE_FILE=/var/lib/varnish/mmap<br>
VARNISH_STORAGE_SIZE=50G<br>VARNISH_STORAGE="file,${VARNISH_STORAGE_FILE},${VARNISH_STORAGE_SIZE}"<br>VARNISH_TTL=1800<br><br>DAEMON_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \<br> -f ${VARNISH_VCL_CONF} \<br>
-T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \<br> -t ${VARNISH_TTL} \<br> -w ${VARNISH_MIN_THREADS},${VARNISH_MAX_THREADS},${VARNISH_THREAD_TIMEOUT} \<br> -u varnish -g varnish \<br>
-s ${VARNISH_STORAGE} \<br> -p obj_workspace=4096 \<br> -p sess_workspace=262144 \<br> -p lru_interval=3600 \<br> -p listen_depth=8192 \<br> -p log_hashstring=off \<br>
-p sess_timeout=10 \<br> -p shm_workspace=32768 \<br> -p ping_interval=1 \<br> -p thread_pools=4 \<br> -p thread_pool_min=100 \<br> -p thread_pool_max=4000 \<br>
-p srcaddr_ttl=0 \<br> -p esi_syntax=1 "<br></blockquote></blockquote></div><div><div>~~~instructables.vcl~~~~~~~~~~~~~~~~~~~</div><div>C{</div><div>#include <stdio.h></div><div>#include <unistd.h></div>
<div><br></div><div>char myhostname[255] = "";</div><div>}C</div><div><br></div><div><br></div><div>acl purge {</div><div> "localhost"; /* myself */</div><div> "backup"; /* purge requests will always come from backup */</div>
<div>}</div><div><br></div><div>backend default {</div><div> /*</div><div> * Default backend definition. Set this to point to your content</div><div> * server.</div><div> */</div><div> .host = "10.0.0.1"; /* put your back end server here! */</div>
<div> .port = "8080";</div><div>}</div><div><br></div><div>sub vcl_recv {</div><div> C{</div><div> if (myhostname[0] == '\0') {</div><div> /* only get hostname once - restart required if hostname changes */</div>
<div> gethostname(myhostname, 255);</div><div> }</div><div> }C</div><div> /* Do not cache if request is not GET or HEAD */</div><div> if (req.request != "GET" && req.request != "HEAD") {</div>
<div> /* Forward to 'lookup' if request is an authorized PURGE request */</div><div> if (req.request == "PURGE") {</div><div> if (!client.ip ~ purge) {</div>
<div> error 405 "Not allowed.";</div><div> }</div><div> lookup;</div><div> }</div><div> set req.http.connection = "close";</div>
<div> pipe;</div><div> }</div><div><br></div><div> /* Do not cache if request contains an Expect header */</div><div> if (req.http.Expect) {</div><div> set req.http.connection = "close";</div>
<div> pipe;</div><div> }</div><div><br></div><div> # normalize Accept-Encoding to reduce vary</div><div> if (req.http.Accept-Encoding) {</div><div> if (req.http.Accept-Encoding ~ "gzip") {</div>
<div> set req.http.Accept-Encoding = "gzip";</div><div> } elsif (req.http.Accept-Encoding ~ "deflate") {</div><div> set req.http.Accept-Encoding = "deflate";</div>
<div> } else {</div><div> unset req.http.Accept-Encoding;</div><div> }</div><div> }</div><div><br></div><div><br></div><div> if (req.url ~ "^/(you|edit|account)") {</div><div>
pass;</div><div> }</div><div><br></div><div> /* Enable grace period (varnish serves stale (but cacheable) objects while retriving</div><div> * object from backend)</div><div> */</div>
<div> set req.grace = 30s;</div><div><br></div><div> if (req.request == "GET" && req.http.cookie) {</div><div> lookup;</div><div> }</div><div>}</div><div><br></div><div>
sub vcl_fetch {</div><div> set obj.http.X-Cache = "MISS";</div><div><br></div><div> /*if (!obj.valid) {</div><div> error;</div><div> }*/</div><div> if (!obj.cacheable) {</div>
<div> pass;</div><div> }</div><div> if (obj.http.Set-Cookie) {</div><div> pass;</div><div> }</div><div><br></div><div> if(obj.status >= 500 && obj.status < 600) {</div>
<div> pass;</div><div> }</div><div> /* Do not cache if response contains any 'no cache' tokens</div><div> */</div><div> if (obj.http.Cache-Control ~ "(private|no-cache|no-store)") {</div>
<div> pass;</div><div> }</div><div><br></div><div> /*</div><div> * object from backend)</div><div> */</div><div> set obj.grace = 30s;</div><div><br></div><div> /* you might want to change this, I have a default TTL of 10 min here. */</div>
<div> if (obj.ttl < 1s) {</div><div> set obj.ttl = 1711s;</div><div> }</div><div><br></div><div> deliver;</div><div>}</div><div><br></div><div>sub vcl_pipe {</div><div> pipe;</div>
<div>}</div><div><br></div><div>sub vcl_pass {</div><div> pass;</div><div>}</div><div><br></div><div>sub vcl_hash {</div><div> set req.hash += req.url;</div><div> set req.hash += req.http.host;</div><div>
hash;</div><div>}</div><div><br></div><div>sub vcl_hit {</div><div><br></div><div> if (req.request == "PURGE") {</div><div> purge_url(req.url);</div><div> error 200 "Purged";</div>
<div> }</div><div> if (!obj.cacheable) {</div><div> pass;</div><div> }</div><div><br></div><div><br></div><div> deliver;</div><div>}</div><div><br></div><div>sub vcl_miss {</div>
<div><br></div><div> /* Varnish doesn't do IMS to backend, so if not in cache just pass it through */</div><div> if (req.http.If-Modified-Since) {</div><div> pass;</div><div> }</div>
<div><br></div><div> if (req.request == "PURGE") {</div><div> error 404 "Not in cache";</div><div> }</div><div><br></div><div> fetch;</div><div>}</div><div><br></div>
<div>sub vcl_hit {</div><div> if (req.request == "PURGE") {</div><div> purge_url(req.url);</div><div> error 200 "Purged";</div><div> }</div><div> if (!obj.cacheable) {</div>
<div> pass;</div><div> }</div><div> deliver;</div><div>}</div><div><br></div><div>sub vcl_timeout {</div><div> discard;</div><div>}</div><div><br></div><div>sub vcl_discard {</div><div>
discard;</div><div>}</div><div><br></div><div>sub vcl_deliver {</div><div><br></div><div> C{</div><div> VRT_SetHdr(sp, HDR_RESP, "\014X-Cache-Svr:", myhostname, vrt_magic_string_end);</div><div> }C</div>
<div><br></div><div> /* mark hit/miss on the request */</div><div> if (obj.hits > 0) {</div><div> set resp.http.X-Cache = "HIT";</div><div> set resp.http.X-Cache-Hits = obj.hits;</div><div>
} else {</div><div> set resp.http.X-Cache = "MISS";</div><div> }</div><div> deliver;</div><div>}</div><div><br></div><div>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</div><br><div class="gmail_quote">
On Thu, May 14, 2009 at 9:28 AM, Artur Bergman <span dir="ltr"><<a href="mailto:sky@crucially.net">sky@crucially.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div style="word-wrap:break-word">Can you share your VCL?<div><br></div><div>Artur</div><div><div></div><div class="h5"><div><br><div><div>On May 14, 2009, at 9:26 AM, Cloude Porteus wrote:</div><br><blockquote type="cite">
I was able to find this entry in /var/log/messages, but it's hard to tell if it's going to be helpful or not for debugging. I can't seem to find a daemon.log in /var/log.<div><br></div><div><div>May 13 13:06:48 squid03 varnishd[14993]: Child (14994) not responding to ping, killing it.</div>
<div>May 13 13:06:48 squid03 varnishd[14993]: Child (14994) died signal=6</div><div>May 13 13:06:48 squid03 varnishd[14993]: Child (14994) Panic message: Assert error in Tcheck(), cache.h line 648: Condition((t.e) != 0) not true. thread = (cache-worker)sp = 0x2ab733984008 { fd = 19, id = 19, xid = 2173533104, client = <a href="http://10.0.0.1:58322" target="_blank">10.0.0.1:58322</a>, step = STP_FETCH, handling = fetch, ws = 0x2ab733984078 { id = "sess", {s,f,r,e} = {0x2ab733984808,,+1162,(nil),+262144}, }, worker = 0x2ab7b4a46bd0 { }, vcl = { srcname = { "input", "Default", }, }, obj = 0x2aaddddaf000 { refcnt = 1, xid = 2173533104, ws = 0x2aaddddaf028 { id = "obj", {s,f,r,e} = {0x2aaddddaf358,,0x2aaddddaf358,(nil),+3240}, }, http = { ws = 0x2aaddddaf028 { id = "obj", {s,f,r,e} = {0x2aaddddaf358,,0x2aaddddaf358,(nil),+3240}, }, }, len = 0, store = { }, }, },</div>
<div>May 13 13:06:48 squid03 varnishd[14993]: child (32738) Started</div><div>May 13 13:06:48 squid03 varnishd[14993]: Child (32738) said Closed fds: 4 5 6 10 11 13 14</div><div>May 13 13:06:48 squid03 varnishd[14993]: Child (32738) said Child starts</div>
<div>May 13 13:06:48 squid03 varnishd[14993]: Child (32738) said managed to mmap 53687091200 bytes of 53687091200</div><div>May 13 13:06:48 squid03 varnishd[14993]: Child (32738) said Ready</div><div>May 13 13:06:50 squid03 varnishd[14993]: Child (32738) died signal=6</div>
<div>May 13 13:06:50 squid03 varnishd[14993]: Child (32738) Panic message: Assert error in Tcheck(), cache.h line 648: Condition((t.e) != 0) not true. thread = (cache-worker)sp = 0x2ab736402008 { fd = 267, id = 267, xid = 1961344622, client = <a href="http://10.0.0.1:59424" target="_blank">10.0.0.1:59424</a>, step = STP_FETCH, handling = fetch, ws = 0x2ab736402078 { id = "sess", {s,f,r,e} = {0x2ab736402808,,+1162,(nil),+262144}, }, worker = 0x2ab7432ffbd0 { }, vcl = { srcname = { "input", "Default", }, }, obj = 0x2aaab0ce0000 { refcnt = 1, xid = 1961344622, ws = 0x2aaab0ce0028 { id = "obj", {s,f,r,e} = {0x2aaab0ce0358,,0x2aaab0ce0358,(nil),+3240}, }, http = { ws = 0x2aaab0ce0028 { id = "obj", {s,f,r,e} = {0x2aaab0ce0358,,0x2aaab0ce0358,(nil),+3240}, }, }, len = 0, store = { }, }, },</div>
<div>May 13 13:06:50 squid03 varnishd[14993]: child (390) Started</div><div>May 13 13:06:50 squid03 varnishd[14993]: Child (390) said Closed fds: 4 5 6 10 11 13 14</div><div>May 13 13:06:50 squid03 varnishd[14993]: Child (390) said Child starts</div>
<div>May 13 13:06:50 squid03 varnishd[14993]: Child (390) said managed to mmap 53687091200 bytes of 53687091200</div><div>May 13 13:06:50 squid03 varnishd[14993]: Child (390) said Ready</div><div><br></div><br><div class="gmail_quote">
On Wed, May 13, 2009 at 5:57 PM, John Adams <span dir="ltr"><<a href="mailto:jna@twitter.com" target="_blank">jna@twitter.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">Go look in /var/log/daemon.log, and find out why the children are dying. If you're getting SEGVs, that's going to be listed in your syslog.<div><br></div><div>A big reason for crashing is running out of session workspace (sess_workspace). Find out if that's happening, and if it is, increase it. (say, to 512k)</div>
<div><br></div><div><br></div><div>-j</div><div><br><div><div><div></div><div><div>On May 13, 2009, at 5:17 PM, Cloude Porteus wrote:</div><br></div></div><blockquote type="cite"><div><div></div><div> Varnish seems to restart itself every so often, usually after a few days. We finally installed some SSD's, which made all the difference and our system load came down to the .02 - .2 range.<br>
<br>I don't currently have any logging turned on. If I did, would it have any useful information for me? <br> <br>We typically don't have more that 700k objects cached. I also never see the worker threads go above 400. We are running on CentOS 5.<br>
<br>Our config:<br><br>NFILES=131072<br>MEMLOCK=90000<br>DAEMON_COREFILE_LIMIT="unlimited"<br> VARNISH_VCL_CONF=/etc/varnish/instructables.vcl<br>VARNISH_LISTEN_ADDRESS=<br>VARNISH_LISTEN_PORT=80<br>VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1<br>
VARNISH_ADMIN_LISTEN_PORT=82<br>VARNISH_MIN_THREADS=400<br>VARNISH_MAX_THREADS=4000<br> VARNISH_THREAD_TIMEOUT=60<br>VARNISH_STORAGE_FILE=/var/lib/varnish/mmap<br>VARNISH_STORAGE_SIZE=50G<br>VARNISH_STORAGE="file,${VARNISH_STORAGE_FILE},${VARNISH_STORAGE_SIZE}"<br>
VARNISH_TTL=1800<br><br>DAEMON_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \<br> -f ${VARNISH_VCL_CONF} \<br> -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \<br>
-t ${VARNISH_TTL} \<br> -w ${VARNISH_MIN_THREADS},${VARNISH_MAX_THREADS},${VARNISH_THREAD_TIMEOUT} \<br> -u varnish -g varnish \<br> -s ${VARNISH_STORAGE} \<br> -p obj_workspace=4096 \<br>
-p sess_workspace=262144 \<br> -p lru_interval=3600 \<br> -p listen_depth=8192 \<br> -p log_hashstring=off \<br> -p sess_timeout=10 \<br> -p shm_workspace=32768 \<br>
-p ping_interval=1 \<br> -p thread_pools=4 \<br> -p thread_pool_min=100 \<br> -p thread_pool_max=4000 \<br> -p srcaddr_ttl=0 \<br> -p esi_syntax=1 "<br>
<br>I don't think out load is all that heavy and we have a high hitrate ratio. Our varnishstat output.<br> <br>0+11:02:14 <br>Hitrate ratio: 10 100 133<br>
Hitrate avg: 0.9875 0.9833 0.9832<br><br> 15370527 325.94 386.84 Client connections accepted<br> 15370517 325.94 386.84 Client requests received<br> 14604988 320.94 367.57 Cache hits<br>
182795 4.00 4.60 Cache hits for pass<br> 581426 1.00 14.63 Cache misses<br> 765513 5.00 19.27 Backend connections success<br> 1 0.00 0.00 Backend connections failures<br>
119 . . N struct sess_mem<br> 10 . . N struct sess<br> 447866 . . N struct object<br> 440545 . . N struct objecthead<br>
913238 . . N struct smf<br> 4490 . . N small free smf<br> 2 . . N large free smf<br> 0 . . N struct vbe_conn<br>
112 . . N struct bereq<br> 400 . . N worker threads<br> 400 0.00 0.01 N worker threads created<br> 313048 0.00 7.88 N worker threads limited<br>
1 . . N backends<br> 126326 . . N expired objects<br> 1250255 . . N LRU moved objects<br> 18 0.00 0.00 HTTP header overflows<br>
13645614 292.95 343.42 Objects sent with write<br> 15370518 327.94 386.84 Total Sessions<br> 15370510 327.94 386.84 Total Requests<br> 7 0.00 0.00 Total pipe<br>
191394 5.00 4.82 Total pass<br> 765481 9.00 19.27 Total fetch<br> 7252376430 156332.93 182523.19 Total header bytes<br> 74103505138 772233.39 1864989.81 Total body bytes<br>
15370160 327.94 386.83 Session Closed<br> 365 0.00 0.01 Session herd<br> 758091326 15625.09 19079.16 SHM records<br> 62365137 1317.75 1569.57 SHM writes<br> 468 0.00 0.01 SHM flushes due to overflow<br>
589 0.00 0.01 SHM MTX contention<br> 307 0.00 0.01 SHM cycles through buffer<br> 1573886 15.00 39.61 allocator requests<br> 908746 . . outstanding allocations<br>
7766196224 . . bytes allocated<br> 45920894976 . . bytes free<br> <br clear="all"><br>-- <br> VP of Product Development<br>Instructables.com<br><br><a href="http://www.instructables.com/member/lebowski" target="_blank">http://www.instructables.com/member/lebowski</a><br>
</div></div><div> _______________________________________________<br>varnish-dev mailing list<br><a href="mailto:varnish-dev@projects.linpro.no" target="_blank">varnish-dev@projects.linpro.no</a><br><a href="http://projects.linpro.no/mailman/listinfo/varnish-dev" target="_blank">http://projects.linpro.no/mailman/listinfo/varnish-dev</a><br>
</div></blockquote></div><br><div> <div style="word-wrap:break-word"><span style="border-collapse:separate;color:rgb(0, 0, 0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="word-wrap:break-word">
<div>---</div><div>John Adams</div><div>Twitter Operations</div><div><a href="mailto:jna@twitter.com" target="_blank">jna@twitter.com</a></div><div><a href="http://twitter.com/netik" target="_blank">http://twitter.com/netik</a></div>
<div><br></div></div></span><br></div><br> </div><br></div></div></blockquote></div><br><br clear="all"><br>-- <br>VP of Product Development<br>Instructables.com<br><br><a href="http://www.instructables.com/member/lebowski" target="_blank">http://www.instructables.com/member/lebowski</a><br>
</div> _______________________________________________<br>varnish-dev mailing list<br><a href="mailto:varnish-dev@projects.linpro.no" target="_blank">varnish-dev@projects.linpro.no</a><br><a href="http://projects.linpro.no/mailman/listinfo/varnish-dev" target="_blank">http://projects.linpro.no/mailman/listinfo/varnish-dev</a><br>
</blockquote></div><br></div></div></div></div></blockquote></div><br><br clear="all"><br>-- <br>VP of Product Development<br>Instructables.com<br><br><a href="http://www.instructables.com/member/lebowski">http://www.instructables.com/member/lebowski</a><br>
</div></div>