Loading

响应速度与uwsgi线程数的关系

压测发现接口响应较慢,代码打日志发现接口执行时间月0.04s,通过修改uwsgi进程与线程数量可显著影响响应速度及其分布。

结论:

压测时并发请求较多,

如果uwsgi worker较少,可以很快响应到来的请求(0.04s),但剩余请求会堆积,等待uwsgi处理,所以这种情况下,响应时间小者很小,大者很大。

如果uwsgi worker较多,超过cpu核心数,则同时有很多请求被多个uwsgi处理,但这些worker会争夺cpu资源,导致每个请求的处理都较慢,但多个请求处理完的时间相近,所以这种情况下,响应时间小者很大,大者却不比小者大很多。

此外发现thunder-lock明显拖慢响应速度。


参考:https://stackoverflow.com/questions/14962289/bad-django-uwsgi-performance

img

参考:https://stackoverflow.com/questions/34182465/what-are-uwsgi-threads-used-for

参考:https://uwsgi-docs.readthedocs.io/en/latest/ThingsToKnow.html

参考:Using the NGINX Built‑In Timing Variables

参考:nginx and uwsgi: large difference between upstream response time and request time

posted @ 2020-04-27 20:51  dylanchu  阅读(2113)  评论(0编辑  收藏  举报