# Way to queue connections until a uwsgi socket available?

**URL:** <https://www.ruby-forum.com/t/way-to-queue-connections-until-a-uwsgi-socket-available/200311>\
**Category:** NGINX\
**Created:** [December 8, 2010, 11:14pm UTC](https://www.ruby-forum.com/t/way-to-queue-connections-until-a-uwsgi-socket-available/200311 "2010-12-08T23:14:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [December 8, 2010, 11:14pm UTC](https://www.ruby-forum.com/t/way-to-queue-connections-until-a-uwsgi-socket-available/200311/1 "2010-12-08T23:14:17Z")

</div>

We are currently configuring nginx and uwsgi on ubuntu 9.10. We are  
having a problem while load testing in that when uwsgi becomes  
saturated, nginx kills incoming connections rather than queueing. I  
cannot figure out if there is a way to do this queueing in nginx. The  
errors we get in the nginx error log look like:

2010/12/08 12:57:03 [error] 15276#0: \*10079 connect() to  
unix:///var/run/nginx-uwsgi/wsgi-app.sock failed (11: Resource  
temporarily unavailable) while connecting to upstream, client:  
xx.xxx.xx.xx, server: [www.app.com](http://www.app.com), request: “GET /url/here/ HTTP/1.1”,  
upstream: “uwsgi://unix:///var/run/nginx-uwsgi/wsgi-app.sock:”, host:  
“[ec2-xxx-xxx-xxx-xx.compute-1.amazonaws.com](http://ec2-xxx-xxx-xxx-xx.compute-1.amazonaws.com)”

I have tried kqueue and poll to no avail.

Here is our nginx.conf

* * *

user www-data;  
worker\_processes 2;

error\_log /var/log/nginx/error.log;  
pid /var/run/nginx.pid;

events {  
worker\_connections 1024;  
}

http {  
include /etc/nginx/mime.types;

```
access_log /var/log/nginx/access.log;

sendfile on;

keepalive_timeout 65;
tcp_nodelay on;

gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
client_max_body_size 50m;

```

server {  
listen 80;  
server\_name app;

```
  access_log /var/log/nginx/access_80.log;

  location / {
              uwsgi_connect_timeout 10;
              uwsgi_pass

```

unix:///var/run/nginx-uwsgi/wsgi-app.sock;  
include uwsgi\_params;  
}  
}  
include /etc/nginx/conf.d/_.conf;  
include /etc/nginx/sites-enabled/_;  
}

here is our uwsgi.xml file

/var/run/nginx-uwsgi/wsgi-app.sock  
/path/to/python/app  
wsgi  
33  
33  
12

60  
256  
10  
10

Any help here would be GREATLY appreciated!

Posted at Nginx Forum:

> **[Way to queue connections until a uwsgi socket available?](https://forum.nginx.org/read.php?2,156979,156979#msg-156979)**
>
> We are currently configuring nginx and uwsgi on ubuntu 9.10. We are having a problem while load testing in that when uwsgi becomes saturated, nginx kills incoming connections rather than queueing. I cannot figure out if there is a way to do this...

---

<div class="post-metadata">

**Author:** ![kickme444](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/8baadc/32.png) [@kickme444](https://www.ruby-forum.com/u/kickme444)\
**Post date:** [December 9, 2010, 12:08am UTC](https://www.ruby-forum.com/t/way-to-queue-connections-until-a-uwsgi-socket-available/200311/2 "2010-12-09T00:08:53Z")

</div>

We had similar problems;  
[The uWSGI project — uWSGI 2.0 documentation](http://projects.unbit.it/uwsgi/wiki/Doc#Backloglistenqueue) helped us  
lick them, along with the following entry about socket timeout.

Posted at Nginx Forum:

> **[Re: Way to queue connections until a uwsgi socket available?](https://forum.nginx.org/read.php?2,156979,156997#msg-156997)**
>
> We are currently configuring nginx and uwsgi on ubuntu 9.10. We are having a problem while load testing in that when uwsgi becomes saturated, nginx kills incoming connections rather than queueing. I cannot figure out if there is a way to do this...

---

<div class="post-metadata">

**Author:** ![kickme444](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/8baadc/32.png) [@kickme444](https://www.ruby-forum.com/u/kickme444)\
**Post date:** [December 8, 2010, 11:48pm UTC](https://www.ruby-forum.com/t/way-to-queue-connections-until-a-uwsgi-socket-available/200311/3 "2010-12-08T23:48:47Z")

</div>

Hello!

On Wed, Dec 08, 2010 at 05:13:09PM -0500, kickme444 wrote:

> upstream: “uwsgi://unix:///var/run/nginx-uwsgi/wsgi-app.sock:”, host:  
> “[ec2-xxx-xxx-xxx-xx.compute-1.amazonaws.com](http://ec2-xxx-xxx-xxx-xx.compute-1.amazonaws.com)”

Enlarge listen queue on backend (i.e. uwsgi app). According to  
[1] it should be possible via something like

4096

in uwsgi.xml. Note that your OS may require tuning to make 4096  
possible, something like “echo 4096 \> /proc/sys/net/core/somaxconn”.  
Refer to your OS manuals for details.

[1] [The uWSGI project — uWSGI 2.0 documentation](http://projects.unbit.it/uwsgi/wiki/Doc)

> I have tried kqueue and poll to no avail.

There is no kqueue on ubuntu, the best event method it has is  
epoll. This is unrelated though.

Maxim D.
