Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gunicorn slower than flask development server

Tags:

flask

gunicorn

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 ?

like image 499
PepperoniPizza Avatar asked Oct 25 '25 15:10

PepperoniPizza


1 Answers

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.

like image 188
PepperoniPizza Avatar answered Oct 28 '25 05:10

PepperoniPizza