Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk10 min

How to Optimize RAM Usage for Apache and a LAMP Stack

Reduce LAMP memory pressure by measuring real process RSS, separating PHP with PHP-FPM, capping Apache and FPM concurrency, and reserving MySQL and OS headroom.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Optimize a LAMP server’s RAM by measuring the real resident memory of Apache, PHP-FPM, MySQL and the operating system, then setting concurrency limits so their combined peak stays below physical RAM with headroom. In practice, that means choosing an appropriate Apache MPM, separating PHP into PHP-FPM, sizing Apache’s MaxRequestWorkers and PHP-FPM’s pm.max_children from observed usage, and reserving memory for MySQL, the kernel, filesystem cache and traffic spikes.

There is no reliable universal “RAM per Apache worker” number. A WordPress request, a file download and a database-heavy application can have very different footprints. The safe configuration is the one derived from your workload and then verified under representative concurrency without swapping.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why RAM, not CPU, usually sets your concurrency ceiling

Every request consumes some combination of Apache process or thread memory, PHP worker memory, database connection memory and kernel or filesystem-cache memory. More simultaneous requests therefore create a concurrency problem even when average CPU utilization looks comfortable. If the combined demand exceeds physical RAM, Linux starts reclaiming aggressively or swapping; latency rises sharply and the machine can become unstable.

Apache’s own performance guidance calls RAM “the single biggest hardware issue affecting webserver performance.” Treat that as a sizing constraint rather than a reason to buy memory blindly: first measure the resident set size (RSS) of each component during a representative peak, then cap the number of concurrent workers that can exist at once.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

A practical memory budget

Write down the machine’s physical RAM and reserve space for the kernel, filesystem cache, SSH, monitoring agents and short-lived bursts. From the remainder, reserve the measured peak for MySQL, the measured peak for Apache and a separate allowance for PHP-FPM. The limits must fit simultaneously; increasing one pool without reducing another can turn a healthy configuration into a swapping system.

Use observed RSS, not a product’s theoretical maximum, for the normal calculation. Keep an explicit safety margin because RSS varies with URLs, extensions, opcode caches, uploads, report generation and other exceptional requests.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Measure before changing a directive

Capture a baseline during ordinary traffic and during the busiest period you can reproduce. Record total RAM, swap activity, CPU load, the active Apache MPM, Apache process or thread usage, PHP-FPM child RSS, MySQL RSS and peak in-flight requests.

  1. Check physical memory and swap: run free -h, then watch pressure with vmstat 1. Sustained swap-in or swap-out during traffic is a warning that concurrency is too high or a process is retaining memory.
  2. Find the largest processes: run ps -eo pid,comm,rss,args --sort=-rss | head -n 30. RSS is shown in KiB; group Apache, PHP-FPM and the MySQL server rather than judging a single process in isolation.
  3. Identify the MPM: use apachectl -V and inspect the loaded modules with apachectl -M. Confirm whether the server is using prefork, worker or event and whether PHP is embedded with mod_php.
  4. Inspect PHP-FPM: check the service status and pool configuration, then sample child RSS while the site handles representative PHP requests. A quiet period can substantially understate peak child memory.
  5. Measure database demand: sample the MySQL process and record active and maximum connections during the same window. A database-only tuning profile can leave too little RAM for the web tier.
  6. Record application concurrency: note requests per second, in-flight requests, response latency and the busiest URLs. A short burst can require more workers than the hourly average.

Keep the measurements with a timestamp and the workload description. Compare later changes against equivalent traffic windows; otherwise a quieter or busier period can be mistaken for an improvement.

Choose an Apache MPM and separate PHP from Apache

For a new deployment, use PHP-FPM behind Apache’s mod_proxy_fcgi. The PHP documentation explicitly says, “Do not use mod_php for new installations.” PHP-FPM places PHP workers in their own pool, allows PHP to restart independently, improves process isolation and works with Apache’s event MPM.

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

Prefork

Prefork creates one process per active request slot. It is generally required when a non-thread-safe PHP build is loaded directly with mod_php. Each process carries a comparatively large private PHP footprint, so the number of simultaneous requests that fit in RAM is often lower than with a threaded MPM. If prefork is unavoidable, Apache recommends making the worker limit large enough for expected simultaneous requests but small enough that all processes remain in physical RAM and do not thrash.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Worker

Worker uses multiple threads in each process. Threads share process memory, so its footprint can be smaller than prefork, but every thread still needs stack and request state. Verify that every loaded module is thread-safe before selecting it.

Event

