PHP-FPM nginx.conf

Source: Internet
Author: User
Tags php website dedicated server percona percona server

Query AdminSystem administration Tips, Security, Internet Skip to content
    • Home

    • About Me

Million hits/day with Nginx + php-fpm + MySQL

I have recently registered to Blitz.io, a very interested cloud service which allows the users to stress-test a Web server sim Ulating up to 50K concurrent connections, with the possibility to specify different regions to originate requests, the HTT P method, the timeout and much more. This service can-help-properly configure the Web server (Nginx, LIGHTTPD, etc), the PHP-FPM and the MySQL to handle as More concurrent connections as possible.

I wanted to test how many concurrent connections Nginx + PHP-FPM + MySQL (Percona) could handle in one dedicated server an D The results is very promising as the server handled more than a concurrent connections with an average CPU usage o F 50%/65%.

The dedicated server have the following hardware Specs:intel Xeon E3 1230v3 (4 cores 8 threads at 3.3 GHz), GB DDR3 ECC , the GB SSD, the Bandwidth. The Nginx version used is 1.4.5-stable, the MySQL (Percona Server) version used are 5.6.15-63.0 and the PHP-FPM version use D is PHP 5.5.9-1~dotdeb.1 (fpm-fcgi).

The test involved the GET request of a Remote PHP Web page (/test.php?item=testing-12444) used to query the MySQL database With a table of more than 100K rows and print the found row ' s items in a HTML Web page. So we had not tested the serving of a static file but a PHP page used to display dynamic content.

The following parameters were used in the Blitz rush test:

This is a screenshot of the Nginx status page showing active connections:

This was a screenshot of the output generated by the "Top" command:

This is a screenshot of the PHP-FPM status page:

Now lets see what I have configured Nginx, PHP-FPM, MySQL and sysctl.conf file.

/etc/nginx/nginx.conf:

