0

Information and prerequisites:

I have a project which is, at its core, a basic CRUD application. It doesn't have long running background processes which it forks at the beginning and talks to later on, nor does it have long running queries or kept alive connection requirements. It receives a request, makes some queries to the database and then responds.

In order to serve static files and cachable files fast, I am going to use Varnish in all cases.

Here is my question:

After reading about various Python web application servers, I have seen that they all have their "fans" for certain, usually "personal" reasons, which got me confused since each usecase differs from the next.

  • How can I learn about the core differentiating factors of Python web servers (in order) to decide how suitable they are for my project and if one would be better than the other?

  • What are your (technically provable) thoughts on the matter?

  • How should I choose a Python web server?

Thank you.

4
  • Please read the FAQ on appropriate questions ( serverfault.com/help ) - this is a programming question and it's a product recommendation question, and it's all opinion without any clear answer. Oct 24, 2013 at 15:18
  • @TessellatingHeckler, I think there is a chance that you actually misunderstood the question. The question mainly seeks to clarify the way which is to be followed in order for one to figure out which server solves his/her production needs. Then the question goes on to ask people's thoughts on the matter. It's not a programming question either. It's about servers (web server) and not about programming.
    – Phil
    Oct 24, 2013 at 15:23
  • Are you asking "I have an application using CherryPy web framework, should I run it on Apache or Nginx?" or are you asking "I haven't written my app yet, should I program against CherryPy or Django or web.py?". If the first, what framework do you need the web server to support? Either way "how can I learn about X" sounds like a learning material recommendation, which is expressly off-topic. serverfault.com/help/on-topic Oct 24, 2013 at 17:47
  • @TessellatingHeckler, where did I ever mention the name of a Framework? FYI. CherryPy is also a web server, apart from being a framework. The question is about web servers (WSGI or uwsgi compliant), not frameworks.
    – Phil
    Oct 24, 2013 at 21:26

2 Answers 2

3

Part of the biz is becoming a "fan" of whatever server configuration works for you.

For a simple app, it really shouldn't matter, but you'll find that deployment and maintenance are better for this or that server. Maybe your linux distro has better packages for apache. Maybe it's better for nginx. Maybe you can't make the configuration work for apache. Maybe you can't make it work for nginx.

If you're looking for a simple "This server is superiour" answer, it's just not going to happen. They can all be configured to work very well or very poorly, and anyone who has worked in the industry has seen both and formed strong opinions.

That being said, I tend to stick with Apache. Nginx is a hot up-and-comer, so jumping on that is not a bad decision, but Apache is still the gold standard.

0

The best thing you can do is ensure you target your Python web application to the WSGI specification (PEP 333/3333). Do not build your application to be dependent on specific features of particular Python web servers which fall outside of the WSGI specification. By doing this you will ensure that the web server isn't a critical component and you will not forever be bound to one specific web server. This will give you the flexibility to migrate your whole web application or parts of it to a different WSGI server if your requirements of the web server change.

Also ensure that your web application can work in multithreaded and multiprocess deployment environments and ensure that you don't somehow make your code dependent on the use of coroutines for concurrency in handling parallel requests. This is again to ensure you have the flexibility to move between WSGI servers as necessary.

Finally, don't take the stance that you must use the same technology for your whole web application. Just because one URL of your application needs to handling long polling style requests don't think that you need to reimplement your whole web application as an async application. Consider instead vertically partitioning your web application and move just specific subsets of URLs that have special requirements such as async to a separate server and use the much easier to use WSGI for the bulk of the web application. To bring all the different components of the web application under the one host, use a nginx front end to proxy to the different backends, async and WSGI etc.

In other words, always keep your options open and don't restrict yourself by buying into a specific non standard technology. Try and stick with WSGI as much as possible as it will give you most flexibility as far as WSGI server choices and PaaS hosting.

1
  • thank you for your thorough answer regarding Python web application development. Can you please also comment about Python web application servers (WSGI or uwsgi compliant)?
    – Phil
    Oct 24, 2013 at 21:28

Not the answer you're looking for? Browse other questions tagged .