如何使烧瓶处理25K请求,例如Express.js

发布于 2025-01-21 16:59:45 字数 290 浏览 2 评论 0原文

因此,我正在制作一个大型的社交媒体应用程序,但是我有一个问题可以选择烧瓶或Express.js。我非常喜欢烧瓶,但不能处理太多的请求。 Express.js每秒可以处理约25K请求(Google)。因此,无论如何,是否有使用Gunicorn使用Gunicorn进行烧瓶处理25K请求,我目前正在使用此命令$ gunicorn -w 4 -b 0.0.0.0.0.0.0.0.0.0.0.0:5000 your_project:app时间。嗯,还有一个问题一次可以处理100万用户。我应该选择express.js,因为它可以处理25k请求

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

辞旧 2025-01-28 16:59:45

您可以使用多线程或GEVENT来增加枪支的并发性。

option1多线程

例如:

gunicorn -w 4 --threads 100 -b 0.0.0.0:5000 your_project:app

- 线程100表示每个进程100个线程。

因此-w 4- threads 100表示400个请求

-w 4 表示4个进程,

pip install gevent
gunicorn -w 4 -k gevent --worker-connections 1000 -b 0.0.0.0:5000 your_project:app

连接1000表示每个gevent工作过程的1000 coroutines。

-w 4表示4个进程,因此-w 4 -k gevent -worker-connections 1000一次指4000个请求。

有关更多信息,您可以参考我的博客文章: https://easydevguide.com/posts/posts/posts/gunicorn_concurrency

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文