php - Web site cannot handle more than 50 concurrent visitors, what is wrong?Get the solution ↓↓↓
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:
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
[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
People are also looking for solutions of the problem: filter_sanitize_string
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.