pre-existing data on a connection

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

pre-existing data on a connection

Frank Liu
Hi,

When using nginx as a reverse proxy, how does it handle the
pre-existing data on a keepalive connection to the backend?

eg: for a request, the backend has a bug that sends 2 identical
responses. I assume nginx will take the first response and send it to
client. What will happen to the extra data (duplicate response)? Now
when nginx gets a second request and re-uses the same keepalive
connection to backend, will nginx take the pre-existing data (the
duplicate response for the first request) on that connection and send
it to second client or will it drop those and read the new response
from backend to send to client?
If nginx uses the pre-existing data, all the subsequent requests will
get the response shifted.

Thanks!
Frank
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: pre-existing data on a connection

Maxim Dounin
Hello!

On Mon, Jan 06, 2020 at 04:32:24PM -0800, Frank Liu wrote:

> When using nginx as a reverse proxy, how does it handle the
> pre-existing data on a keepalive connection to the backend?
>
> eg: for a request, the backend has a bug that sends 2 identical
> responses. I assume nginx will take the first response and send it to
> client. What will happen to the extra data (duplicate response)? Now
> when nginx gets a second request and re-uses the same keepalive
> connection to backend, will nginx take the pre-existing data (the
> duplicate response for the first request) on that connection and send
> it to second client or will it drop those and read the new response
> from backend to send to client?
> If nginx uses the pre-existing data, all the subsequent requests will
> get the response shifted.

The behaviour heavily depends on the timing.  As long as nginx
will be able to detect there are additional data after the
response is already sent, nginx will close the connection (and
will use another one for the next request to the same upstream
server).  It might not be able to detect there are additional
data though, and will only read the duplicate response after it
will sent the next request to the connection, so the duplicate
response will be sent to the second client.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx