I'm running nginx server with php-fpm.
I'm using "c5d.xlarge
" ec2 instance type to host my website.
c5d.xlarge = 4 vcpu & 8GB RAM.
If active connections go beyond 10k on my ELB, CPU Utilization goes beyond 60-70% on my all 15 servers.
php-fpm configuration:
pm = dynamic
pm.max_children = 65
pm.start_servers = 10
pm.min_spare_servers = 10
pm.max_spare_servers = 20
pm.max_requests = 600
nginx configuration:
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 3072;
}
http {
##
# Basic Settings
##
charset utf-8;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
server_tokens off;
log_not_found off;
types_hash_max_size 2048;
client_max_body_size 16M;
keepalive_timeout 70;
client_header_timeout 3000;
client_body_timeout 3000;
fastcgi_read_timeout 3000;
fastcgi_buffers 8 128k;
fastcgi_buffer_size 128k;
# MIME
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /home/ubuntu/apps/log/default/access.log main buffer=32k;
error_log /home/ubuntu/apps/log/default/error.log;
gzip on;
gzip_disable "MSIE [1-6]\.";
# Only allow proxy request with these headers to be gzipped.
gzip_proxied expired no-cache no-store private auth;
# Default is 6 (1<n<9), but 2 -- even 1 -- is enough. The higher it is, the
# more CPU cycles will be wasted.
gzip_comp_level 7;
gzip_min_length 20; # Default 20
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
include /etc/nginx/conf.d/*.conf;
Please suggest if these configurations are okay. I'm not too sure if this much cpu utilization for these many active connections is alright. I'll be really grateful if someone can guide me in setting up nginx and php-fpm for optimal performance.
If anymore information is required, please let me know.