> Hi,
>
> I am coming for tornado to uwsgi.  With tornado, I used supervisord to
> launch a process for each core and used engine nginx as a load
> balancer.
>
> The main reason why I switched is because I have to use redis-py.  The
> tornado and cyclone redis clients, although not blocking are very slow
> because the do not use hiredis parser. I blocking redis-py is faster
> then a non blocking tornado client.  Hence the motivation for uWSGI
> with the gevent loop.
>
> The number of options to used with uWSGI is rather overwhelming and I
> am rather confused on how to best launch given then fact that I am
> using the gevent loop.
>
> My stack is as follows:
> supervisors to launch uWSGI
> nginx as a load balancer
> uWSGI with gevent
> redis with the redis-py client
> bottle.py
>
> The application is a c10K problem.  I need to make to make a redis
> pipeline request by spawning gevent threads and have the request not
> block so I can process other requests.
>
> The machine will be physical hardware with 4 cores and will scale out.
>  I have the ubuntu sysctl.conf file optimized for low latency high
> throughput that is typical for nginx.
>
> In my local test machine, the below is how I am launching uwsgi
>
> /usr/local/bin/uwsgi --loop gevent --socket 127.0.0.1:8070 --wsgi-file
> /home/ubuntu/workspace//uwsgiServer.py --master --async 5
> --enable-threads --listen 100 --uid root -b 32768
>
> So, should I have superviord launch four process as follows?
>
> /usr/local/bin/uwsgi --loop gevent --socket 127.0.0.1:8070 --wsgi-file
> /home/ubuntu/workspace//uwsgiServer.py --master --async 5
> --enable-threads --listen 100 --uid root -b 32768
> /usr/local/bin/uwsgi --loop gevent --socket 127.0.0.1:8071 --wsgi-file
> /home/ubuntu/workspace//uwsgiServer.py --master --async 5
> --enable-threads --listen 100 --uid root -b 32768
> /usr/local/bin/uwsgi --loop gevent --socket 127.0.0.1:8072 --wsgi-file
> /home/ubuntu/workspace//uwsgiServer.py --master --async 5
> --enable-threads --listen 100 --uid root -b 32768
> /usr/local/bin/uwsgi --loop gevent --socket 127.0.0.1:8074 --wsgi-file
> /home/ubuntu/workspace//uwsgiServer.py --master --async 5
> --enable-threads --listen 100 --uid root -b 32768

Do not do this kind of setup, use a single socket and start multiple
processes:

--socket 127.0.0.1:8070 --processes 4

>
> Also, I  don't not know how to best set the --async and the --listen
> flags.  My naive tendency is to set high as possible.  --async 10000
> --listen 30000

having a big listen queue could lead to various network problems. I would
not set it over 2k. Set async core the a reasonable number based on your
available memory and cpu power. You should measure how much memory a
request takes (use --memory-report) and calculate it.

>
> The relevant portions of my nignx.conf file is as follows.
>
> worker_processes 4;
> worker_rlimit_nofile 32768;
> events {
>        worker_connections  30000;
>        multi_accept on;
>        use epoll;
> }
>            upstream uwsgi_b {
>         server 127.0.0.1:8070;
>           server 127.0.0.1:8071;
>           server 127.0.0.1:8072;
>           server 127.0.0.1:8073;
>       }

I suggest you to not do this kind of local load-balancing in nginx.
Directly connect to the socket shared by multiple processes.


-- 
Roberto De Ioris
http://unbit.it
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Reply via email to