0

My web site will slow down after an e-mailing, when more than 50 visitors arrive at the same time. Then it gets very slow and sometimes gives a 502 Bad Gateway. I tried to change some settings on PHP and NGINX - this didn't solve it. To be able to see what's happening I installed a tool on the server (Netdata) which gives real time information during 'rush hour'. Also I used a tool to do load testing with 50 concurrent visitors (flood.io) It appears that when testing starts, CPU usage immediately grows to 100%. Memory is almost, but not used fully, there is about 80Mb available memory left and the swap file is not used yet, which I think is good.

The only log file remarks are:

WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 12 total children WARNING: [pool www] server reached pm.max_children setting (15), consider raising it [error] 26813#26813: *114871 connect() to unix:/var/run/php/php7.4-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:"

I tried to tune but couldn't make more of it, so I hope this question brings an insight in what to do now. I would expect that more visitors than 50 must be possible. For testing, I copied the site to it's own dedicated VPS, so nothing is slowing it down. What could I do to have it accept some more visitors? Any help would be very much appreciated!

The url on which I'm testing is https://test.parkeer24.nl - the setup is Drupal 8 on Ubuntu 18.04 (LTS), 1 GB RAM, 25 GB SSD, 1 CPU and most of the settings are default.

NGINX 1.14.0 nginx.conf:

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

events {
    worker_connections 1024;
}

http {
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    types_hash_max_size 2048;
    server_tokens off;
    client_body_buffer_size 10K;
    client_header_buffer_size 1k;
    client_max_body_size 8m;
    large_client_header_buffers 2 1k;
    fastcgi_buffers 16 16k;
    fastcgi_buffer_size 32k;
    client_body_timeout 12;
    client_header_timeout 12;
    keepalive_timeout 15;
    send_timeout 10;
    include /etc/nginx/mime.types;
    default_type application/octet-stream;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;
    gzip on;
    gzip_comp_level  2;
    gzip_min_length  1000;
    gzip_proxied     expired no-cache no-store private auth;
    gzip_types       text/plain application/x-javascript text/xml text/css application/xml;
    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

PHP 7.4 php.ini:

[PHP]
engine = On
short_open_tag = Off
precision = 14
output_buffering = 4096
zlib.output_compression = Off
implicit_flush = Off
serialize_precision = -1
disable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
zend.enable_gc = On
zend.exception_ignore_args = On
expose_php = Off
max_execution_time = 30
max_input_time = 60
memory_limit = 128M
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = Off
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
variables_order = "GPCS"
request_order = "GP"
register_argc_argv = Off
auto_globals_jit = On
post_max_size = 8M
default_mimetype = "text/html"
default_charset = "UTF-8"
enable_dl = Off
file_uploads = On
upload_max_filesize = 2M
max_file_uploads = 20
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60
[CLI Server]
cli_server.color = On
[mail function]
SMTP = localhost
smtp_port = 25
mail.add_x_header = Off
[ODBC]
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1
[MySQLi]
mysqli.max_persistent = -1
mysqli.allow_persistent = On
mysqli.max_links = -1
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off
[mysqlnd]
mysqlnd.collect_statistics = On
mysqlnd.collect_memory_statistics = Off
[bcmath]
bcmath.scale = 0
[Session]
session.save_handler = files
session.use_strict_mode = 0
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.cookie_samesite =
session.serialize_handler = php
session.gc_probability = 0
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.referer_check =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.sid_length = 26
session.trans_sid_tags = "a=href,area=href,frame=src,form="
session.sid_bits_per_character = 5
[Assertion]
zend.assertions = -1
[Tidy]
tidy.clean_output = Off
[soap]
soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400
soap.wsdl_cache_limit = 5
[ldap]
ldap.max_links = -1

PHP www.conf:

[www]
user = www-data
group = www-data
listen = /run/php/php7.4-fpm.sock
listen.owner = www-data
listen.group = www-data
pm = dynamic
pm.max_children = 15
pm.start_servers = 3
pm.min_spare_servers = 3
pm.max_spare_servers = 6
C.A. Vuyk
  • 1,055
  • 17
  • 36
  • I am not sure but the issue came when there is less File Usage space, less File physical memory and the CPU overheated for that you need need to maximize the resources – Shakeel Ahmad Jun 04 '21 at 07:36
  • Yes, more resources surely will bump up the performance. I have a 'live' version of this site running on a server with 12GB ram and 4 cpu's - that allows for about 250 visitors before falling apart. But for such a site I would expect that more visitors than 50 must be possible don't you? – C.A. Vuyk Jun 04 '21 at 08:22
  • There's enough physical file space root@sv11:~# df -m gives /dev/sda1 24636 15913 8708 65% – C.A. Vuyk Jun 04 '21 at 08:24
  • Not a solution but could help mitigate : What about using a CDN like cloudflare ? – Civette Jun 04 '21 at 08:46
  • As I understand it, Cloudflare would prevent DDOS attacks. But when I send an emailing, the whole purpose of it is to attract more visitors. A site should be able to receive such low numbers. – C.A. Vuyk Jun 04 '21 at 09:09
  • You need to increase `pm.max_children`, then the bottleneck will probably be the RAM, 1GB seems very low to handle both php/mysql, you will see the real difference when testing on your live server having 12GB. – EricLavault Jun 04 '21 at 10:15
  • I tested that with the 12Gb server up to 250 children. It didn't help. Point is, shouldn't it be a problem to handle more connections even with a simple setup. – C.A. Vuyk Jun 04 '21 at 11:06

0 Answers0