Theoretical connections/second limit using Varnish

Nick Loman nick at loman.net
Fri May 1 12:25:52 CEST 2009


Poul-Henning Kamp wrote:
> In message <49FAB28F.2040903 at loman.net>, Nick Loman writes:
>> Poul-Henning Kamp wrote:
> 
>> Which way round do you mean?
>>
>> Apache specifies Keep-Alive in seconds, and my sites will certainly die 
>> if I set it to even 1 second.
> 
> Tell the apache developers to get their act together then.

Hi Poul-Henning,

I'm sure I could find a way of getting Apache to put in a 10msec 
Keep-Alive timeout if that was necessary.

Are you proposing that Varnish would then hold and re-use that backend 
connection for a waiting request from a different user/TCP connection?

>> But I would like to eliminate my thousands of TIME_WAIT sockets if at 
>> all possible, as this represents a scaleability ceiling right now. Of 
>> course I could just throw more webservers at the problem - if necessary.
> 
> Couldn't you also just configure multiple IP#'s on your backend ?

True, I could set up Apache to listen on 16 different ports each on 
localhost, then set up Varnish to load-balance to those 16 different 
backends, giving me much greater pool of unique connection entries to 
work with.

The only thing I don't like about this approach is that the kernel is 
using a lot of memory tracking localhost connections in TIME_WAIT mode 
that do not need tracking.

> If you run a tcpdump of the backend traffic, does the connections
> close properly with FIN or does one of the ends RST them ?

A single backend request from Varnish -> Apache yields the following 
tcpdump.  It looks correct in that there is:

  Varnish -> Apache (FIN)
  Apache -> Varnish (FIN / ACK)
  Varnish -> Apache (ACK)


11:16:38.304362 IP (tos 0x0, ttl 64, id 18602, offset 0, flags [DF], 
proto TCP (6), length 60) 127.0.0.1.52192 > 127.0.0.1.8080: S 
1321521977:1321521977(0) win 32792 <mss 16396,sackOK,timestamp 
177773459[|tcp]>
         0x0000:  0000 0000 0000 0000 0000 0000 0800 4500  ..............E.
         0x0010:  003c 48aa 4000 4006 f40f 7f00 0001 7f00  .<H. at .@.........
         0x0020:  0001 cbe0 1f90 4ec4 d339 0000 0000 a002  ......N..9......
         0x0030:  8018 dbf2 0000 0204 400c 0402 080a 0a98  ........ at .......
         0x0040:  9b93 0000                                ....
11:16:38.304380 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto 
TCP (6), length 60) 127.0.0.1.8080 > 127.0.0.1.52192: S 
1327228413:1327228413(0) ack 1321521978 win 32768 <mss 
16396,sackOK,timestamp 177773459[|tcp]>
         0x0000:  0000 0000 0000 0000 0000 0000 0800 4500  ..............E.
         0x0010:  003c 0000 4000 4006 3cba 7f00 0001 7f00  .<.. at .@.<.......
         0x0020:  0001 1f90 cbe0 4f1b e5fd 4ec4 d33a a012  ......O...N..:..
         0x0030:  8000 00b5 0000 0204 400c 0402 080a 0a98  ........ at .......
         0x0040:  9b93 0a98                                ....
11:16:38.304391 IP (tos 0x0, ttl 64, id 18603, offset 0, flags [DF], 
proto TCP (6), length 52) 127.0.0.1.52192 > 127.0.0.1.8080: ., cksum 
0xe8d8 (correct), ack 1327228414 win 257 <nop,nop,timestamp 177773459 
177773459>
         0x0000:  0000 0000 0000 0000 0000 0000 0800 4500  ..............E.
         0x0010:  0034 48ab 4000 4006 f416 7f00 0001 7f00  .4H. at .@.........
         0x0020:  0001 cbe0 1f90 4ec4 d33a 4f1b e5fe 8010  ......N..:O.....
         0x0030:  0101 e8d8 0000 0101 080a 0a98 9b93 0a98  ................
         0x0040:  9b93                                     ..
11:16:38.304552 IP (tos 0x0, ttl 64, id 18604, offset 0, flags [DF], 
proto TCP (6), length 1190) 127.0.0.1.52192 > 127.0.0.1.8080: P 
1321521978:1321523116(1138) ack 1327228414 win 257 <nop,nop,timestamp 
177773459 177773459>
         0x0000:  0000 0000 0000 0000 0000 0000 0800 4500  ..............E.
         0x0010:  04a6 48ac 4000 4006 efa3 7f00 0001 7f00  ..H. at .@.........
         0x0020:  0001 cbe0 1f90 4ec4 d33a 4f1b e5fe 8018  ......N..:O.....
         0x0030:  0101 029b 0000 0101 080a 0a98 9b93 0a98  ................
         0x0040:  9b93 4745                                ..GE
