Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5965891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:42:18+00:00 2026-05-22T19:42:18+00:00

I am looking for the best way to scale a PHP application under Nginx

  • 0

I am looking for the best way to scale a PHP application under Nginx using PHP-FPM. I am looking at a concurrency of about 1200. Currently, anything over 400 starts to get slow response times. Response size is generally very small, but a few may be fairly large. Request sizes are usually small except for a select few.

Things are fast up until it is under a heavy load. Response times crawl down to anywhere between 2 and 50 seconds. Under a light load, response times vary between 100 and 300 milliseconds.

Server setup is 2 servers. Load balancer in front, PHP-FPM, Nginx and MongoDB on both boxes. One server runs the mongod master and arbiter, the other runs the slave (unless failover occurs). I know best practices with Mongo, but I don’t have enough servers to have dedicated database servers.

There is still quite a bit of ram free and the last 1 minute load average never gets above 0.7. They’re 8 core boxes with 16 gigs of ram each so this shouldn’t be the bottleneck. Mongo isn’t sweating at all and Nginx and PHP-FPM don’t seem to be either. I’ve checked top statistics and MongoDB using db.serverStatus().

My question is, given my concurrency, do my Nginx fastcgi settings look correct, and is there anything else that I may be missing even if it doesn’t have anything to do with Nginx settings?

fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;

Would a low “ulimit -n” slow this down? Mongo uses about 500 to 600 connections when under a heavy load. Ulimit settings are as follows:

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 147456
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 147456
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

FYI, I will be upping “ulimit -n” when load testing for 1200 concurrency.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:42:19+00:00Added an answer on May 22, 2026 at 7:42 pm

    It seems all it took was a little bit of calculations. Since I have 8 cores available, I can generate more nginx worker processes:

    nginx.conf

    worker_processes 4;
    events {
        worker_connections 1024;
    }
    

    And 16gb of ram will give some leg room for a static amount of php-fpm workers.

    php-fpm.conf

    pm = static
    pm.max_children = 4096
    

    The Nginx fastcgi settings stayed the same. I probably have a bit more tweaking todo to as as settings changed, the acceptable concurrency stayed the same while the server load went down, but this seems to do the trick and is at least a starting point.

    A single server seems to handle about 2000 concurrency before the load gets pretty high. ApacheBench starts getting errors around 500 concurrency so testing with AB should be done from multiple servers.

    As David said, ideally this would be written in something that could scale easier, but given the time frame that just isn’t feasible at this point.

    I hope this helps others.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for the best way to log errors in an ASP.NET application. I
I am looking for a best way to trigger windows application automation from Java
I'm looking for the best way to go about forcing the user to fill
I'm looking for the best way to take a simple input: echo -n Enter
I am looking for the best way to test if a website is alive
I'm looking for the best way to tell if an <mx:Image> has already fired
I am looking for the best way to make my desktop java program run
I'm looking for the best way to provide authorization, authentication, and auditing to web
I'm looking for a best way to implement common Windows keyboard shortcuts (for example
I am looking for the best way to check that a database login exists

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.