Mercurial > hg > ngx_http_upstream_keepalive
diff t/memcached-keepalive.t @ 45:489c5d4318ff draft
Keepalive: "single" parameter deprecated.
The original idea was to optimize edge cases in case of interchangeable
backends, i.e. don't establish a new connection if we have any one
cached. This causes more harm than good though, as it screws up
underlying balancer's idea about backends used and may result in
various unexpected problems.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 25 Jun 2012 22:55:53 +0400 |
parents | 2ee28064a04a |
children |
line wrap: on
line diff
--- a/t/memcached-keepalive.t +++ b/t/memcached-keepalive.t @@ -20,7 +20,7 @@ select STDOUT; $| = 1; eval { require Cache::Memcached; }; plan(skip_all => 'Cache::Memcached not installed') if $@; -my $t = Test::Nginx->new()->has('rewrite')->has_daemon('memcached')->plan(17) +my $t = Test::Nginx->new()->has('rewrite')->has_daemon('memcached')->plan(16) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% @@ -38,12 +38,6 @@ http { keepalive 1; } - upstream memd2 { - server 127.0.0.1:8081; - server 127.0.0.1:8082; - keepalive 1 single; - } - upstream memd3 { server 127.0.0.1:8081; server 127.0.0.1:8082; @@ -71,11 +65,6 @@ http { memcached_pass memd; } - location /memd2 { - set $memcached_key "/"; - memcached_pass memd2; - } - location /memd3 { set $memcached_key "/"; memcached_pass memd3; @@ -160,25 +149,12 @@ like(http_get('/'), qr/SEE-THIS/, 'get a is($memd1->stats()->{total}->{total_connections}, $total + 1, 'big head request closes connection'); -# two backends with 'single' option - should establish only one connection +# two backends with maximum number of cached connections set to 1, +# should establish new connection on each request $total = $memd1->stats()->{total}->{total_connections} + $memd2->stats()->{total}->{total_connections}; -http_get('/memd2'); -http_get('/memd2'); -http_get('/memd2'); - -is($memd1->stats()->{total}->{total_connections} + - $memd2->stats()->{total}->{total_connections}, $total + 1, - 'only one connection with two backends and single'); - -$total = $memd1->stats()->{total}->{total_connections} + - $memd2->stats()->{total}->{total_connections}; - -# two backends without 'single' option and maximum number of cached -# connections set to 1 - should establish new connection on each request - http_get('/memd3'); http_get('/memd3'); http_get('/memd3'); @@ -187,8 +163,8 @@ is($memd1->stats()->{total}->{total_conn $memd2->stats()->{total}->{total_connections}, $total + 3, '3 connections should be established'); -# two backends without 'single' option and maximum number of cached -# connections set to 10 - should establish only two connections (1 per backend) +# two backends with maximum number of cached connections set to 10, +# should establish only two connections (1 per backend) $total = $memd1->stats()->{total}->{total_connections} + $memd2->stats()->{total}->{total_connections};