1、使用 PHP-FPM SOCKET的形式通讯
2、配置
PHP-FPM配置
[root@bogon php-fpm.d]# ls -al
总用量24drwxr-xr-x. 2 root root 22 8月 13 12:15.
drwxr-xr-x. 87 root root 8192 8月 13 12:10..-rw-r--r--. 1 root root 10110 8月 13 12:05www.conf
[root@bogon php-fpm.d]# pwd/etc/php-fpm.d
[root@bogon php-fpm.d]# vi www.conf
pm= static; The number of child processes to be created when pmis set to 'static'and the
; maximum number of child processes to be created when pmis set to 'dynamic'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variableinthe original PHP
; CGI.
; Note: Used when pmis set to either 'static' or 'dynamic'; Note: This valueismandatory.
pm.max_children= 200; The number of child processes created on startup.
; Note: Used only when pmis set to 'dynamic'; Default Value: min_spare_servers+ (max_spare_servers - min_spare_servers) / 2pm.start_servers= 20; The desired minimum number of idle server processes.
; Note: Used only when pmis set to 'dynamic'; Note: Mandatory when pmis set to 'dynamic'pm.min_spare_servers= 5; The desired maximum number of idle server processes.
; Note: Used only when pmis set to 'dynamic'; Note: Mandatory when pmis set to 'dynamic'pm.max_spare_servers= 35; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaksin3rd party libraries. For
; endless request processing specify'0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value:0pm.max_requests= 4096; Set open file descriptor rlimit.
; Default Value: system defined value
rlimit_files= 4096
Nginx 配置
[root@bogon nginx]# pwd
/usr/local/openresty/
[root@bogon openresty]# cat nginx/conf/nginx.conf
user root;
worker_processes 4;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 2048;
}
Linux 设置
[root@bogon php-fpm.d]# cat /etc/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
touch /var/lock/subsys/local
ulimit -HSn 65535
[root@bogon php-fpm.d]# source /etc/rc.local
[root@bogon php-fpm.d]#
3、Siege 压力测试结果
[root@workspace ~]# siege -c 100 -r 10 http://10.2.1.123 -i -b
Transactions: 2550 hits
Availability: 100.00 %
Elapsed time: 43.20 secs
Data transferred: 162.12 MB
Response time: 3.62 secs
Transaction rate: 59.03 trans/sec
Throughput: 3.75 MB/sec
Concurrency: 213.65
Successful transactions: 2550
Failed transactions: 0
Longest transaction: 18.46
Shortest transaction: 0.04
[root@workspace ~]#