Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between WSGI utilities and Web Servers [closed]

Tags:

python

wsgi

I am new to Python and i am not able to understand the server concepts in Python.

First of all what is WSGI and what are Wsgiref and Werkzeug and how are they different from CherryPy WSGI Server, Gunicorn, Tornado (HTTP Server via wsgi.WSGIContainer), Twisted Web, uWSGI, Waitress WSGI Server.

If i need to develop a web application from scratch, i mean starting from the beginning, where should i start, my company needs a custom framework and the application is based on critical performance overheads.

Please help and explain how they are different.

P.S I am not a beginner to programming.

like image 570
ajknzhol Avatar asked Jan 11 '14 05:01

ajknzhol


People also ask

Is WSGI a web server?

The Web Server Gateway Interface (WSGI, pronounced whiskey or WIZ-ghee) is a simple calling convention for web servers to forward requests to web applications or frameworks written in the Python programming language. The current version of WSGI, version 1.0.

What is the difference between WSGI and CGI?

The WSGI application runs on the server, and acts as the interface between the server and web application written in a python. The CGI application runs on the server and processes requests passed by server.

What is the difference between asgi and WSGI?

WSGI stands for Web Server Gateway Interface, and ASGI stands for Asynchronous Server Gateway interface. They both specify the interface and sit in between the web server and a Python web application or framework. One of their jobs is to handle incoming requests from the client, but they go about it in different ways.

Why do I need a WSGI server?

WSGI is a standard described on PEP 3333 and basically, provides a standard interface between web applications written in Python and Webservers. That means, WSGI gives portability to your Python Web Application across many different Web Servers, without any additional configurations on your NGINX, Apache, etc.


1 Answers

WSGI is just a set a rules to help unify and standardize how Python applications communicate with web servers. It defines both how applications should send responses and how servers should communicate with applications and pass along the environment and other details about the request. Any application that needs to communicate with any web server implements WSGI, because its the de-facto standard and recommended method for Python. WSGI came about to unify the other implementations (CGI, mod_python, FastCGI).

wsgiref is a reference implementation of the WSGI interface. Its like a blueprint to help developers understand how to implement WSGI in their own applications.

The other things you mentioned are all different applications that implement the WSGI standard; with some exceptions:

  1. Twisted is a library to create applications that can communicate over a network. Any kind of network, and any kind of applications. Its not limited to the web.

  2. Tornado is similar to Twisted in that it is also a library for network communication; however it is designed for non blocking applications. Things that require a long open connection to the server (like say, an application that displays realtime feeds).

  3. CherryPy is a very minimal Python framework for creating web applications. It implements WSGI.

  4. Werkzeug is a library that implements WSGI. So if you are developing an application that needs to speak WSGI, you would import werkzeug because it provides all various parts of WSGI that you would need.

  5. uWSGI is a project that allows easily hosting of multiple web applications. The fact that it as WSGI in the name is because WSGI was the first plugin that was released with the application. It is perhaps the odd duck in this list because it is not a development framework, but more of a way to manage multiple web applications.

Web servers that implement WSGI can talk to any application that also implements WSGI. modwsgi is a popular implementation of WSGI for webservers; it is available for both Apache and Nginx and for IIS there is the isapi wsgi module.

like image 134
Burhan Khalid Avatar answered Sep 19 '22 20:09

Burhan Khalid