
max_requests in PHP-FPM (FastCGI Process Manager) is an important part in making sure that PHP-powered apps work smoothly and quickly, especially on websites or APIs with a lot of traffic. It is one of the most important yet often ignored directives in PHP-FPM.
If you’ve ever had weird issues, slowdowns, or memory leaks that go away after restarting a service, your max_requests setting probably needs to be changed.
It’s important to make sure that your blog, eCommerce site, or web app runs smoothly all the time. One important element of that is fine-tuning PHP-FPM, especially the max_requests directive.
We’ll show you everything you need to know about PHP-FPM’s max_requests in this tutorial, including why it’s important and how to set it up appropriately so that your server runs smoothly and reliably.
What is PHP-FPM?
PHP-FPM stands for PHP FastCGI Process Manager. It is a modern and effective way to handle PHP processes. PHP-FPM runs worker processes in the background that handle incoming PHP requests more faster than launching a new PHP process for each request (which is slow).
What does max_requests mean in PHP-FPM?
The max_requests option tells PHP-FPM how many requests a single child process may handle before it is safely destroyed and restarted.
- It’s a safety mechanism.
- It helps prevent memory leaks or misbehaving scripts from degrading performance over time.
So, when a worker reaches the max_requests limit, it gets recycled, which is like saying, “You’ve done enough for now; let’s give you a break.”
Why is max_requests Important?
You might think, “Why restart a perfectly working process?”
The reason is long-term reliability. Over time, PHP processes can accumulate memory bloat or errors. Restarting them at regular intervals ensures:
- Memory usage stays in check
- Old, faulty processes are cleared out
- Improved uptime and server stability
This is especially helpful for high-traffic websites and applications.
Default Behavior of max_requests
By default, max_requests is set to 0, which indicates that a PHP-FPM worker process will keep operating until it is actively restarted or crashes.
Sounds like risky, right? That’s why most production environments should change this parameter.
When is it time to change max_requests?
You should consider adjusting max_requests when:
- You’re running a high-traffic website
- You observe memory usage increasing over time
- Your server is returning frequent 502/504 errors
- You experience performance degradation during long uptimes
Not all servers are the same, so your ideal number might differ.
How to Check Your Current PHP-FPM Configuration
Before changing anything, let’s check your current setup:
grep max_requests /etc/php/*/fpm/pool.d/*.conf
Or if you’re using ServerAvatar, you can find it in the PHP settings section of your application dashboard under your server dashboard section.
Recommended Values for max_requests
There is no one-size-fits-all number, but here are some general guidelines:
Server LoadRecommended ValueLow Traffic | 300 – 500Medium Traffic | 400 – 700High Traffic | 800 – 1000Debugging Mode | 50 – 100
Server Load | Recommended Value |
---|---|
Low Traffic | 300 – 500 |
Medium Traffic | 400 – 700 |
High Traffic | 800 – 1000 |
Debugging Mode | 50 – 100 |
When testing for memory leaks or isolating bugs, you might set it very low (e.g., 50), so processes are constantly recycled and don’t accumulate stale memory.
Step-by-Step: How to Configure max_requests
Here’s how to update the setting manually on your server:
Step 1: Open PHP-FPM configuration file using below command:
sudo nano /etc/php/8.1/fpm/pool.d/www.conf
- This is the path of the main configuration file for the default PHP-FPM pool, usually named www.
- This file controls how PHP-FPM manages child processes, timeouts, limits, etc.
Replace 8.1 with your actual installed PHP version (e.g., 7.4, 8.2, etc.)
If you’re unsure about your PHP version run the below command to check your PHP version:
php -v
Step 2: Find or add the pm.max_requests line:
Inside the www.conf file, look for a line like this:
pm.max_requests = 500
If the line exists:
- Just modify the number (e.g., change from 100 to 500).
If it doesn’t exist:
- Add it manually, preferably near other pm. directives, like this
pm = dynamic
pm.max_children = 10
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.max_requests = 500
This tells PHP-FPM to restart a child process after it handles 500 requests, helping to free memory and prevent memory leaks from long-running or buggy PHP scripts.
Step 3: Save and exit Nano editor
Inside nano editor:
- Press Ctrl + X to exit Nano.
- Enter “Y” to save changes.
- Press Enter to confirm.
Step 4: Restart PHP-FPM
sudo systemctl restart php8.1-fpm
- Replace php8.1-fpm with your system’s php version (e.g., php7.4-fpm, php8.2-fpm, etc.)
- You can confirm the version to restart it properly by using the command below:
systemctl status php8.1-fpm
Using ServerAvatar to Simplify Configuration
If all of this sounds a bit too technical, don’t worry, ServerAvatar makes it much easier.
With ServerAvatar, you can easily:
Step 1: Access Your Application Dashboard
- Navigate to the Server Dashboard in which your application is hosted.
- Go to the Applications section, and click on the application dashboard icon next to the application for which you want to change the PHP-FPM max_requests.

Step 2: Open PHP Settings
- Navigate to the PHP Settings, and scroll down to the PHP Process Manager section.
Step 3: Update the Max Requests Value
- You can see the “Max Requests” field under the PHP Process Manager section.
- Change it and set it as per your requirements and click on the “Update Settings” button.

- That’s it! This is how easily we can set the “PHP-FPM max_requests” for your application from ServerAvatar.
- No terminal commands. No stress.

Testing Your New Configuration
After updating, you can:
Monitor memory usage over time to know whether your “max_requests” configuration is effective. You can use the following commands or tools:
Interactive system monitor
htop
Process monitoring tool
top
Service-level health
systemctl status php8.2-fpm
Check PHP-FPM logs:
sudo tail -f /var/log/php8.1-fpm.log
Run load tests if needed to simulate real traffic
Best Practices for Setting max_requests
- Begin with a number between 300 and 500.
- Watch how much memory and CPU are being used
- Change depends on how the app works and how much traffic it gets.
- If you experience RAM bloat, lower the setting.
- For PHP apps with a lot of memory or bugs, use settings that are a little lower.
- After making changes, restart the PHP-FPM service.
- Check it out before using it in production
Common Mistakes to Avoid
- Putting it too high: makes recycling pointless
- If you leave it at 0, it can cause memory leaks over time.
- Not restarting PHP-FPM after making changes
- Copying and copying from web tutorials without checking to see if they work for your situation
Not all servers are the same. There isn’t one number that fits all.
Other Ways to Improve Performance Besides max_requests
- Turn on OPcache to make PHP run faster.
- For optimal performance, use nginx with PHP-FPM instead of Apache.e
- Keep PHP up to date to get the most out of new features.
- Optimize your application code
- Use a CDN (content delivery network)
- max_requests is only one part of the performance puzzle.
FAQs
1. How much should pm.max_requests be?
Between 300 and 500 is a reasonable place to start, but it truly depends on your app and how much traffic it gets. Keep observing your server and make the necessary changes.
2. Will reducing max_requests make things run better?
Not always. Recycling memory-hungry programs will make things more stable, but if the setting is too low, it could make the CPU work harder because processes would have to restart more often.
3. Is it possible to use ServerAvatar to specify max_requests?
Yes! You can change the PHP-FPM settings from the ServerAvatar dashboard. You don’t have to edit config files by hand.
4. Is it okay to keep max_requests at 0?
Maybe for servers that don’t last long or are still being built. But in production environments, it’s dangerous because memory leaks could happen.
5. Do I have to restart PHP-FPM once I change max_requests?
Yes, for sure. You need to restart PHP-FPM for the changes to take effect.
Conclusion:
One of the easiest and most effective ways to keep your server stable over time is to set the max_requests option in PHP-FPM. Recycling PHP processes on a regular basis keeps memory use in check and helps prevent crashes or 502 errors, whether you’re using a lightweight CMS or a Laravel app with a lot of traffic.
If you set max_requests correctly, your server won’t crash, burn out, or slow down over time. It’s a simple setting that may have a big effect, and ServerAvatar makes it easier than ever.
ServerAvatar can make it even easier to manage many servers by giving you a dashboard that lets you change settings like “max_requests” without having to open config files.
Keep in mind that it’s not about setting it and forgetting it. Keep an eye on things, test them, and make changes based on how they work in the actual world.