AWS Beanstalk: Errors in var/log/nginx/error file


We have setup our application on Beanstalk. We are trying to fire 5000 concurrent POST request to Beanstalk env. At first we observed 1024 worker connections error and we updated this number in nginx conf for our use case. On further testing we saw that still all the messages are not reaching our application deployed on Beanstalk. On different runs, nginx/error file had different errors like below:

  • connect() failed (111: Connection refused) while connecting to upstream
  • recv() failed (104: Connection reset by peer) while reading response header from upstream, client
  • *4889 upstream timed out (110: Connection timed out) while reading response header from upstream

We tried out the below configurations with no luck location / { proxy_connect_timeout 3600; proxy_send_timeout 3600; proxy_read_timeout 3600; fastcgi_send_timeout 3600; fastcgi_read_timeout 3600; }

CPU and Memory usage is very much normal.

Need help to understand the missing steps/configuration if any?

asked a year ago595 views
1 Answer

you may need to adjust additional settings to further optimize your environment for handling a large number of connections. For example, you could try:

Increasing worker_processes to take advantage of multiple CPU cores. Increasing keepalive_timeout to allow for persistent connections. Setting proxy_http_version 1.1 and proxy_set_header Connection ""; to enable HTTP/1.1 support with proxying. Here's an example configuration:

worker_processes auto;
events {
    worker_connections 10240;
http {
    keepalive_timeout 65;
    server {
        listen 80;
        location / {
            proxy_http_version 1.1;
            proxy_set_header Connection "";
            proxy_pass http://your_upstream;
            proxy_connect_timeout 3600;
            proxy_send_timeout 3600;
            proxy_read_timeout 3600;
profile picture
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions