librelist archives

« back to archive

Preferred web server

Preferred web server

From:
Dan Ross
Date:
2010-12-01 @ 14:49
 Is there a web server that is suggested with Flask?

 I know it works on many, but is there one that others have found 
 particular success with?

 Thanks,

 Dan

Re: [flask] Preferred web server

From:
Jonas Galvez
Date:
2010-12-01 @ 16:07
Dan Ross wrote:
> Is there a web server that is suggested with Flask?

I'm using nginx as a load balancer and static file server (1 node),
with several uwsgi daemons in the backend (2 nodes). The site's still
in a private alpha phase, so it's too soon to say how it holds up, but
so far I have had zero downtime. Everything's snappy and very
responsive. And it just worked with my Flask app the first time I
tried. Deployment is trivial.

I'd be interested in learning how uwsgi compares to gunicorn in the long run.

-- Jonas

Re: [flask] Preferred web server

From:
danjac354@gmail.com
Date:
2010-12-01 @ 16:16
>
> I'd be interested in learning how uwsgi compares to gunicorn in the long run.

uwsgi looks good - the only caveat I have with it right now is that it
needed to be compiled with nginx, which is not possible/desirable in
all circumstances. Once nginx ships with precompiled uwsgi I expect it
will become more widely adopted.

Here's a good summary (as always, take benchmarks with a grain of salt):

http://www.peterbe.com/plog/fcgi-vs-gunicorn-vs-uwsgi

Re: [flask] Preferred web server

From:
Jonas Galvez
Date:
2010-12-01 @ 16:27
danjac354@gmail.com wrote:
> uwsgi looks good - the only caveat I have with it right now is that it
> needed to be compiled with nginx, which is not possible/desirable in
> all circumstances. Once nginx ships with precompiled uwsgi I expect it
> will become more widely adopted.

I think uwsgi is already included in the latest nginx distribution. I
didn't have to set any special flags to enable it when compiling.

> http://www.peterbe.com/plog/fcgi-vs-gunicorn-vs-uwsgi

Good overview, thanks!

-- Jonas

Re: [flask] Preferred web server

From:
Thadeus Burgess
Date:
2010-12-01 @ 17:07
My favourite feature with Apache + mod_wsgi....

$: touch run_application.wsgi

Also, whenever you restart apache, it makes sure to restart your WSGI
processes too. This is invaluable. I run Cherokee + uWSGI on my personal
server, but if I ever want to update anything I have to go manually kill all
of my uWSGI processes before it notices I updated the files. This is fine
since its my personal server, for work I prefer Apache to make sure things
happen like they are supposed to.

--
Thadeus




On Wed, Dec 1, 2010 at 10:27 AM, Jonas Galvez <jonasgalvez@gmail.com> wrote:

> danjac354@gmail.com wrote:
> > uwsgi looks good - the only caveat I have with it right now is that it
> > needed to be compiled with nginx, which is not possible/desirable in
> > all circumstances. Once nginx ships with precompiled uwsgi I expect it
> > will become more widely adopted.
>
> I think uwsgi is already included in the latest nginx distribution. I
> didn't have to set any special flags to enable it when compiling.
>
> > http://www.peterbe.com/plog/fcgi-vs-gunicorn-vs-uwsgi
>
> Good overview, thanks!
>
> -- Jonas
>

Re: [flask] Preferred web server

From:
Dan Ross
Date:
2010-12-01 @ 16:21
 So can something such as Gunicorn be used to serve both dynamic and 
 static requests? Or is that just a horrible idea?

 On Wed, 1 Dec 2010 16:16:26 +0000, "danjac354@gmail.com" 
 <danjac354@gmail.com> wrote:
>>
>> I'd be interested in learning how uwsgi compares to gunicorn in the 
>> long run.
>
> uwsgi looks good - the only caveat I have with it right now is that 
> it
> needed to be compiled with nginx, which is not possible/desirable in
> all circumstances. Once nginx ships with precompiled uwsgi I expect 
> it
> will become more widely adopted.
>
> Here's a good summary (as always, take benchmarks with a grain of 
> salt):
>
> http://www.peterbe.com/plog/fcgi-vs-gunicorn-vs-uwsgi

Re: [flask] Preferred web server

From:
Jonas Galvez
Date:
2010-12-01 @ 16:25
Dan Ross wrote:
>  So can something such as Gunicorn be used to serve both dynamic and
>  static requests? Or is that just a horrible idea?

That's not a good idea since Gunicorn is pure Python and not optimized
for this task. Let nginx do that.

-- Jonas

Re: [flask] Preferred web server

From:
Alex Ezell
Date:
2010-12-01 @ 14:57
The mod_wsgi module for nginx is particularly easy to use. Combine that with
the nginx-gridfs module to talk directly to mongodb/gridfs and I've been
very happy with it.

Alex

On Wed, Dec 1, 2010 at 8:49 AM, Dan Ross <dan@rosspixelworks.com> wrote:

>  Is there a web server that is suggested with Flask?
>
>  I know it works on many, but is there one that others have found
>  particular success with?
>
>  Thanks,
>
>  Dan
>

Re: [flask] Preferred web server

From:
danjac354@gmail.com
Date:
2010-12-01 @ 15:08
Apache/mod_wsgi is a solid workhorse. I've used it in production
environments (albeit with Django) and it's worked fine, once you've
tuned it correctly.

That said, if you're not using Apache for anything else - for example,
if you're using nginx for serving static content - then a more
lightweight solution might be more appealing. I've been experimenting
with gunicorn and it works very nicely - again using nginx for media
and proxying dynamic requests out to gunicorn. I'd recommend
supervisord or some other process manager to keep the lights on, but
once you've got it all set up with fabric it's a very straightforward
deployment.

I'm using gunicorn + nginx to serve a Flask application, newsmeme
(http://thenewsmeme.com) right now. The traffic is light so no idea
how it holds up (it's on a shared webfaction account anyway, so I
doubt it's going to take much). However as a deployment strategy it's
very easy.

On 1 December 2010 14:57, Alex Ezell <aezell@gmail.com> wrote:
> The mod_wsgi module for nginx is particularly easy to use. Combine that with
> the nginx-gridfs module to talk directly to mongodb/gridfs and I've been
> very happy with it.
> Alex
>
> On Wed, Dec 1, 2010 at 8:49 AM, Dan Ross <dan@rosspixelworks.com> wrote:
>>
>>  Is there a web server that is suggested with Flask?
>>
>>  I know it works on many, but is there one that others have found
>>  particular success with?
>>
>>  Thanks,
>>
>>  Dan
>
>

Re: [flask] Preferred web server

From:
Dan Ross
Date:
2010-12-01 @ 15:17
 I see a lot of (web server a) + (web server b) like nginx + gunicorn.

 I understand the theory behind it I think, but is there any 
 documentation or reading you'd suggest to get more familiar?

 I'm new to web server stuff.

 On Wed, 1 Dec 2010 15:08:15 +0000, "danjac354@gmail.com" 
 <danjac354@gmail.com> wrote:
> Apache/mod_wsgi is a solid workhorse. I've used it in production
> environments (albeit with Django) and it's worked fine, once you've
> tuned it correctly.
>
> That said, if you're not using Apache for anything else - for 
> example,
> if you're using nginx for serving static content - then a more
> lightweight solution might be more appealing. I've been experimenting
> with gunicorn and it works very nicely - again using nginx for media
> and proxying dynamic requests out to gunicorn. I'd recommend
> supervisord or some other process manager to keep the lights on, but
> once you've got it all set up with fabric it's a very straightforward
> deployment.
>
> I'm using gunicorn + nginx to serve a Flask application, newsmeme
> (http://thenewsmeme.com) right now. The traffic is light so no idea
> how it holds up (it's on a shared webfaction account anyway, so I
> doubt it's going to take much). However as a deployment strategy it's
> very easy.
>
> On 1 December 2010 14:57, Alex Ezell <aezell@gmail.com> wrote:
>> The mod_wsgi module for nginx is particularly easy to use. Combine 
>> that with
>> the nginx-gridfs module to talk directly to mongodb/gridfs and I've 
>> been
>> very happy with it.
>> Alex
>>
>> On Wed, Dec 1, 2010 at 8:49 AM, Dan Ross <dan@rosspixelworks.com> 
>> wrote:
>>>
>>>  Is there a web server that is suggested with Flask?
>>>
>>>  I know it works on many, but is there one that others have found
>>>  particular success with?
>>>
>>>  Thanks,
>>>
>>>  Dan
>>
>>

Re: [flask] Preferred web server

From:
Alex Ezell
Date:
2010-12-01 @ 15:50
The basic premise as I understand it is that as fast as nginx and apache are
at delivering static content, there are now faster ways to handle dynamic
request/response cycles, especially in the world of wsgi. Those ways are
things like gunicorn, uwsgi, or even cherrypy (though I might quibble about
cherrypy's speed). These newer dynamic wsgi servers typically are designed
to scale well and use wsgi natively.

As I mentioned above, nginx has a mod_wsgi module, as does apache, and I
think they work perfectly fine. These newer tools might be slight
improvements as far as speed, but the real benefit is what Dan Jacobs
mentioned: ease of deployment. After all, gunicorn is just python.

With regards to gunicorn, you're also getting into the realm of concurrency
and long-running request/response processes using greenlet and Eventlet or
Gevent. That worker model is something that Apache and nginx are not really
designed to deal with.

One of the beauties of the nginx + something model is if you start doing any
kind of caching with memcache, nginx can respond with data directly out of
memcache, meaning any request that asks for something you've cached never
touches your application at all. It's a nice bit of speedup if you're in
that situation.

I'm no expert, so please don't take the above as gospel. It's just how this
stuff is in my head currently.



On Wed, Dec 1, 2010 at 9:17 AM, Dan Ross <dan@rosspixelworks.com> wrote:

>  I see a lot of (web server a) + (web server b) like nginx + gunicorn.
>
>  I understand the theory behind it I think, but is there any
>  documentation or reading you'd suggest to get more familiar?
>
>  I'm new to web server stuff.
>
>  On Wed, 1 Dec 2010 15:08:15 +0000, "danjac354@gmail.com"
>  <danjac354@gmail.com> wrote:
> > Apache/mod_wsgi is a solid workhorse. I've used it in production
> > environments (albeit with Django) and it's worked fine, once you've
> > tuned it correctly.
> >
> > That said, if you're not using Apache for anything else - for
> > example,
> > if you're using nginx for serving static content - then a more
> > lightweight solution might be more appealing. I've been experimenting
> > with gunicorn and it works very nicely - again using nginx for media
> > and proxying dynamic requests out to gunicorn. I'd recommend
> > supervisord or some other process manager to keep the lights on, but
> > once you've got it all set up with fabric it's a very straightforward
> > deployment.
> >
> > I'm using gunicorn + nginx to serve a Flask application, newsmeme
> > (http://thenewsmeme.com) right now. The traffic is light so no idea
> > how it holds up (it's on a shared webfaction account anyway, so I
> > doubt it's going to take much). However as a deployment strategy it's
> > very easy.
> >
> > On 1 December 2010 14:57, Alex Ezell <aezell@gmail.com> wrote:
> >> The mod_wsgi module for nginx is particularly easy to use. Combine
> >> that with
> >> the nginx-gridfs module to talk directly to mongodb/gridfs and I've
> >> been
> >> very happy with it.
> >> Alex
> >>
> >> On Wed, Dec 1, 2010 at 8:49 AM, Dan Ross <dan@rosspixelworks.com>
> >> wrote:
> >>>
> >>>  Is there a web server that is suggested with Flask?
> >>>
> >>>  I know it works on many, but is there one that others have found
> >>>  particular success with?
> >>>
> >>>  Thanks,
> >>>
> >>>  Dan
> >>
> >>
>
>

Re: [flask] Preferred web server

From:
danjac354@gmail.com
Date:
2010-12-01 @ 15:56
That's a good summary.

Another point is on performance. There are a number of benchmarks
comparing various WSGI servers. Most often however these measure a
very basic "hello world" app, and not a real-world application. In the
real world the difference between these options is minimal and the
bottleneck most of the time will be the database, the framework and
libraries, and your own application code. So whatever deployment
method you choose, it's best to follow good practice in database
design, efficient coding etc. Furthermore, it's relatively little work
to switch between different solutions thanks to the WSGI standard.

On 1 December 2010 15:50, Alex Ezell <aezell@gmail.com> wrote:
> The basic premise as I understand it is that as fast as nginx and apache are
> at delivering static content, there are now faster ways to handle dynamic
> request/response cycles, especially in the world of wsgi. Those ways are
> things like gunicorn, uwsgi, or even cherrypy (though I might quibble about
> cherrypy's speed). These newer dynamic wsgi servers typically are designed
> to scale well and use wsgi natively.
> As I mentioned above, nginx has a mod_wsgi module, as does apache, and I
> think they work perfectly fine. These newer tools might be slight
> improvements as far as speed, but the real benefit is what Dan Jacobs
> mentioned: ease of deployment. After all, gunicorn is just python.
> With regards to gunicorn, you're also getting into the realm of concurrency
> and long-running request/response processes using greenlet and Eventlet or
> Gevent. That worker model is something that Apache and nginx are not really
> designed to deal with.
> One of the beauties of the nginx + something model is if you start doing any
> kind of caching with memcache, nginx can respond with data directly out of
> memcache, meaning any request that asks for something you've cached never
> touches your application at all. It's a nice bit of speedup if you're in
> that situation.
> I'm no expert, so please don't take the above as gospel. It's just how this
> stuff is in my head currently.
>
>
>
> On Wed, Dec 1, 2010 at 9:17 AM, Dan Ross <dan@rosspixelworks.com> wrote:
>>
>>  I see a lot of (web server a) + (web server b) like nginx + gunicorn.
>>
>>  I understand the theory behind it I think, but is there any
>>  documentation or reading you'd suggest to get more familiar?
>>
>>  I'm new to web server stuff.
>>
>>  On Wed, 1 Dec 2010 15:08:15 +0000, "danjac354@gmail.com"
>>  <danjac354@gmail.com> wrote:
>> > Apache/mod_wsgi is a solid workhorse. I've used it in production
>> > environments (albeit with Django) and it's worked fine, once you've
>> > tuned it correctly.
>> >
>> > That said, if you're not using Apache for anything else - for
>> > example,
>> > if you're using nginx for serving static content - then a more
>> > lightweight solution might be more appealing. I've been experimenting
>> > with gunicorn and it works very nicely - again using nginx for media
>> > and proxying dynamic requests out to gunicorn. I'd recommend
>> > supervisord or some other process manager to keep the lights on, but
>> > once you've got it all set up with fabric it's a very straightforward
>> > deployment.
>> >
>> > I'm using gunicorn + nginx to serve a Flask application, newsmeme
>> > (http://thenewsmeme.com) right now. The traffic is light so no idea
>> > how it holds up (it's on a shared webfaction account anyway, so I
>> > doubt it's going to take much). However as a deployment strategy it's
>> > very easy.
>> >
>> > On 1 December 2010 14:57, Alex Ezell <aezell@gmail.com> wrote:
>> >> The mod_wsgi module for nginx is particularly easy to use. Combine
>> >> that with
>> >> the nginx-gridfs module to talk directly to mongodb/gridfs and I've
>> >> been
>> >> very happy with it.
>> >> Alex
>> >>
>> >> On Wed, Dec 1, 2010 at 8:49 AM, Dan Ross <dan@rosspixelworks.com>
>> >> wrote:
>> >>>
>> >>>  Is there a web server that is suggested with Flask?
>> >>>
>> >>>  I know it works on many, but is there one that others have found
>> >>>  particular success with?
>> >>>
>> >>>  Thanks,
>> >>>
>> >>>  Dan
>> >>
>> >>
>>
>
>

Re: [flask] Preferred web server

From:
Italo Maia
Date:
2010-12-01 @ 15:07
I suggest cherokee. It has a web interface and uwsgi wizard!

2010/12/1 Alex Ezell <aezell@gmail.com>

> The mod_wsgi module for nginx is particularly easy to use. Combine that
> with the nginx-gridfs module to talk directly to mongodb/gridfs and I've
> been very happy with it.
>
> Alex
>
> On Wed, Dec 1, 2010 at 8:49 AM, Dan Ross <dan@rosspixelworks.com> wrote:
>
>>  Is there a web server that is suggested with Flask?
>>
>>  I know it works on many, but is there one that others have found
>>  particular success with?
>>
>>  Thanks,
>>
>>  Dan
>>
>
>


-- 
"A arrogância é a arma dos fracos."

===========================
Italo Moreira Campelo Maia
Graduado em Ciência da Computação - UECE
Desenvolvedor WEB e Desktop (Java, Python, Lua)
Coordenador do Pug-CE
-----------------------------------------------------
http://www.italomaia.com/
http://twitter.com/italomaia/
http://eusouolobomau.blogspot.com/
-----------------------------------------------------
turtle linux 910 - http://tiny.cc/blogturtle910
===========================

Re: [flask] Preferred web server

From:
Col Wilson
Date:
2010-12-01 @ 14:57
I'd also be interested in your opinions. Apache and mod_wsgi works fine, bu
then I'm not comparing it with anything.

On Wed, Dec 1, 2010 at 2:49 PM, Dan Ross <dan@rosspixelworks.com> wrote:

>  Is there a web server that is suggested with Flask?
>
>  I know it works on many, but is there one that others have found
>  particular success with?
>
>  Thanks,
>
>  Dan
>