benoitc / gunicorn

gunicorn 'Green Unicorn' is a WSGI HTTP Server for UNIX, fast clients and sleepy applications.
http://www.gunicorn.org
Other
9.76k stars 1.74k forks source link

Worker timeout under gevent mode using ab #2330

Closed alanwang93 closed 4 years ago

alanwang93 commented 4 years ago

Hi, I'm using ab to test my serving, the command is like

ab -n 20000 -c 4 -k -T application/json -p b1.json "127.0.0.1:8000/predict"

where -k means keep-alive.

The problem is, if the connection lasts for more than timeout (the timeout argument in gunicorn), a timeout error will be raised. Before the error, the service works well and can handle a request within 2s.

  1. If I switch to gthread mode, the problem disappears.
  2. If I remove -k in ab command, the problem disappears.

It seems that if ab's connection lasts longer than timeout, the worker will be killed.

benoitc commented 4 years ago

This is expected. The sync worker doesn't handle keep-alive, it's designed for fast request and close them every time. Also if a request is too long and maintain a worker alived above the timeout, the gunicorn will be killed: https://docs.gunicorn.org/en/stable/design.html#server-model

Hope it helps :)