✓ Solved

Linode CPU usage not exceeding 500%

Hello!
I'm running a 16CPU 32GB linode and for some reasons, my linode CPU usage peaks at 500% which should be 1600%. I'm running nginx as my web server and I have configured my linode to use all available resources in the linode. I operate a very high traffic website.

Here's my nginx config

`

/etc/nginx/nginx.conf

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 8192;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        error_log off;
        access_log off;

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

        server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

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

        ##
        # Gzip Settings
        ##

        gzip on;

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}


#mail {
#       # See sample authentication script at:
#       # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
# 
#       # auth_http localhost/auth.php;
#       # pop3_capabilities "TOP" "USER";
#       # imap_capabilities "IMAP4rev1" "UIDPLUS";
# 
#       server {
#               listen     localhost:110;
#               protocol   pop3;
#               proxy      on;
#       }
# 
#       server {
#               listen     localhost:143;
#               protocol   imap;
#               proxy      on;
#       }
#}

`

1 Reply

✓ Best Answer

Test Setup:

I created a 32GB LEMP Server using the Linode Marketplace Apps
I created a 1GB Debian 10 Linode in the same data center to load test

To install the load tester, called wrk I did the following:

echo "deb http://deb.debian.org/debian buster-backports main" >> /etc/apt/sources.list
apt update
apt install wrk
# Keep one CPU thread (-t1) using 10,000 connections (-c1000) pounding away for a duration of 30 minutes (-d30m)
wrk -t1 -c10000 -d30m http://your.server.ip.address/

I ran top on the server, and observed that there were a limit of 5 php-fpm7.0 worker processes, each using close to 100% of a single CPU:

top - 05:50:37 up  2:16,  1 user,  load average: 11.94, 12.61, 8.69
Tasks: 220 total,   8 running, 212 sleeping,   0 stopped,   0 zombie
%Cpu(s): 29.9 us,  6.7 sy,  0.0 ni, 62.5 id,  0.0 wa,  0.0 hi,  0.9 si,  0.0 st
KiB Mem : 32950116 total, 22569428 free,   280512 used, 10100176 buff/cache
KiB Swap:   524284 total,   524284 free,        0 used. 32178084 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
19464 www-data  20   0  229884  12636   7404 R 100.0  0.0   0:21.23 php-fpm7.0
19467 www-data  20   0  229884  12596   7368 R 100.0  0.0   0:20.14 php-fpm7.0
19469 www-data  20   0  229884  12600   7372 R 100.0  0.0   0:18.12 php-fpm7.0
19465 www-data  20   0  229884  12596   7368 R  99.7  0.0   0:21.24 php-fpm7.0
19468 www-data  20   0  229884  10776   5624 R  99.7  0.0   0:19.19 php-fpm7.0
19112 www-data  20   0  165484  10900   5720 S  14.0  0.0   1:09.25 nginx
19104 www-data  20   0  165484  10900   5720 S  12.6  0.0   1:06.34 nginx
19103 www-data  20   0  165484  10880   5700 R  11.3  0.0   1:02.64 nginx
19108 www-data  20   0  165484  10900   5720 S   9.3  0.0   1:11.65 nginx
19114 www-data  20   0  165484  10900   5720 S   9.3  0.0   1:13.71 nginx
19116 www-data  20   0  165484  10900   5720 S   8.3  0.0   1:09.53 nginx

Editing the /etc/php/7.0/fpm/pool.d/www.conf file and changing pm.max_children = 5 to pm.max_children = 20, I was able to get around this restriction after doing:

systemctl restart php7.0-fpm

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct