Process management
We've seen in Chapter 2, Discovering Flask, that Flask-based applications, in general, run in a single-threaded environment.
To add concurrency, the most common pattern is to use a prefork model. Serving several clients concurrently is done by forking several processes (called workers), which accept incoming connections from the same inherited socket. The socket can be a TCP Socket or a Unix Socket. Unix sockets can be used when both the clients and the server are running on the same machine. They are based on exchanging data via a file and are slightly faster than TCP sockets, since they don't have to deal with the network protocol overhead. Using Unix Sockets to run Flask apps is common when the application is proxied via a front server like NGinx.
In any case, Unix or TCP, every time a request reaches the socket, the first available process accepts the request and handles it. Which process gets which request is done at the system level by the system socket API with a...