ryandipranata
Poster 1.0
Halo mastah DWH semua, sebelumnya saya uda googling kesana kemari. Tapi saya cobain tetep hasilnya kurang memuaskan, alias masih sering High CPU sehingga website saya serring Error 502 kala dibuka. Di error_list NGINX ada tulisannya begini juga:
Bagaimana ya setting NGINX+PHP-FPM yang benar untuk jumlah visitor online sekitar 200 - 500 an?? Saya juga pakai CloudFlare, berharap bisa reduce pemakaian CPU tapi tetap sama saja.
Ketika saya cek "htop" yang sering memakan CPU banyak adalah PHP-FPM, bisa hingga 80% setiap proses.
Spesifikasi VPS saya:
- Core 2
- RAM 4 GB
- KVM
Settingan Nginx saya:
Settingan PHP-FPM saya:
Terimakasih sebelumnya
Code:
2014/05/01 13:27:38 [error] 64117#0: *2745 upstream prematurely closed connection while reading response header from upstream, client: xxx.xxx.xxx.xxx server: xxxxxxx.com, request: "GET /xxxxxxxxxx", upstream: "fastcgi://127.0.0.1:9001"
2014/05/01 13:27:31 [error] 64117#0: *2415 upstream timed out (110: Connection timed out) while connecting to upstream"
Bagaimana ya setting NGINX+PHP-FPM yang benar untuk jumlah visitor online sekitar 200 - 500 an?? Saya juga pakai CloudFlare, berharap bisa reduce pemakaian CPU tapi tetap sama saja.
Ketika saya cek "htop" yang sering memakan CPU banyak adalah PHP-FPM, bisa hingga 80% setiap proses.
Spesifikasi VPS saya:
- Core 2
- RAM 4 GB
- KVM
Settingan Nginx saya:
Code:
#user nobody;
worker_processes 2;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid /usr/local/apps/nginx/var/log/nginx.pid;
events
{
worker_connections 1024;
use epoll;
multi_accept on;
}
error_log /usr/local/apps/nginx/var/log/error_log debug;
http
{
include 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 /usr/local/apps/nginx/var/log/web.access.log main;
# Basic Settings
access_log off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 30;
keepalive_requests 100000;
server_tokens off;
reset_timedout_connection on;
send_timeout 60;
client_body_timeout 60;
client_header_timeout 60;
client_max_body_size 20M;
client_body_buffer_size 1k;
client_header_buffer_size 1k;
large_client_header_buffers 4 8k;
types_hash_max_size 2048;
# File Cache Settings
open_file_cache max=200000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
#Gzip Setting
gzip on;
gzip_min_length 10240;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
gzip_disable "MSIE [1-6]\.";
# If your domain names are long, increase this parameter.
server_names_hash_bucket_size 64;
include /usr/local/apps/nginx/etc/conf.d/*.conf;
include /usr/local/apps/nginx/etc/sites-enabled/*.conf;
}
Settingan PHP-FPM saya:
Code:
;;;;;;;;;;;;;;;;;;;;;
; FPM Configuration ;
;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;
; Global Options ;
;;;;;;;;;;;;;;;;;;
[global]
;emergency_restart_threshold 10
;emergency_restart_interval 1m
;process_control_timeout 10s
;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ;
;;;;;;;;;;;;;;;;;;;;
[index]
listen = 127.0.0.1:9000
user = rap
group = rap
request_slowlog_timeout = 5s
slowlog = var/log/php-fpm-slowlog-index.log
"/usr/local/apps/php53/etc/php-fpm.conf" 64L, 1359C
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 5
pm.start_servers = 3
pm.min_spare_servers = 2
pm.max_spare_servers = 4
pm.max_requests = 500
listen.backlog = -1
request_terminate_timeout = 300
rlimit_files = 131072
rlimit_core = unlimited
catch_workers_output = yes
security.limit_extensions = FALSE
env[HOSTNAME] = $HOSTNAME
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
[regular]
listen = 127.0.0.1:9001
user = rap
group = rap
request_slowlog_timeout = 5s
slowlog = var/log/php-fpm-slowlog-regular.log
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 5
pm.start_servers = 3
pm.min_spare_servers = 2
pm.max_spare_servers = 4
pm.max_requests = 500
listen.backlog = -1
request_terminate_timeout = 300
rlimit_files = 131072
rlimit_core = unlimited
catch_workers_output = yes
security.limit_extensions = FALSE
env[HOSTNAME] = $HOSTNAME
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
Terimakasih sebelumnya

Last edited: