Sizing Varnish RAM after over allocation

Crowder, Travis Travis.Crowder at penton.com
Tue Oct 1 19:29:19 CEST 2013


I am trying to properly size our Varnish cache size after it's been allocated way too much memory.  The system is using about 10GB of RAM for Varnish.

Here is what I am using to calculate the total needed:

~ 100MB = Varnish Master Process
~ 80MB = Varnish Shared Memory Log
~ 2KB * n objects = Object storage overhead
~ yKB * n objects = Object storage

With this, I am estimating about 4.2GB for Varnish using a 32KB average object size.  What I am having trouble with is the grace (set for 1 hour) and how that comes into play with storing objects.  Are they stored for 1 hour after expiry in case a backend goes down and after the 1 hour available to be evicted?  When exactly do objects free memory?  I've found different information, but it seems the prevailing thought is only when a purge command occurs.

I am under the impression the expired objects just sit in memory until the cache is full (just before nuking objects) and then LRU eviction occurs.  Is this accurate?  I mean, even though I need about 5GB for Varnish, since I allocate 16GB, will the entire 16GB be used by expired objects?

Is there a way to tell exactly how much RAM is being used for VALID objects?

TIA,
Travis

client_conn            7668521        58.59 Client connections accepted
client_drop                  0         0.00 Connection dropped, no sess/wrk
client_req            15846658       121.06 Client requests received
cache_hit             10757881        82.19 Cache hits
cache_hitpass            32698         0.25 Cache hits for pass
cache_miss             4011878        30.65 Cache misses
backend_conn           4465314        34.11 Backend conn. success
backend_unhealthy            0         0.00 Backend conn. not attempted
backend_busy                 0         0.00 Backend conn. too many
backend_fail                 0         0.00 Backend conn. failures
backend_reuse                0         0.00 Backend conn. reuses
backend_toolate              0         0.00 Backend conn. was closed
backend_recycle              0         0.00 Backend conn. recycles
backend_retry                0         0.00 Backend conn. retry
fetch_head                  89         0.00 Fetch head
fetch_length           2928665        22.37 Fetch with Length
fetch_chunked          1416614        10.82 Fetch chunked
fetch_eof                    0         0.00 Fetch EOF
fetch_bad                    0         0.00 Fetch had bad headers
fetch_close              95492         0.73 Fetch wanted close
fetch_oldhttp                0         0.00 Fetch pre HTTP/1.1 closed
fetch_zero                   0         0.00 Fetch zero len
fetch_failed                 8         0.00 Fetch failed
fetch_1xx                    0         0.00 Fetch no body (1xx)
fetch_204                    0         0.00 Fetch no body (204)
fetch_304                22537         0.17 Fetch no body (304)
n_sess_mem                 682          .   N struct sess_mem
n_sess                     369          .   N struct sess
n_object                119236          .   N struct object
n_vampireobject              0          .   N unresurrected objects
n_objectcore            119437          .   N struct objectcore
n_objecthead            127556          .   N struct objecthead
n_waitinglist             6994          .   N struct waitinglist
n_vbc                       10          .   N struct vbc
n_wrk                      400          .   N worker threads
n_wrk_create               400         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                   11          .   N backends
n_expired              3890039          .   N expired objects
n_lru_nuked                  0          .   N LRU nuked objects
n_lru_moved            8128646          .   N LRU moved objects
losthdr                     91         0.00 HTTP header overflows
n_objsendfile                0         0.00 Objects sent with sendfile
n_objwrite            13494880       103.10 Objects sent with write
n_objoverflow                0         0.00 Objects overflowing workspace
s_sess                 7668501        58.59 Total Sessions
s_req                 15846658       121.06 Total Requests
s_pipe                    1251         0.01 Total pipe
s_pass                  453681         3.47 Total pass
s_fetch                4462324        34.09 Total fetch
s_hdrbytes          7307416930     55826.98 Total header bytes
s_bodybytes       435088023618   3323972.25 Total body bytes
sess_closed            2239685        17.11 Session Closed
sess_pipeline                0         0.00 Session Pipeline
sess_readahead               0         0.00 Session Read Ahead
sess_linger           13878128       106.03 Session Linger
sess_herd             12875482        98.37 Session herd
shm_records          916560440      7002.31 SHM records
shm_writes            61086120       466.68 SHM writes
shm_flushes                 14         0.00 SHM flushes due to overflow
shm_cont                 10334         0.08 SHM MTX contention
shm_cycles                 405         0.00 SHM cycles through buffer
sms_nreq                313389         2.39 SMS allocator requests
sms_nobj                     0          .   SMS outstanding allocations
sms_nbytes                   0          .   SMS outstanding bytes
sms_balloc           544043304          .   SMS bytes allocated
sms_bfree            544043304          .   SMS bytes freed
backend_req            4463489        34.10 Backend requests made
n_vcl                        3         0.00 N vcl total
n_vcl_avail                  3         0.00 N vcl available
n_vcl_discard                0         0.00 N vcl discarded
n_ban                    29993          .   N total active bans
n_ban_gone               29127          .   N total gone bans
n_ban_add                61384         0.47 N new bans added
n_ban_retire             31391         0.24 N old bans deleted
n_ban_obj_test        16197865       123.75 N objects tested
n_ban_re_test       3174198250     24250.14 N regexps tested against
n_ban_dups               33565         0.26 N duplicate bans removed
hcb_nolock            14802058       113.08 HCB Lookups without lock
hcb_lock               3831356        29.27 HCB Lookups with lock
hcb_insert             3831344        29.27 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                  130894         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               3226586        24.65 Gunzip operations
LCK.sms.creat                1         0.00 Created locks
LCK.sms.destroy              0         0.00 Destroyed locks
LCK.sms.locks           940167         7.18 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                2         0.00 Created locks
LCK.sma.destroy              0         0.00 Destroyed locks
LCK.sma.locks         21106576       161.25 Lock Operations
LCK.sma.colls                0         0.00 Collisions
LCK.smf.creat                0         0.00 Created locks
LCK.smf.destroy              0         0.00 Destroyed locks
LCK.smf.locks                0         0.00 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          7544189        57.64 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            17100         0.13 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         7668837        58.59 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        7703601        58.85 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           146130         1.12 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            30510977       233.10 Lock Operations
LCK.wq.colls                   0         0.00 Collisions
LCK.objhdr.creat         3831455        29.27 Created locks
LCK.objhdr.destroy       3703972        28.30 Destroyed locks
LCK.objhdr.locks        79026186       603.74 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            8038327        61.41 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            4017535        30.69 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               1802         0.01 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           37966814       290.06 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             286759         2.19 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            8930660        68.23 Lock Operations
LCK.vbe.colls                  0         0.00 Collisions
LCK.backend.creat             11         0.00 Created locks
LCK.backend.destroy            0         0.00 Destroyed locks
LCK.backend.locks       13425358       102.57 Lock Operations
LCK.backend.colls              0         0.00 Collisions
SMA.s0.c_req             8642204        66.02 Allocator requests
SMA.s0.c_fail                  0         0.00 Allocator failures
SMA.s0.c_bytes      413441801561   3158600.10 Bytes allocated
SMA.s0.c_freed      405211048073   3095719.04 Bytes freed
SMA.s0.g_alloc            238498          .   Allocations outstanding
SMA.s0.g_bytes        8230753488          .   Bytes outstanding
SMA.s0.g_space        8949115696          .   Bytes available
SMA.Transient.c_req       884306         6.76 Allocator requests
SMA.Transient.c_fail           0         0.00 Allocator failures
SMA.Transient.c_bytes  31276155463    238942.62 Bytes allocated
SMA.Transient.c_freed  31276023159    238941.61 Bytes freed
SMA.Transient.g_alloc            2          .   Allocations outstanding
SMA.Transient.g_bytes       132304          .   Bytes outstanding
SMA.Transient.g_space            0          .   Bytes available
VBE.web10(10.2.180.74,,80).vcls            2          .   VCL references
VBE.web10(10.2.180.74,,80).happy18446744073709551615          .   Happy health probes
VBE.web11(10.2.180.75,,80).vcls            3          .   VCL references
VBE.web11(10.2.180.75,,80).happy18446744073709551615          .   Happy health probes
VBE.web12(10.2.180.185,,80).vcls           3          .   VCL references
VBE.web12(10.2.180.185,,80).happy 18446744073709551615          .   Happy health probes
VBE.web13(10.2.180.186,,80).vcls             3          .   VCL references
VBE.web13(10.2.180.186,,80).happy 18446744073709551615          .   Happy health probes
VBE.web14(10.2.180.198,,80).vcls             3          .   VCL references
VBE.web14(10.2.180.198,,80).happy 18446744073709551615          .   Happy health probes
VBE.web15(10.2.180.199,,80).vcls             3          .   VCL references
VBE.web15(10.2.180.199,,80).happy 18446744073709551615          .   Happy health probes
VBE.web16(10.2.180.47,,80).vcls              3          .   VCL references
VBE.web16(10.2.180.47,,80).happy  18446744073709551615          .   Happy health probes
VBE.web17(10.2.180.48,,80).vcls              3          .   VCL references
VBE.web17(10.2.180.48,,80).happy  18446744073709551615          .   Happy health probes
VBE.web18(10.2.180.49,,80).vcls              3          .   VCL references
VBE.web18(10.2.180.49,,80).happy  18446744073709551615          .   Happy health probes
VBE.web19(10.2.180.50,,80).vcls              3          .   VCL references
VBE.web19(10.2.180.50,,80).happy  18446744073709551615          .   Happy health probes
VBE.web20(10.2.180.44,,80).vcls              2          .   VCL references
VBE.web20(10.2.180.44,,80).happy  18446744073709551615          .   Happy health probes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20131001/9a4b4dcd/attachment-0001.html>


More information about the varnish-misc mailing list