枪gunicorn异步工人班级增加平均时间,而同步良好
我正在运行两个单独的烧瓶应用程序。在针对AWS ECS的针对性的容器中。其中之一是由CPU结合的服务,另一个是由另一个服务来完成传入请求。绑定CPU只是另一个API(CPU结合)。
我正在使用Jmeter使用相当小的有效载荷进行负载测试(JSON有效载荷带有一些密钥/值对,这确实很小)。
对于CPU结合(在其上运行的数学模型),我决定与CPU绑定的应用程序中建议的同步工作类(2个工人)一起去。在启用线程(async类)时,对其进行了负载测试,并且在平均响应时间方面,同步实际上比异步更好。
但是,问题在于,我在另一个应用程序上观察到了与CPU结合的API相同的行为。简而言之,它正在处理传入数据(转换,日志记录等),并通过使用请求库将其发送到API。
同步工人可以,但是当我切换到异步时,平均响应时间越来越多。据我从Internet I/O绑定的操作(例如进行HTTP调用(是吗?))上的文档和教程中了解的据我所知,应该通过线程更好地处理HTTP调用(是吗?),因为此类操作并不能阻止由于GIL而阻止解释器。但是,我看到的只是增加了平均响应时间。
我想知道这是完全出乎意料的事情还是可能需要更多细节,基准测试和进一步配置的情况?
I am running two separate Flask apps. in containers targeted to be run on AWS ECS. One of them is a CPU-bound service and being called by the other to complete the incoming request. CPU-bound is simply an API (CPU-bound) for the other.
I am using JMeter to do the load testing with a rather small payload (json payload with a few key/value pairs, something really small).
For CPU-bound (math model running on it), I decided to go with sync worker class (2 workers) as suggested in the docs for CPU-bound apps. Also done a load testing on it while threads enabled (async class) and indeed sync worked better than async in terms of average response time.
However, the problem is I observed the same behavior on the other app calling that CPU-Bound API. Simply, it's processing the incoming data (transformation, logging and etc.) and send it to the API via using requests library.
It's ok with sync workers, but when I switch to async the average response time is becoming more and more. As far as I understood from the docs and tutorials on the internet I/O bound operations like making an HTTP call (is it?) should be handled better with threads because such ops not blocks the interpreter due to GIL. However, what I saw is just increasing average response times.
I wonder if it's something totally unexpected or a possible case which needs more details, benchmarking and further configuration?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论