Use the http_perl_module to development a simple url hash module

perl_set $backend ’
sub {
use Digest::MD5 (md5_hex);
my $r = shift;
my $uri = $r->uri;
@arr = qw(192.168.1.2 192.168.1.3 192.168.1.4
192.168.1.5);
$arr_num = $#arr + 1;
$url = substr(md5_hex($uri), -8);
$backend = $arr[hex($url) % $arr_num];
return $backend;
}
';

location / {
proxy_pass http://$backend$request_uri;
}

Hmm,what’s your question?

2007/12/25, 焦胜强 [email protected]:

On Tue, Dec 25, 2007 at 02:14:44PM +0800, ??? wrote:

                    return $backend;
            }
    ';

location / {
proxy_pass http://$backend$request_uri;
}

The better:

   upstream  b1 {
        server   192.168.1.1;
        server   192.168.1.2  backup;
        server   192.168.1.3  backup;
        server   192.168.1.4  backup;
   }

   upstream  b2 {
        server   192.168.1.1  backup;
        server   192.168.1.2;
        server   192.168.1.3  backup;
        server   192.168.1.4  backup;
   }

   perl_set $backend {
        ...
        @arr = qw(b1 b2 b3 b4);

Hi All,

who know the exact mean of  "connection_pool_size" and

“request_pool_size”,I try to find it in nginx document but it it not
listed in module reference ,and I can not search it in nginx wiki too.
Finally I search it from nginx’s source code, only two xx.c used
these parameter , but I can not find out the exact mean of these two
parameters, so I need to know how these two parameters are defined and
the most thing is they are used for what?


best regards,
arlenecc

WARNINGS : this email may be confidential and/or privileged. Only the
intended recipient may access or use it. If you are not the intented
recipient, please delete this email and notify us promptly. We use virus
scanning software but disclaim any liability for viruses or any other
contents of this message or any attachment.

On Wed, Dec 26, 2007 at 11:36:47PM +0800, arlene chen wrote:

who know the exact mean of “connection_pool_size” and
“request_pool_size”,I try to find it in nginx document but it it not
listed in module reference ,and I can not search it in nginx wiki too.
Finally I search it from nginx’s source code, only two xx.c used
these parameter , but I can not find out the exact mean of these two
parameters, so I need to know how these two parameters are defined and
the most thing is they are used for what?

The pools are used to allocate memory per connection and request.
The pools are used for small allocations. If a block is bigger than
pool size or bigger than page size, then it is allocted outside the
pool.
If there is not enough memory for small allocation inside pool, then
a new block of the same pool size is allocated.

On Thu, Dec 27, 2007 at 11:14:26AM +0800, arlene chen wrote:

the most thing is they are used for what?
the default setting of connection_pool_size is 256 byte ,and the default
setting of request_pool_size is 4k, can I think that the
connection_pool_size is just used to maintain the socket connection and
and the request_pool_size is just used to cache the http request header,
the output_buffer is used to http response, so the connection_pool_size
and request_pool_size have not effect on the performance of nginx or the
effect is very small?

Yes, the effect is very small.

The output_buffers are used to read response from file if it is needed
to
be processed by SSI, charset converting, or gzipping. Otherwise, if
sendfile is used, the output_buffers are not used.

Igor S. 写道:

The pools are used to allocate memory per connection and request.
The pools are used for small allocations. If a block is bigger than
pool size or bigger than page size, then it is allocted outside the pool.
If there is not enough memory for small allocation inside pool, then
a new block of the same pool size is allocated.

the default setting of connection_pool_size is 256 byte ,and the default
setting of request_pool_size is 4k, can I think that the
connection_pool_size is just used to maintain the socket connection and
and the request_pool_size is just used to cache the http request header,
the output_buffer is used to http response, so the connection_pool_size
and request_pool_size have not effect on the performance of nginx or the
effect is very small?


best regards,
arlenecc

WARNINGS : this email may be confidential and/or privileged. Only the
intended recipient may access or use it. If you are not the intented
recipient, please delete this email and notify us promptly. We use virus
scanning software but disclaim any liability for viruses or any other
contents of this message or any attachment.