mopemope / meinheld

Meinheld is a high performance asynchronous WSGI Web Server (based on picoev)
http://meinheld.org
Other
1.47k stars 103 forks source link

File upload fails with 502 #129

Open keremnymn opened 3 years ago

keremnymn commented 3 years ago

I am using Gunicorn + Flask + Meinheld + NGINX with egg:meinheld#gunicorn_worker setting but when I try to upload more than 10 MB server fails with 502 Bad Gateway. I think Meinheld causes the issue because I can upload the same files with sync workers.

Exact error is:

[error] 4338#4338: *1 sendfile() failed (32: Broken pipe) while sending request to upstream, client: 127.0.0.1, server: localhost, request: "POST /******** HTTP/1.1", upstream: "http://127.0.0.1:8000/*********", host: "localhost", referrer: "http://localhost/******/"

Edit: When I disable Gunicorn and use only Meinheld, it works without an error.

Any ideas?

soundkitchen commented 3 years ago

hi @keremnymn

Could you please show me each middleware settings? (nginx, gunicorn and so

keremnymn commented 3 years ago

Gunicorn: gunicorn --workers=6 --worker-class="egg:meinheld#gunicorn_worker" app:app app.py:

import meinheld, os
from **** import create_app

app = create_app()

if __name__ == "__main__":
    if os.environ['RUNNING_ON'] == 'localhost':
        app.run(debug=True)
    else:
        meinheld.listen(("0.0.0.0", 5000))
        meinheld.run(app)

nginx:

server {
        listen 80;
        server_name localhost;
        client_max_body_size 512M;

        location /static {
                alias /********/static;
        }
        location / {
                proxy_pass http://localhost:8000;
                include /etc/nginx/proxy_params;
        }
}
zulfirman commented 2 years ago

any updates about this issue?

zulfirman commented 2 years ago

I solve it by changing to gevent, I use gunicorn with meinheld before but now using gunicorn with gevent.

gunicorn --bind=0.0.0.0:5000 -w 3 --worker-class=gevent app:app --timeout 60

jet10000 commented 1 year ago

I had the same problem

jet10000 commented 1 year ago

caddy -> gunicorn(meinheld) -> django

gunicorn --workers=5 --worker-class="egg:meinheld#gunicorn_worker" --bind :8000 myproject.wsgi

When upload 3M image file via form, it's display Request timeout, Then I just use gunicorn

caddy -> gunicorn -> django

gunicorn --workers=5 --bind :8000 myproject.wsgi

It's working.

@jet10000

https://m.xkcd.com/979/

mheppner commented 1 year ago

I had the same issue - anything larger than ~15MB would just immediately display a request timeout. Removed meinheld from gunicorn and uploads work as expected.