Event is a threaded MPM designed to avoid tying up a main request thread while some keep-alive or connection-management work can be handled by supporting threads. It is normally the best fit for Apache front ends that pass PHP requests to PHP-FPM through mod_proxy_fcgi. It is not a drop-in choice for an installation that embeds a non-thread-safe PHP module.

MPM Memory model PHP implication Operational trade-off
prefork One child process per request slot; private process memory is the dominant cost. Works with typical non-thread-safe mod_php deployments. Simple compatibility, but usually the highest RAM cost at concurrency.
worker Multiple threads share a process, reducing duplicated memory compared with prefork. Requires thread-safe modules; PHP-FPM avoids embedding PHP in Apache. Higher potential concurrency per GB, subject to module compatibility.
event Threaded model that delegates some connection handling to supporting threads. Pairs with PHP-FPM and mod_proxy_fcgi; unsuitable for a non-thread-safe embedded PHP module. Efficient handling of keep-alive connections with isolated PHP restarts.

Remove modules the site does not use. Apache’s performance guidance notes that commenting out unused LoadModule directives can reduce memory consumption. Test one module change at a time and keep a rollback copy of the configuration.

Set Apache’s hard concurrency cap

MaxRequestWorkers is Apache’s primary safety limit. In prefork it is the maximum number of child processes. In worker and event it is the total number of request-processing threads. Once the limit is reached, additional requests wait in Apache’s queue until a slot becomes available.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Derive the value from measured memory

Estimate an Apache allowance after reserving PHP-FPM, MySQL, the operating system and headroom. For prefork, divide that allowance by the measured peak RSS of an Apache child under representative requests. For worker or event, measure the shared process footprint and the incremental memory associated with active threads; do not assume a thread costs as much as a complete prefork process.

Choose a rounded-down value that keeps the sum below physical RAM during the observed peak. Recheck it after enabling modules, changing TLS settings, increasing logging or deploying an application that alters request size.

Do not inflate ServerLimit

ServerLimit controls the maximum process capacity that Apache can allocate for prefork or threaded MPMs. Setting it “just in case” can allocate unused shared memory. Apache warns that setting ServerLimit and MaxRequestWorkers beyond what the system can support can prevent Apache from starting or make the host unstable. Raise ServerLimit only when the chosen worker limit genuinely requires it, and restart Apache deliberately after the change.

Example calculation (illustrative, not a benchmark)

Suppose measurements leave 1,200 MiB for Apache after the OS, MySQL, PHP-FPM and safety headroom are reserved, and a prefork child uses 24 MiB RSS at the representative peak. The arithmetic is floor(1,200 / 24) = 50, so a starting MaxRequestWorkers of 50 is defensible. It is not a universal recommendation: a different application or traffic mix will produce a different measured child size and therefore a different limit.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Size PHP-FPM pools independently

PHP-FPM limits simultaneous PHP execution separately from Apache. The key directive, pm.max_children, is the maximum number of child processes for dynamic and ondemand pools, and the fixed child count for a static pool.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

Choose the process manager

Mode How workers are created RAM and latency behavior Best fit
ondemand Creates children only when requests arrive. Lowest idle-RAM footprint; a quiet pool can incur cold-start latency when a worker must be created. Quiet or bursty sites where conserving idle memory matters.
dynamic Maintains configured spare workers and grows up to pm.max_children. Balances warm-worker latency against a bounded pool; idle workers consume memory. Most general-purpose sites with a reasonably steady workload.
static Keeps exactly the configured number of children. Most predictable concurrency and RAM reservation; all children remain allocated. Stable, well-measured workloads with enough RAM for the fixed pool.

Calculate pm.max_children

Use the RAM remaining after Apache, MySQL and the OS are reserved. Divide that amount by the observed peak RSS of one PHP-FPM child, then round down and retain a safety margin. The planning expression is:

pm.max_children = floor(PHP RAM allowance / measured peak child RSS)

Do not multiply PHP’s memory_limit directly by the child count. memory_limit is a per-script ceiling, not a promise that every worker reaches that amount, and many requests use far less. Conversely, a single request can approach the ceiling, so measure real child RSS and account for the application’s heaviest legitimate paths.

Recycle children that retain memory

Set pm.max_requests to recycle a child after it has served a defined number of requests when third-party code or an extension leaks memory. PHP documents this directive as a way to work around leaks. Recycling limits the damage but does not identify or repair the leaking extension or application path; investigate a steadily growing RSS trend separately.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep Apache and FPM limits compatible

If Apache can accept far more PHP requests than the FPM pool can execute, requests queue at the FastCGI boundary and latency rises. If FPM allows more children than the RAM budget supports, PHP can push the entire host into swap even while Apache appears healthy. Set both limits from the same memory budget, then observe queueing and response times.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Use PHP’s memory_limit as a per-request guardrail