user nginx;worker_processes 8;error_log /var/log/nginx/error.log warn;pid /var/run/ nginx.pid;worker_rlimit_nofile 150000; events {  worker_connections 150000;   multi_accept on;  use epoll;}  http {    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 /var/log/nginx/access.log  main;     sendfile on;    tcp_nopush on;     keepalive_timeout 65;    reset_timedout_connection on;     types_hash_max_size 2048;    server_tokens off;     server_names_hash_bucket_size 256;    client_max_body_size 32k ;     client_body_buffer_size 32k;    client_body_in_single_buffer  on;    client_body_timeout 180s;    client_header_timeout  180s;    client_header_buffer_size 32k;    large_client_ header_buffers 4 32k;     include /etc/nginx/conf.d/*.conf;}

/etc/nginx/fastcgi_params:

... # Custom parametersfastcgi_connect_timeout 180s;fastcgi_send_timeout 600s;fastcgi_read_timeout 600s;fastcgi_ Intercept_errors on;fastcgi_max_temp_file_size 0;fastcgi_pass 127.0.0.1:9000;fastcgi_param SCRIPT_FILENAME $ Document_root$fastcgi_script_name;fastcgi_index index.php;

/etc/php5/fpm/pool.d/www.conf:

... listen = 127.0.0.1:9000pm = Staticpm.max_children = 4000pm.max_requests = 50000 ...

/etc/sysctl.conf:

Fs.file-max = 150000net.core.netdev_max_backlog=32768net.core.optmem_max=20480#net.core.rmem_default=65536# net.core.rmem_max=16777216net.core.somaxconn=50000#net.core.wmem_default=65536#net.core.wmem_max= 16777216net.ipv4.tcp_fin_timeout=120#net.ipv4.tcp_keepalive_intvl=30#net.ipv4.tcp_keepalive_probes=3# Net.ipv4.tcp_keepalive_time=120net.ipv4.tcp_max_orphans=262144net.ipv4.tcp_max_syn_backlog=524288net.ipv4.tcp_ max_tw_buckets=524288#net.ipv4.tcp_mem=1048576 1048576 2097152#net.ipv4.tcp_no_metrics_save=1net.ipv4.tcp_orphan _retries=0#net.ipv4.tcp_rmem=4096 16384 16777216#net.ipv4.tcp_synack_retries=2net.ipv4.tcp_syncookies=1# net.ipv4.tcp_syn_retries=2#net.ipv4.tcp_wmem=4096 32768 16777216

/ETC/MYSQL/MY.CNF:

# generated by percona configuration wizard  (http://tools.percona.com/)   version rel5-20120208 [mysql] # client  #port                              = 3306socket                          = /var/run/mysqld/ mysqld.sock [mysqld] # general  #user                             =  mysqldefault-storage-engine         = innodbsocket                           = /var/run/mysqld/mysqld.sockpid-file                        = /var/run/mysqld/ mysqld.pidtmpdir                          = /tmp # myisam # key-buffer-size                 = 32Mmyisam-recover                  = FORCE,BACKUP # SAFETY  #max-allowed-packet              = 16Mmax-connect-errors              = 1000000skip-name-resolvesysdate-is-now                  = 1innodb                          =  Forceinnodb-strict-mode             = 1  # DATA STORAGE  #datadir                          = /var/lib/mysql #  CACHES AND LIMITS  #tmp-table-size                  = 32Mmax-heap-table-size             = 32Mquery-cache-type                = 0query-cache-size                = 0max-connections                 = 15000thread-cache-size               = 50open-files-limit                = 65535table-definition-cache          = 1024table-open-cache                = 2048 # INNODB  #innodb-flush-method             = O_DIRECTinnodb-log-files-in-group       = 2innodb-log-file-size            = 128Minnodb-flush-log-at-trx-commit = 2innodb-file-per-table         &nbSp; = 1innodb-buffer-pool-size        = 1456minnodb_ Fast_shutdown           = 0 # logging   #log-error                       = /var/log/mysql/mysql-error.loglog-queries-not-using-indexes   = 0slow-query-log                  = 1slow-query-log-file             = /var/log/mysql/mysql-slow.log # reduce memory usage # Performance_schema             = 0

Finally, this is the screenshot of the Blitz Rush test results:

As can see, the test generated 344,447 successful hits in 60.00 seconds and it transferred 3.39 GB o F data in and out of our PHP Web page (that is involved queries to our database of 100K rows). The average hits rate is 5,740.78/second translates to about 496,003,680 Hits/day.

This is a screenshot of the hits rate graph:

This is a screenshot of the responses time:

Contact me if you have any questions.

Stay Updated

    • Receive News Directly on Your Email

    • Become a Fan on our Facebook Page

    • Subscribe to RSS Feeds

Other Posts

    • 1 billion hits/day with Nginx + php5-fpm + MySQL

    • Building a simple multilingual PHP website

    • New wave of spam emails that spread Zbot Trojan

    • SMTP error:password Command failed:534-5.7.14

    • Automatically close alert message on Twitter Bootstrap

    • How to use MySQL LOAD DATA LOCAL INFILE

    • Flush and clear cached memory in Linux server

    • Import large bulk of data into MySQL InnoDB

Random Posts

    • Million hits/day with Nginx + php-fpm + MySQL

    • Fix the Nginx 504 Gateway Timeout

    • Optimize Linux sysctl.conf Parameters

    • Connect () to Unix:/var/run/php5-fpm.sock failed

    • Configure Fastcgi_cache for WordPress and Nginx

    • Enable Nginx Status Page

    • Configure php-cgi without spawn-fcgi

    • 111 Connection refused while connecting to upstream

This entry is posted in Nginx and tagged Blitz io test, Blitz site test, concurrent connections, Nginx benchmark, Nginx C OnCurrent connections on February 23, 2014.Post Navigation ← Fix The Nginx 504 Gateway Timeout Free World flags icon sets →

Search for:

Categories
    • Apache (8)

    • Free Icons (1)

    • Htaccess (6)

    • LIGHTTPD (9)

    • Linux (55)

    • Microsoft Windows (12)

    • MySQL (21)

    • Nginx (19)

    • Raspberry Pi (7)

    • Uncategorized (18)

    • WordPress (21)

Recent Posts
    • Check if Hardware DEP is enabled on Windows OS

    • Check if PAE is enabled on Windows 7

    • XenServer VM Virtual disk could not being found

    • Create A screenshot of a website with PHP

    • Css3pie Basic Usage

    • JQuery $ (document). Ready (function ()

    • Check if Bootstrap modal is already open

    • Delay Display of Bootstrap 3 modal after click

    • WordPress get Page ID outside the Loop

    • PHP ReadFile () corrupted ZIP file

    • Fixed height and vertical scrollbar on Syntaxhighlighter evolved

    • Organize uploads folder by Post ID, Slug, Author, Media Type

    • Use META tags to disable caching in Web browsers

    • Enable DEP and ASLR on a Delphi XE executable

    • Automate Code Signing with Innosetup

Proudly powered by WordPress


PHP-FPM nginx.conf

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.