11:16:38.304567 IP (tos 0x0, ttl 64, id 32365, offset 0, flags [DF], 
proto TCP (6), length 52) 127.0.0.1.8080 > 127.0.0.1.52192: ., cksum 
0xe455 (correct), ack 1321523116 win 274 <nop,nop,timestamp 177773459 
177773459>
         0x0000:  0000 0000 0000 0000 0000 0000 0800 4500  ..............E.
         0x0010:  0034 7e6d 4000 4006 be54 7f00 0001 7f00  .4~m at .@..T......
         0x0020:  0001 1f90 cbe0 4f1b e5fe 4ec4 d7ac 8010  ......O...N.....
         0x0030:  0112 e455 0000 0101 080a 0a98 9b93 0a98  ...U............
         0x0040:  9b93                                     ..
11:16:38.410471 IP (tos 0x0, ttl 64, id 32366, offset 0, flags [DF], 
proto TCP (6), length 13079) 127.0.0.1.8080 > 127.0.0.1.52192: P 
1327228414:1327241441(13027) ack 1321523116 win 274 <nop,nop,timestamp 
177773565 177773459>
         0x0000:  0000 0000 0000 0000 0000 0000 0800 4500  ..............E.
         0x0010:  3317 7e6e 4000 4006 8b70 7f00 0001 7f00  3.~n at .@..p......
         0x0020:  0001 1f90 cbe0 4f1b e5fe 4ec4 d7ac 8018  ......O...N.....
         0x0030:  0112 310c 0000 0101 080a 0a98 9bfd 0a98  ..1.............
         0x0040:  9b93 4854                                ..HT
11:16:38.410504 IP (tos 0x0, ttl 64, id 18605, offset 0, flags [DF], 
proto TCP (6), length 52) 127.0.0.1.52192 > 127.0.0.1.8080: ., cksum 
0xb02f (correct), ack 1327241441 win 385 <nop,nop,timestamp 177773565 
177773565>
         0x0000:  0000 0000 0000 0000 0000 0000 0800 4500  ..............E.
         0x0010:  0034 48ad 4000 4006 f414 7f00 0001 7f00  .4H. at .@.........
         0x0020:  0001 cbe0 1f90 4ec4 d7ac 4f1c 18e1 8010  ......N...O.....
         0x0030:  0181 b02f 0000 0101 080a 0a98 9bfd 0a98  .../............
         0x0040:  9bfd                                     ..
11:16:38.410509 IP (tos 0x0, ttl 64, id 32367, offset 0, flags [DF], 
proto TCP (6), length 52) 127.0.0.1.8080 > 127.0.0.1.52192: F, cksum 
0xb107 (correct), 1327241441:1327241441(0) ack 1321523116 win 274 
<nop,nop,timestamp 177773565 177773459>
         0x0000:  0000 0000 0000 0000 0000 0000 0800 4500  ..............E.
         0x0010:  0034 7e6f 4000 4006 be52 7f00 0001 7f00  .4~o at .@..R......
         0x0020:  0001 1f90 cbe0 4f1c 18e1 4ec4 d7ac 8011  ......O...N.....
         0x0030:  0112 b107 0000 0101 080a 0a98 9bfd 0a98  ................
         0x0040:  9b93                                     ..
11:16:38.410576 IP (tos 0x0, ttl 64, id 18606, offset 0, flags [DF], 
proto TCP (6), length 52) 127.0.0.1.52192 > 127.0.0.1.8080: F, cksum 
0xb02d (correct), 1321523116:1321523116(0) ack 1327241442 win 385 
<nop,nop,timestamp 177773565 177773565>
         0x0000:  0000 0000 0000 0000 0000 0000 0800 4500  ..............E.
         0x0010:  0034 48ae 4000 4006 f413 7f00 0001 7f00  .4H. at .@.........
         0x0020:  0001 cbe0 1f90 4ec4 d7ac 4f1c 18e2 8011  ......N...O.....
         0x0030:  0181 b02d 0000 0101 080a 0a98 9bfd 0a98  ...-............
         0x0040:  9bfd                                     ..
11:16:38.410587 IP (tos 0x0, ttl 64, id 32368, offset 0, flags [DF], 
proto TCP (6), length 52) 127.0.0.1.8080 > 127.0.0.1.52192: ., cksum 
0xb09c (correct), ack 1321523117 win 274 <nop,nop,timestamp 177773565 
177773565>
         0x0000:  0000 0000 0000 0000 0000 0000 0800 4500  ..............E.
         0x0010:  0034 7e70 4000 4006 be51 7f00 0001 7f00  .4~p at .@..Q......
         0x0020:  0001 1f90 cbe0 4f1c 18e2 4ec4 d7ad 8010  ......O...N.....
         0x0030:  0112 b09c 0000 0101 080a 0a98 9bfd 0a98  ................
         0x0040:  9bfd

Regards,

Nick.



More information about the varnish-misc mailing list