waitress vs mod_wsgi

1,147 views
Skip to first unread message

Chris Withers

unread,
Mar 9, 2014, 7:46:56 AM3/9/14
to pylons-...@googlegroups.com
Hi All,

What are the things you should consider when deciding between waitress
and mod_wsgi when it comes to serving a pyramid app?

cheers,

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk

Jonathan Vanasco

unread,
Mar 9, 2014, 7:04:12 PM3/9/14
to pylons-...@googlegroups.com
Could you use nginx + uwsgi/gunicorn/etc ?

I'm generally anti-Apache because I don't like the memory/process management model and miscellaneous concurrency issues ( handling the number, and also dealing with slow connections/hangups ).  If you ran mod_wsgi, I would make really suggest you either have nginx or a "Vanilla" apache on Port 80 that proxies to your mod_wsgi, or use Varnish as a load balancer.  This has nothing to do with mod_wsgi, you just absolutely need to keep static traffic and direct clients off of dynamic apache servers.

I have waitress serving a site in production, and it's been fine.  It's fronted by nginx though, which just proxies dynamic requests back to the waitress port.  Nginx handles all the connections and static files.

personally, I've been happiest with nginx+uwsgi.  that's my preference.

John Anderson

unread,
Mar 9, 2014, 7:37:22 PM3/9/14
to pylons-...@googlegroups.com
I would go with waitress at this point unless you have to support non-WSGI applications. It is very efficient and stable and doesn't require you to run it behind a proxy server (varnish/nginx) if you don't want to.

The only way to get comparable performance from another Python webserver would be to use something like gunicorn or uwsgi with a corouting worker like gevent or eventlet but then you have to make sure you are 100% compatible with those workers which is a pain and can cause a lot of misery if you find 1 part of your stack isn't "greened".

The battle tested threaded worker model works so well and along with their asyncore buffering it allows all the benefits of using a proxy server and all the benefits of a wsgi server in one tiny little package!

- John


--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.

Laurence Rowe

unread,
Mar 9, 2014, 10:12:52 PM3/9/14
to pylons-...@googlegroups.com
On Sunday, 9 March 2014 04:46:56 UTC-7, Chris Withers wrote:
What are the things you should consider when deciding between waitress
and mod_wsgi when it comes to serving a pyramid app?

If you need to run more than one process, or configure SSL, etc. then mod_wsgi is the all-in-one solution. This is the config I use (with apache 2.4 event mpm.):

# The socket directory must be readable by the daemon process user
WSGISocketPrefix /var/run/wsgi
WSGIDaemonProcess myapp user=myapp group=myapp processes=8 threads=1
# No need for embedded interpreters
WSGIRestrictEmbedded On
# Pass the authorization header so basic auth works
WSGIPassAuthorization On

# Specifying process-group and application-group here ensures processes are started on httpd start
WSGIScriptAlias / /srv/myapp/parts/production/wsgi process-group=myapp application-group=%{GLOBAL}

<Directory /srv/myapp/production>
    Order deny,allow
    Allow from all
    Require all granted
</Directory>

<Directory /srv/myapp/static>
    Order deny,allow
    Allow from all
    Require all granted
</Directory>

# Serve static resources directly from Apache
Alias /static /srv/myapp/static
Alias /favicon.ico /srv/myapp/static/favicon.ico
Alias /robots.txt /srv/myapp/static/robots.txt

# Compress JSON responses.
AddOutputFilterByType DEFLATE application/javascript application/json text/css text/html text/javascript


Laurence

Marius Gedminas

unread,
Mar 12, 2014, 3:08:29 AM3/12/14
to pylons-...@googlegroups.com
On Sun, Mar 09, 2014 at 11:46:56AM +0000, Chris Withers wrote:
> What are the things you should consider when deciding between
> waitress and mod_wsgi when it comes to serving a pyramid app?

If you choose mod_wsgi, make sure you configure it appropriately (e.g.
*always* use daemon mode).

I like mod_wsgi because if I use it I don't need to write additional
init scripts for my web servers. (Supervisor config files count as init
scripts in my book).

Marius Gedminas
--
Despite all appearances, your boss is a thinking, feeling, human being.
signature.asc

Wyatt Baldwin

unread,
Mar 12, 2014, 8:04:35 PM3/12/14
to pylons-...@googlegroups.com
On Sunday, March 9, 2014 4:46:56 AM UTC-7, Chris Withers wrote:
Hi All,

What are the things you should consider when deciding between waitress
and mod_wsgi when it comes to serving a pyramid app?

It probably depends on your usage scenario.

Waitress by itself would probably be the easiest thing to set up, but that's usually not recommended... but if you're only serving a few users, it probably doesn't matter. Waitress behind a proxy is the next easiest and is probably good enough if you don't need *super* high performance.

For "serious" production apps, I like nginx+uwsgi (similar to apache+mod_wsgi in daemon mode). It's only slightly more work to configure than a reverse proxy setup. If you're managing multiple apps, uwsgi's emperor mode can be handy.

I found mod_wsgi a bit more cumbersome than uwsgi, but not by much. On the other hand, uwsgi has a billion options to wade through, but I don't think most of them are relevant most of the time.
Reply all
Reply to author
Forward
0 new messages