uWSGI
The next element of the chain is the uWSGI application. This application receives the requests from nginx
and redirects them into independent Python workers, in WSGI format.
Web Server Gateway Interface (WSGI) is a Python standard to deal with web requests. It's very popular and supported by a lot of software, both from the sending end (like nginx
, but also other web servers like Apache and GUnicorn) and from the receiving end (virtually every Python web framework, like Django, Flask, or Pyramid).
uWSGI will also start and coordinate the different processes, handling the lifecycle for each of them. The application works as an intermediary, starting a group of workers receiving the requests.
uWSGI is configured through a uwsgi.ini
file. Let's see an example, available on GitHub at https://github.com/PacktPublishing/Python-Architecture-Patterns/blob/main/chapter_06_web_server/uwsgi_example.uni.
[uwsgi]
chdir=/root/directory
wsgi-file = webapplication...