The current PHP core configuration documentation lists a default memory_limit of 128M. It limits the memory a script may allocate; it does not cap the RSS of the whole PHP process or account for Apache and MySQL.

Lowering the value can protect a small host from runaway scripts, but an overly low limit produces application errors during image processing, imports, report generation or large framework operations. Change it only after identifying the application’s legitimate peak request needs, deploy gradually and inspect PHP and web-server logs for “allowed memory size” failures.

Coordinate MySQL with the web tier

A shared LAMP host cannot use the same database profile as a dedicated MySQL server. Reserve the measured Apache and PHP peaks first, then fit MySQL’s InnoDB buffer pool, connection ceiling and other allocations into the remaining memory. Leave room for connection-specific buffers and traffic spikes rather than allocating nearly all RAM to the buffer pool.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Oracle’s 2025 shape table illustrates why a preset is not portable:

Oracle shape innodb_buffer_pool_size default max_connections default
MySQL.2.16GB 10,737,418,240 bytes 1,000
MySQL.8.64GB 51,539,607,552 bytes 4,000

Those are service-specific examples, not recommendations for a shared web server. A large connection ceiling can permit many simultaneous sessions, while the buffer pool can consume most of the machine before Apache or PHP has room to grow. Set the connection ceiling to the concurrency the application and database can actually serve, and verify that the resulting memory use does not trigger swap.

A safe optimization sequence

  1. Establish a baseline. Capture RAM, swap, process RSS, MPM, FPM children, MySQL RSS, peak concurrency and latency during a known traffic window.
  2. Separate PHP. For a new installation, use PHP-FPM with mod_proxy_fcgi. Confirm that the selected worker or event MPM and every loaded module are compatible.
  3. Remove unused Apache modules. Comment out one unused LoadModule at a time, validate the configuration and restart during a controlled window.
  4. Reserve system and database memory. Account for the kernel, cache, administration tools, MySQL peak and short-lived bursts before calculating web-worker limits.
  5. Set Apache’s cap. Derive MaxRequestWorkers from measured Apache memory. Keep ServerLimit no higher than the capacity the configuration requires.
  6. Set the FPM pool mode and cap. Choose ondemand, dynamic or static, then derive pm.max_children from measured child RSS and the PHP allowance.
  7. Set PHP’s request ceiling. Keep memory_limit high enough for legitimate requests and low enough to catch runaway scripts; validate with application logs.
  8. Recycle if necessary. Use pm.max_requests when child RSS grows over time, while continuing to locate the underlying leak.
  9. Change one limit at a time. Compare equivalent traffic windows and retain the previous configuration so a regression can be reversed quickly.

Verify that the new limits work

Expose the PHP-FPM status page only on an internal address or through an access-controlled monitoring path. PHP’s status information includes queue length, active, idle and total processes, maximum active processes, max children reached, memory peak and per-request memory.

  • Rising queue length or repeated max children reached: the FPM pool is saturated. First check whether requests are unusually slow; then decide whether the application can be optimized or whether the measured RAM budget supports a larger pool.
  • Growing child RSS or memory peak: inspect extensions and application paths for leaks, and use pm.max_requests as a containment measure.
  • Swap activity after raising a limit: lower the most recently increased concurrency cap and recheck Apache, FPM and MySQL peaks together.
  • Apache startup failure: review ServerLimit, MaxRequestWorkers and the error log. Values beyond available process or shared-memory capacity can prevent a safe start.
  • Application memory errors after lowering memory_limit: identify the failing request class and raise the limit only as far as that workload requires.

Pair FPM metrics with operating-system pressure and swap counters, Apache scoreboard or status data, request latency and MySQL process and connection metrics. A configuration is successful when peak traffic remains responsive without swapping and without repeatedly exhausting either Apache or PHP-FPM capacity.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Common mistakes to avoid

  • Using a universal workers-per-gigabyte rule: no official documentation establishes one; process size depends on modules, code and request mix.
  • Multiplying PHP’s memory_limit by every worker: it is a per-script ceiling, not measured worker RSS.
  • Copying a dedicated-MySQL preset: database defaults must leave room for the web tier on a shared host.
  • Raising every limit together: Apache, FPM and MySQL compete for the same physical RAM.
  • Disabling swap without fixing pressure: this can turn recoverable paging into an immediate out-of-memory kill; find and correct the overcommit instead.
  • Changing several settings at once: you lose the ability to attribute an improvement or regression to one cause.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.