Gunicorn does not handle concurrent requests at the same time

I am trying to do long queries using gunicorn and its asynchronous workers, but I cannot find any examples that I can get to work. I used the example here , but configured to add a fake delay (sleep for 5s) before returning the answer:

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

Then I fire the guns like this:

gunicorn -w 4 myapp:app -k gevent

When I open two browser tabs and type http://127.0.0.1:8000/in both of them and send requests almost at the same time, the requests seem to be processed sequentially - one returns after 5 seconds and the other returns after further 5 seconds.

Q. , ? 4 , "", ?

+5
3

, : -. , . , , , - , .. , , , , , , , ..

+6

gunicorn , gevent, , , , 5- .

, , - . , IO (, , , ), , , ., , .

UPDATE

.

, , - , .

, time.sleep , , , .

, . os.getpid().

+1

gevent.sleep time.sleep.

, -w 4, -k gevent - async, , gunicorn . , , , time.sleep , gevent.monkey.patch_all().

0

All Articles