So i am making a big social media app but i have a problem which framework to choose flask or express.js i like flask so much but it cant handle too much requests. Express.js can handle about 25k request per second (google). So is there anyway to make flask handle 25k request per second using gunicorn currently i am using this command $ gunicorn -w 4 -b 0.0.0.0:5000 your_project:app
but it can only handle 4 request at a time. And uh one more question can flask handle 1Million user at a time. Should i choose express.js because it can handle 25k request
CodePudding user response:
You can use multithreads or gevent to increase gunicorn's concurrency.
Option1 multithreads
eg:
gunicorn -w 4 --threads 100 -b 0.0.0.0:5000 your_project:app
--threads 100
means 100 threads per process.
-w 4
means 4 processes, so -w 4 --threads 100
means 400 requests at a time
Option2 gevent worker
eg:
pip install gevent
gunicorn -w 4 -k gevent --worker-connections 1000 -b 0.0.0.0:5000 your_project:app
-k gevent --worker-connections 1000
means 1000 coroutines per gevent worker process.
-w 4
means 4 processes, so -w 4 -k gevent --worker-connections 1000
means 4000 requests at a time.
For more information, you can refer to my blog post: https://easydevguide.com/posts/gunicorn_concurrency