Proxy non persistent client connections to persistent upstream connections
Maxim Dounin
mdounin at mdounin.ru
Tue Aug 11 12:34:06 UTC 2015
Hello!
On Mon, Aug 10, 2015 at 08:18:41AM +0000, Richard Jennings wrote:
> I would like to be able to proxy non persistent client http connections to
> persistent upstream connections on a Linux system, both to reduce the
> number of connections and the upstream latency.
>
> I have experimented with keepalive and proxy_pass.
>
> To observe performance I used log_format upstreamlog '[$time_local] $status
> $connection $connection_requests $request_time'; and $ lsof -Pni
>
> What I think I have found is that some of the time persistent upstream
> connections are reused, but very often they are not. I believe the
> occasions where upstream connections are reused are possible because by
> chance the client connection has been reused.
>
> Is there a way to make this work?
In nginx, client connections and upstream connections are not
related to each other and can be kept alive separately. That is, what
you are trying to do is how it works by design.
It doesn't work because of an error in your config: you proxy to
> proxy_pass http://www.google.com;
and
> proxy_pass http://www.yahoo.com;
but your upstream blocks are called "google" and "yahoo"
respectively. You should use
proxy_pass http://google;
and
proxy_pass http://yahoo;
instead (or rename "upstream" blocks accordingly).
--
Maxim Dounin
http://nginx.org/
More information about the nginx
mailing list