목차
System Administration Tips, Security, Internet
Stay Updated
Other Posts
Random Posts
Post navigation
Categories
Recent Posts

php-fpm nginx.conf

Jun 23, 2016 pm 01:43 PM

Query Admin

System Administration Tips, Security, Internet

Skip to content

Home

About Me

500 Million hits/day with Nginx + PHP-FPM + MySQL

I have recently registered to blitz.io, a very interested cloud service which allows users to stress-test a web server simulating up to 50K concurrent connections, with the possibility to specify different regions to originate requests, the HTTP method, the timeout and much more. This service can help to 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 and the results are very promising as the server handled more than 10,000 concurrent connections with an average CPU usage of 50% / 65%.

The dedicated server has the following hardware specs: Intel Xeon E3 1230v3 (4 cores 8 threads at 3.3 GHz), 32 GB DDR3 ECC, 120 GB SSD, 300 Mbit/s Bandwidth. The Nginx version used is 1.4.5-stable, the MySQL (Percona Server) version used is 5.6.15-63.0 and the PHP-FPM version used 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 have 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 is a screenshot of the output generated by the “top” command:

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

Now lets see how 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          = 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 you can see, the test generated 344,447 successful hits in 60.00 seconds and it transferred 3.39 GB of data in and out of our PHP web page (that involved queries to our database of 100K rows). The average hit rate of 5,740.78/second translates to about 496,003,680 hits/day.

This is a screenshot of the hit 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

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

500 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 was posted in Nginx and tagged blitz io test, blitz site test, concurrent connections, nginx benchmark, nginx concurrent 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 be 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


본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

Video Face Swap

Video Face Swap

완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

뜨거운 도구

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

JWT (JSON Web Tokens) 및 PHP API의 사용 사례를 설명하십시오. JWT (JSON Web Tokens) 및 PHP API의 사용 사례를 설명하십시오. Apr 05, 2025 am 12:04 AM

JWT는 주로 신분증 인증 및 정보 교환을 위해 당사자간에 정보를 안전하게 전송하는 데 사용되는 JSON을 기반으로 한 개방형 표준입니다. 1. JWT는 헤더, 페이로드 및 서명의 세 부분으로 구성됩니다. 2. JWT의 작업 원칙에는 세 가지 단계가 포함됩니다. JWT 생성, JWT 확인 및 Parsing Payload. 3. PHP에서 인증에 JWT를 사용하면 JWT를 생성하고 확인할 수 있으며 사용자 역할 및 권한 정보가 고급 사용에 포함될 수 있습니다. 4. 일반적인 오류에는 서명 검증 실패, 토큰 만료 및 대형 페이로드가 포함됩니다. 디버깅 기술에는 디버깅 도구 및 로깅 사용이 포함됩니다. 5. 성능 최적화 및 모범 사례에는 적절한 시그니처 알고리즘 사용, 타당성 기간 설정 합리적,

세션 납치는 어떻게 작동하며 PHP에서 어떻게 완화 할 수 있습니까? 세션 납치는 어떻게 작동하며 PHP에서 어떻게 완화 할 수 있습니까? Apr 06, 2025 am 12:02 AM

세션 납치는 다음 단계를 통해 달성 할 수 있습니다. 1. 세션 ID를 얻으십시오. 2. 세션 ID 사용, 3. 세션을 활성 상태로 유지하십시오. PHP에서 세션 납치를 방지하는 방법에는 다음이 포함됩니다. 1. 세션 _regenerate_id () 함수를 사용하여 세션 ID를 재생산합니다. 2. 데이터베이스를 통해 세션 데이터를 저장하십시오.

확실한 원칙과 PHP 개발에 적용되는 방법을 설명하십시오. 확실한 원칙과 PHP 개발에 적용되는 방법을 설명하십시오. Apr 03, 2025 am 12:04 AM

PHP 개발에서 견고한 원칙의 적용에는 다음이 포함됩니다. 1. 단일 책임 원칙 (SRP) : 각 클래스는 하나의 기능 만 담당합니다. 2. Open and Close Principle (OCP) : 변경은 수정보다는 확장을 통해 달성됩니다. 3. Lisch의 대체 원칙 (LSP) : 서브 클래스는 프로그램 정확도에 영향을 미치지 않고 기본 클래스를 대체 할 수 있습니다. 4. 인터페이스 격리 원리 (ISP) : 의존성 및 사용되지 않은 방법을 피하기 위해 세밀한 인터페이스를 사용하십시오. 5. 의존성 반전 원리 (DIP) : 높고 낮은 수준의 모듈은 추상화에 의존하며 종속성 주입을 통해 구현됩니다.

시스템 재시작 후 UnixSocket의 권한을 자동으로 설정하는 방법은 무엇입니까? 시스템 재시작 후 UnixSocket의 권한을 자동으로 설정하는 방법은 무엇입니까? Mar 31, 2025 pm 11:54 PM

시스템이 다시 시작된 후 UnixSocket의 권한을 자동으로 설정하는 방법. 시스템이 다시 시작될 때마다 UnixSocket의 권한을 수정하려면 다음 명령을 실행해야합니다.

phpstorm에서 CLI 모드를 디버그하는 방법은 무엇입니까? phpstorm에서 CLI 모드를 디버그하는 방법은 무엇입니까? Apr 01, 2025 pm 02:57 PM

phpstorm에서 CLI 모드를 디버그하는 방법은 무엇입니까? PHPStorm으로 개발할 때 때때로 CLI (Command Line Interface) 모드에서 PHP를 디버그해야합니다 ...

PHP에서 늦은 정적 결합을 설명하십시오 (정적 : :). PHP에서 늦은 정적 결합을 설명하십시오 (정적 : :). Apr 03, 2025 am 12:04 AM

정적 바인딩 (정적 : :)는 PHP에서 늦은 정적 바인딩 (LSB)을 구현하여 클래스를 정의하는 대신 정적 컨텍스트에서 호출 클래스를 참조 할 수 있습니다. 1) 구문 분석 프로세스는 런타임에 수행됩니다. 2) 상속 관계에서 통화 클래스를 찾아보십시오. 3) 성능 오버 헤드를 가져올 수 있습니다.

PHP의 CURL 라이브러리를 사용하여 JSON 데이터가 포함 된 게시물 요청을 보내는 방법은 무엇입니까? PHP의 CURL 라이브러리를 사용하여 JSON 데이터가 포함 된 게시물 요청을 보내는 방법은 무엇입니까? Apr 01, 2025 pm 03:12 PM

PHP 개발에서 PHP의 CURL 라이브러리를 사용하여 JSON 데이터를 보내면 종종 외부 API와 상호 작용해야합니다. 일반적인 방법 중 하나는 컬 라이브러리를 사용하여 게시물을 보내는 것입니다 ...

See all articles