I have a Linux (Ubuntu 20.04) server with 32GB RAM, a 16-core CPU, SSD storage, and 16000 IOPS. Recently we had a campaign and a large traffic came on our website. The website threw 502 Bad Gateway.
I started playing with some Nginx and PHP-FPM configurations based on research to tune the load better. Here is the final config:
# Nginx
worker_processes auto;
events {
worker_connections 8048;
PHP
pm = dynamic
pm.max_children = 85
pm.start_servers = 10
pm.min_spare_servers = 5
pm.max_spare_servers = 15
max_requests = 1000
Now, the website can handle the traffic very well without any downtime or weak performance, but what is strange for me is the low usage of RAM even when there is huge traffic on the website.
I mean lots of the RAM is unused (usually just ~2.5GB of the RAM is used) both when there are over 20k concurrent users on the website and when there are less than 1k concurrent users. Is that normal? How can I make it balance to use more RAM when needed?
It should be noted the result of ulimit -n is 1024.