枪支异步工人班

发布于 2025-02-03 09:10:06 字数 602 浏览 2 评论 0原文

我有一个非常基本的问题。看来我没有得到它,或者我只需要确认即可。

假设我设置了一个烧瓶应用程序,然后使用Gunicorn运行它。 我使用- Wokers = 2- threads = 2,因此我可以在并行上服务4请求。 现在,假设客户端执行4个并行请求,该请求将在Blask应用程序中进行requests.get,它需要5秒才能获得响应(从理论上)。我第五个客户端的电话将需要等待其他四个人中的一个,然后才能在后端开始(并需要5秒钟才能执行)。

现在我的问题:当我切换到- Worker-Class Gevent时,它是否会帮助获得更多并行请求而无需调整代码?如果我正确理解它,我需要正确使用异步库调用以获取GEVENT的优势,并获得1000的最大并行请求执行,例如,对吗?我是说:如果代码继续简单地进行requests.get(或睡眠或其他)而不使用async client libs,则第五请求仍然会被阻止?

谢谢你! (我从未与Asnycio和Coroutines合作过,所以很抱歉)

I have a very basic question. It seems like I don't get it, or I simply need a confirmation.

Let's say I set up a flask app and let it run using gunicorn.
I use --wokers=2 and --threads=2, so I can serve 4 requests on parallel.
Now let's say a client does 4 parallel requests, which will do a requests.get in the flask app, which needs 5 seconds to get a response (in theory). I fifth client call will need to wait for one of the 4 others to be finshed, before it's even started in the backend (and will take another 5 seconds for execution).

Now my question: When I switch to --worker-class gevent, will it help getting more parallel requests without adaping the code? If I understand it correctly, I need to properly use async library calls to get advantage of gevent, and to get a maximum parallel request execution of 1000 for example, right? Am I right by saying: If the code continues to simply do requests.get (or a sleep or whatever) without using async client libs, it the fifth request will still be blocked?

Thank you!
(I've never worked with asnycio and coroutines, so I'm sorry)

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文