gunicorn slower than flask development server

邮差的信 提交于 2020-01-12 11:06:06

问题


My Flask application has a simple feature with a textarea where you input HTML and clicking on a button will strip all the HTML tags and return the text inside the HTML into another textarea, say Text.

When I run my application with:

app.run(debug=True, host='0.0.0.0', port='8000')

it works very fast and smooth. But when I run it with gunicorn like this:

gunicorn -w 3 -b 0.0.0.0:8000 --log-file=- myapp.app:app

after I click the button 'HtmlToText' it takes too much time to return the text value and the larger the HTML the longest it takes.

Context:

The button is a simple JQuery function that does a GET request to 0.0.0.0:8000/htmltotext, that view get's the HTML as a querystring parameter /htmltotext?html=<head>Hi</head> and returns a JSON {text: "Hi"}

What would be the reason for gunicorn being so slow in this issue ?


回答1:


So, what was happening here is that gunicorn had this issue:

Bad Request

Request Line is too large (7385 > 4094)

Since the request was too large it was never happening.

The fix:

gunicorn --limit-request-line 0

0 means unlimited.



来源:https://stackoverflow.com/questions/26985382/gunicorn-slower-than-flask-development-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!