0

I want to run a flask app on tornado server and scale the number of requests it handles. I found similar code as bellow on flasks deployment documentation. But when I am running this and testing for load using jmeter I found it is not scaling at all. If I used it for 5 users and sleep time was of 5 seconds in flask then it was taking 25 seconds to complete tells it is serving one request at a time. Secondly I am not getting why tornado is removed from flasks deployment documentation from version .11.x while it was present in .10.x (reference link). One more suggestion if someone could help me finding the best server for my flask app where my requirements are as follows: I have almost 40 flask apps, which I have to host. Machine config: 8 cores with 16 gb RAM. I am expecting a maximum of 100 users at a time on a particular flask app. One of my flask app takes almost 2 seconds to finish off a job.

from flask import Flask
import time
app = Flask(__name__)

@app.route('/flask')
def hello_world():
    time.sleep( 5 )
    return 'Hello World'
if __name__ == "__main__":
    app.run()

from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from flasky import app

http_server = HTTPServer(WSGIContainer(app))
http_server.listen(12000)
IOLoop.instance().start()
  • There's a [warning in the docs](http://www.tornadoweb.org/en/stable/wsgi.html#tornado.wsgi.WSGIContainer) that's more than clear - `running a WSGI app with Tornado’s WSGIContainer is less scalable than running the same app in a multi-threaded WSGI server like gunicorn or uwsgi`. – xyres Nov 14 '17 at 11:47
  • Agreed but I thought that it would scale it a bit at least, because there it is written less scalable and not that it won't scale at all. So I thought I am going wrong somewhere in my code. Anyways I am using GUNICORN now with gevent workers and its giving good response. Thanks . – Tushar Madheshia Nov 20 '17 at 09:08

0 Answers0