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 ...

Get Python Microservices Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.