小编Des*_*esh的帖子

解决 django 应用程序中 CPU 使用率过高的问题

我尝试优化我的 django Web 应用程序以增加最大 rps。我的堆栈包括 docker+django+gunicorn+nginx

我用 yandex.tank 做了性能测试。

当 rps 负载大约为 15 时,请求开始失败。

坦克写道: "110 Connection timed out"

在 nginx access.log 我有:

 "xxx.xxx.xxx.xxx - - [27/Aug/2019:17:37:52 +0000] "GET /url HTTP/1.1" 499 0 "-" "Tank" 5.257 - [5.256]"
Run Code Online (Sandbox Code Playgroud)

当我在此测试期间打开 htop 时,我看到所有服务器核心都以 100% 加载

我曾尝试使用 proxy_read_timeout、keepalive 设置但没有结果。


upstream app {
    server django:5000;
 }

server {
    listen 80;
    server_name my.site.com;

    listen 443 ssl;

    ssl_certificate /etc/letsencrypt/live/my.site.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/my.site.com/privkey.pem;

    client_max_body_size 4G;

    access_log /var/log/nginx/access.log combined_plus;
    error_log /var/log/nginx/error.log;

    gzip             on;
    gzip_comp_level  2;
    gzip_min_length  1000;
    gzip_proxied     expired …
Run Code Online (Sandbox Code Playgroud)

django nginx cpu-usage gunicorn docker

5
推荐指数
0
解决办法
1970
查看次数

标签 统计

cpu-usage ×1

django ×1

docker ×1

gunicorn ×1

nginx ×1