I have a service in my java application that I get the id of an image,
height and width. I do image resizing according to the provided
dimensions
and return the bytes. As I am using a nginx in front of application
server(tomcat), requests are taking too long to process because nginx is
on
a different server than tomcat. Nginx is receiving the bytes and then
delivering. I wonder if anyone has gone through this problem and found a
better solution.
Infrastructure (Amazon)
1 EC2 Micro (Nginx)
1 Elastic Load Balance
2 EC2 Medium (Java Application)
Nginx send requests to ELB.
I believe the problem is the transfer of bytes between the load balance
and
the nginx instance
Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,249904,249904#msg-249904
On 7 May 2014 19:05, rodrigo.aiello [email protected] wrote:
requests are taking too long to process
[snip]
1 EC2 Micro (Nginx)
I found your problem. Micro instances are a false economy. Stop using
them.
On 8 May 2014 06:05, rodrigo.aiello [email protected] wrote:
Nginx is receiving the bytes and then
delivering. I wonder if anyone has gone through this problem and found a
better solution.
Indeed, Nginx reads the whole response from the backend before a single
byte is sent to the client. That can add latency if your response is
very
large. This is controlled by the proxy_buffering setting, so try setting
it
to “no”:
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffering
Cheers,
Nicholas Sherlock
Hello!
On Thu, May 08, 2014 at 02:47:47PM +1200, Nicholas Sherlock wrote:
On 8 May 2014 06:05, rodrigo.aiello [email protected] wrote:
Nginx is receiving the bytes and then
delivering. I wonder if anyone has gone through this problem and found a
better solution.
As already suggested, the original problem is likely to be related
to micro instance. In particular, there were reports that network
is very slow on such instances.
Indeed, Nginx reads the whole response from the backend before a single
byte is sent to the client. That can add latency if your response is very
This is not true.
large. This is controlled by the proxy_buffering setting, so try setting it
to “no”:
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffering
Using buffering allows to read a resonse from a backend as fast as
possible, while sending the response to the client. This allows
to save expensive backend processes while serving large responses
to slow clients.
It doesn’t imply reading “the whole response from the backend
before a single byte is sent to the client” - as long as at least
one buffer is full, it will be sent to a client.
–
Maxim D.
http://nginx.org/