Hi Matt,<div>We had some instability when running varnish using a file backed cache that was larger than RAM. This was a year or more ago, and I don't recall the exact details of the issue. We resolved it by reducing the size of the file cache to be smaller than memory and the problems went away.</div>
<div><br></div><div>It looks like you can also increase your thread pool size. We are using something like -w 100,1600,120 at startup and have a similar connection rate. I would also suggest moving to malloc storage type (we are migrating from file to malloc). Kristian is quoted as saying:</div>
<div><br></div><div><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
If you can not contain your cache in memory, first consider if you really need that big of a cache. Then consider buying more memory. Then sleep on it.</blockquote><div> </div><div><a href="http://kristianlyng.wordpress.com/2010/01/26/varnish-best-practices/">http://kristianlyng.wordpress.com/2010/01/26/varnish-best-practices/</a></div>
<div><br></div><div>If you do switch to malloc on this box, try something like -smalloc,40G. You don't want to allocate up to the amount of RAM as varnish needs some additional space for other data and you need to make sure your OS and other processes has some margin as well.</div>
<div><br></div><div>For my part, I wish there was an interface into the size of the objects being cached so that you can better estimate the size of the cache you need. I understand varnishsizes can do something like but it doesn't tell you what is currently stored in aggregate or allow you to traverse the objects and their sizes. </div>
<div><br></div><div>In any case, you can monitor your hit rate and see what impact dropping the extra 12 GB has. I suppose you could argue that your hit rate is moot if you are not responding to connections so just getting rid of the no-response issue should be net positive. </div>
<div><br></div><div>Hope this helps,</div><div>Damon</div><br><div class="gmail_quote">On Thu, Sep 22, 2011 at 9:14 AM, Matt Schurenko <span dir="ltr"><<a href="mailto:MSchurenko@airg.com">MSchurenko@airg.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I posted yesterday regarding this issue. It has happened again; however this time I have not restarted the problem varnish node. I am using the default configuration with regards to threads. It seems that once thread_pool_max hits 500 that the server stops responding to any requests. I stopped all connections from the load balancer to the server; however the threads do not decrease. They remain stuck at ~ 509:<br>
<br>
[root@mvp14 16328]# grep Threads /proc/`pgrep varnishd|tail -n1`/status<br>
Threads: 509<br>
<br>
The server has been idle for ~ 45 minutes now and there are only a couple of established connections:<br>
[root@mvp14 16328]# netstat -ant | grep -w .*:80 | grep EST<br>
tcp 254 0 <a href="http://204.92.101.119:80" target="_blank">204.92.101.119:80</a> <a href="http://192.168.105.32:37554" target="_blank">192.168.105.32:37554</a> ESTABLISHED<br>
tcp 532 0 <a href="http://204.92.101.119:80" target="_blank">204.92.101.119:80</a> <a href="http://192.168.100.153:57722" target="_blank">192.168.100.153:57722</a> ESTABLISHED<br>
tcp 0 0 <a href="http://192.168.100.56:38818" target="_blank">192.168.100.56:38818</a> <a href="http://204.92.101.124:80" target="_blank">204.92.101.124:80</a> ESTABLISHED<br>
<br>
There are however quite a number of connections in CLOSE_WAIT:<br>
<br>
[root@mvp14 16328]# netstat -ant | grep -w .*:80 | grep CLOSE_WAIT | wc -l<br>
1118<br>
<br>
Here is my varnishd version:<br>
<br>
[root@mvp14 16328]# varnishd -V<br>
varnishd (varnish-2.1.5 SVN )<br>
Copyright (c) 2006-2009 Linpro AS / Verdens Gang ASrsion:<br>
<br>
Here are the system limits for varnishd:<br>
<br>
[root@mvp14 16328]# cat /proc/`pgrep varnishd|tail -n1`/limits<br>
Limit Soft Limit Hard Limit Units<br>
Max cpu time unlimited unlimited seconds<br>
Max file size unlimited unlimited bytes<br>
Max data size unlimited unlimited bytes<br>
Max stack size 10485760 unlimited bytes<br>
Max core file size 0 unlimited bytes<br>
Max resident set unlimited unlimited bytes<br>
Max processes 397312 397312 processes<br>
Max open files 131072 131072 files<br>
Max locked memory 32768 32768 bytes<br>
Max address space unlimited unlimited bytes<br>
Max file locks unlimited unlimited locks<br>
Max pending signals 397312 397312 signals<br>
Max msgqueue size 819200 819200 bytes<br>
Max nice priority 0 0<br>
Max realtime priority 0 0<br>
<br>
Here is some memory info on the server:<br>
<br>
[root@mvp14 16328]# free -m<br>
total used free shared buffers cached<br>
Mem: 48299 48170 129 0 92 42815<br>
-/+ buffers/cache: 5262 43037<br>
Swap: 15147 0 15147<br>
<br>
Here is my varnishd command line:<br>
<br>
/usr/local/sbin/varnishd -s file,/tmp/varnish-cache,60G -T <a href="http://127.0.0.1:2000" target="_blank">127.0.0.1:2000</a> -a <a href="http://0.0.0.0:80" target="_blank">0.0.0.0:80</a> -t 604800 -f /usr/local/etc/varnish/default.vcl -p http_headers 384 -p connect_timeout 4.0<br>
<br>
Here is the output from 'varnishstat -1':<br>
<br>
client_conn 32772547 265.09 Client connections accepted<br>
client_drop 13103 0.11 Connection dropped, no sess/wrk<br>
client_req 32531681 263.14 Client requests received<br>
cache_hit 27525134 222.64 Cache hits<br>
cache_hitpass 0 0.00 Cache hits for pass<br>
cache_miss 5005404 40.49 Cache misses<br>
backend_conn 4954451 40.07 Backend conn. success<br>
backend_unhealthy 0 0.00 Backend conn. not attempted<br>
backend_busy 0 0.00 Backend conn. too many<br>
backend_fail 853 0.01 Backend conn. failures<br>
backend_reuse 51728 0.42 Backend conn. reuses<br>
backend_toolate 13 0.00 Backend conn. was closed<br>
backend_recycle 51742 0.42 Backend conn. recycles<br>
backend_unused 0 0.00 Backend conn. unused<br>
fetch_head 5 0.00 Fetch head<br>
fetch_length 81316 0.66 Fetch with Length<br>
fetch_chunked 4924086 39.83 Fetch chunked<br>
fetch_eof 0 0.00 Fetch EOF<br>
fetch_bad 0 0.00 Fetch had bad headers<br>
fetch_close 186 0.00 Fetch wanted close<br>
fetch_oldhttp 0 0.00 Fetch pre HTTP/1.1 closed<br>
fetch_zero 0 0.00 Fetch zero len<br>
fetch_failed 0 0.00 Fetch failed<br>
n_sess_mem 1268 . N struct sess_mem<br>
n_sess 1174 . N struct sess<br>
n_object 4922732 . N struct object<br>
n_vampireobject 0 . N unresurrected objects<br>
n_objectcore 4923144 . N struct objectcore<br>
n_objecthead 4642001 . N struct objecthead<br>
n_smf 9639146 . N struct smf<br>
n_smf_frag 394705 . N small free smf<br>
n_smf_large 0 . N large free smf<br>
n_vbe_conn 501 . N struct vbe_conn<br>
n_wrk 500 . N worker threads<br>
n_wrk_create 3622 0.03 N worker threads created<br>
n_wrk_failed 0 0.00 N worker threads not created<br>
n_wrk_max 4079 0.03 N worker threads limited<br>
n_wrk_queue 502 0.00 N queued work requests<br>
n_wrk_overflow 65305 0.53 N overflowed work requests<br>
n_wrk_drop 13102 0.11 N dropped work requests<br>
n_backend 2 . N backends<br>
n_expired 1347 . N expired objects<br>
n_lru_nuked 381454 . N LRU nuked objects<br>
n_lru_saved 0 . N LRU saved objects<br>
n_lru_moved 23327252 . N LRU moved objects<br>
n_deathrow 0 . N objects on deathrow<br>
losthdr 0 0.00 HTTP header overflows<br>
n_objsendfile 0 0.00 Objects sent with sendfile<br>
n_objwrite 31912510 258.13 Objects sent with write<br>
n_objoverflow 0 0.00 Objects overflowing workspace<br>
s_sess 32758443 264.97 Total Sessions<br>
s_req 32531681 263.14 Total Requests<br>
s_pipe 0 0.00 Total pipe<br>
s_pass 1134 0.01 Total pass<br>
s_fetch 5005593 40.49 Total fetch<br>
s_hdrbytes 10659824012 86223.60 Total header bytes<br>
s_bodybytes 129812627152 1050009.12 Total body bytes<br>
sess_closed 29276120 236.80 Session Closed<br>
sess_pipeline 17 0.00 Session Pipeline<br>
sess_readahead 32 0.00 Session Read Ahead<br>
sess_linger 3510104 28.39 Session Linger<br>
sess_herd 3554241 28.75 Session herd<br>
shm_records 1725429324 13956.40 SHM records<br>
shm_writes 144491896 1168.74 SHM writes<br>
shm_flushes 750 0.01 SHM flushes due to overflow<br>
shm_cont 494654 4.00 SHM MTX contention<br>
shm_cycles 794 0.01 SHM cycles through buffer<br>
sm_nreq 10391973 84.06 allocator requests<br>
sm_nobj 9244441 . outstanding allocations<br>
sm_balloc 41184530432 . bytes allocated<br>
sm_bfree 23239979008 . bytes free<br>
sma_nreq 0 0.00 SMA allocator requests<br>
sma_nobj 0 . SMA outstanding allocations<br>
sma_nbytes 0 . SMA outstanding bytes<br>
sma_balloc 0 . SMA bytes allocated<br>
sma_bfree 0 . SMA bytes free<br>
sms_nreq 945 0.01 SMS allocator requests<br>
sms_nobj 0 . SMS outstanding allocations<br>
sms_nbytes 0 . SMS outstanding bytes<br>
sms_balloc 395010 . SMS bytes allocated<br>
sms_bfree 395010 . SMS bytes freed<br>
backend_req 5006185 40.49 Backend requests made<br>
n_vcl 1 0.00 N vcl total<br>
n_vcl_avail 1 0.00 N vcl available<br>
n_vcl_discard 0 0.00 N vcl discarded<br>
n_purge 1 . N total active purges<br>
n_purge_add 1 0.00 N new purges added<br>
n_purge_retire 0 0.00 N old purges deleted<br>
n_purge_obj_test 0 0.00 N objects tested<br>
n_purge_re_test 0 0.00 N regexps tested against<br>
n_purge_dups 0 0.00 N duplicate purges removed<br>
hcb_nolock 32531033 263.13 HCB Lookups without lock<br>
hcb_lock 5005369 40.49 HCB Lookups with lock<br>
hcb_insert 5005363 40.49 HCB Inserts<br>
esi_parse 0 0.00 Objects ESI parsed (unlock)<br>
esi_errors 0 0.00 ESI parse errors (unlock)<br>
accept_fail 0 0.00 Accept failures<br>
client_drop_late 1 0.00 Connection dropped late<br>
uptime 123630 1.00 Client uptime<br>
backend_retry 0 0.00 Backend conn. retry<br>
dir_dns_lookups 0 0.00 DNS director lookups<br>
dir_dns_failed 0 0.00 DNS director failed lookups<br>
dir_dns_hit 0 0.00 DNS director cached lookups hit<br>
dir_dns_cache_full 0 0.00 DNS director full dnscache<br>
fetch_1xx 0 0.00 Fetch no body (1xx)<br>
fetch_204 0 0.00 Fetch no body (204)<br>
fetch_304 0 0.00 Fetch no body (304)<br>
<br>
Here is some output from varnishlog (Is this normal?):<br>
1442 TTL - 216036249 RFC 604800 1316705246 0 0 0 0<br>
1442 VCL_call - fetch<br>
1442 VCL_return - deliver<br>
1442 ObjProtocol - HTTP/1.1<br>
1442 ObjStatus - 200<br>
1442 ObjResponse - OK<br>
1442 ObjHeader - Date: Thu, 22 Sep 2011 15:27:25 GMT<br>
1442 ObjHeader - Server: Apache/1.3.41 (Unix) mod_perl/1.30<br>
1442 ObjHeader - x-airg-hasbinary: 1<br>
1442 ObjHeader - x-airg-return-contentType: image%2Fjpeg<br>
1442 ObjHeader - x-airg-interfacestatus: 200<br>
1442 ObjHeader - Content-Type: image/jpeg<br>
0 ExpKill - 184966508 LRU<br>
0 ExpKill - 184967370 LRU<br>
0 ExpKill - 184969553 LRU<br>
0 ExpKill - 184970764 LRU<br>
0 ExpKill - 184971732 LRU<br>
0 ExpKill - 184976538 LRU<br>
0 ExpKill - 184977972 LRU<br>
0 ExpKill - 184988825 LRU<br>
0 ExpKill - 184917719 LRU<br>
0 ExpKill - 184997163 LRU<br>
0 ExpKill - 184940621 LRU<br>
0 ExpKill - 185000270 LRU<br>
0 ExpKill - 185001314 LRU<br>
0 ExpKill - 185003793 LRU<br>
0 ExpKill - 185004913 LRU<br>
0 ExpKill - 183651304 LRU<br>
0 ExpKill - 185010145 LRU<br>
0 ExpKill - 185012162 LRU<br>
<br>
<br>
I also noticed in MRTG that when this happens there is a sudden spike in lru nuked activity. It looks like it went from 0 nukes/sec to ~ 200.<br>
<br>
Do I have something misconfigured? Is varnish running into some kind of resource limitation (memory, file descriptors) which is causing it to hang? Did I set the cache size to large compared to the amount of physcial RAM I have? I am running the same version of varnish on the exact same server and this has not happened. The only difference is that I am using '-s file,/tmp/varnish-cache,48G ' instead of '-s file,/tmp/varnish-cache,60G'.<br>
<br>
Any help here would be most appreciated. This is in production right now.<br>
<br>
<br>
<br>
Matt Schurenko<br>
Systems Administrator<br>
<br>
airG share your world<br>
Suite 710, 1133 Melville Street<br>
Vancouver, BC V6E 4E5<br>
P: +1.604.408.2228<br>
F: +1.866.874.8136<br>
E: <a href="mailto:MSchurenko@airg.com">MSchurenko@airg.com</a><br>
W: <a href="http://www.airg.com" target="_blank">www.airg.com</a><br>
_______________________________________________<br>
varnish-misc mailing list<br>
<a 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>
</blockquote></div><br></div>