Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask and scaling and concurrency

In the documentation I see the following:

There is only one limiting factor regarding scaling in Flask which are the context local proxies. They depend on context which in Flask is defined as being either a thread, process or greenlet. If your server uses some kind of concurrency that is not based on threads or greenlets, Flask will no longer be able to support these global proxies. However the majority of servers are using either threads, greenlets or separate processes to achieve concurrency which are all methods well supported by the underlying Werkzeug library.

My question: What other concurrent mechanisms are there other than these 3 methods?

like image 721
14 revs, 12 users 16% Avatar asked Jul 31 '13 18:07

14 revs, 12 users 16%


People also ask

Are Flask apps scalable?

Flask is also highly scalable as it can process a high number of requests each day. This micro-framework modularize the entire code and let developers work on independent chunks and use them as the code base grows. However, as compared to Django, Flask's scalability is limited.

Can Flask handle concurrent requests?

Improve performance in both Blocking and Non-Blocking web servers. Multitasking is the ability to execute multiple tasks or processes (almost) at the same time. Modern web servers like Flask, Django, and Tornado are all able to handle multiple requests simultaneously.

How many concurrent requests can a Flask app handle?

For reference, the Flask benchmarks on techempower give 25,000 requests per second.


1 Answers

One pretty interesting concurrency mechanism is the asynchronous model. You have a single process with a single thread running the whole show, with all the I/O or otherwise lengthy tasks being asynchronous and callback based. This method scales really well for I/O bound services, servers in this category easily handle the C10K problem.

See Tornado or node.js for examples.

like image 161
Miguel Avatar answered Oct 12 '22 16:10

Miguel