3

Gunicorn states the following:

Gunicorn is based on the pre-fork worker model. This means that there is a central master process that manages a set of worker processes. The master never knows anything about individual clients. All requests and responses are handled completely by worker processes.

(http://docs.gunicorn.org/en/stable/design.html)

Yet, I cannot grasp the extent of this definition. I'd love to see a diagram, chart or anything that would visualise this concept/model.

Lets assume we have a folder that consists of a single file: wsgi.py

def app(environ, start_response):
    data = b"Hello, World!\n"
    start_response("200 OK", [
        ("Content-Type", "text/plain"),
        ("Content-Length", str(len(data)))
    ])

And run gunicorn with the following arguments:

gunicorn -w 2 wsgi:app

Thus:

If two workers are active and therefore each accepting a connection, does each process has its own wsgi.py instance ?

OR

If they share a common database or I/O operations, is it synchronised ?

P.S: I'd love to see references to articles concerning this topic !

S.B
  • 13,077
  • 10
  • 22
  • 49
  • Possible duplicate of [What exactly is a pre-fork web server model?](https://stackoverflow.com/questions/25834333/what-exactly-is-a-pre-fork-web-server-model) – lee-pai-long May 03 '18 at 15:58

0 Answers0