Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk11 min

How to Optimize Apache Web Server Performance on a VPS

Optimize Apache on a VPS without guesswork: measure first, select the right MPM, set concurrency from real memory headroom, and validate HTTP/2, compression and caching changes safely.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The safest way to optimize Apache on a VPS is to measure first, then change one group of settings at a time. Record latency percentiles, throughput, errors, CPU, resident memory, swap, connection counts, and application response time. Choose an MPM that your application supports, cap concurrency to the RAM you actually have, tune keep-alive and HTTP/2 deliberately, compress only suitable responses, and add caching without exposing private data.

What Apache optimization on a VPS actually means

Apache performance is a balance between concurrency, memory, CPU, network bytes, connection lifetime, and the work performed by your application. A setting that improves one metric can harm another: more workers may reduce queueing until the VPS starts swapping; stronger compression saves bandwidth but consumes CPU; longer keep-alive reduces connection setup but keeps sockets and worker capacity occupied.

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.

There is no universal “best” Apache configuration or MaxRequestWorkers value. The right settings depend on available RAM and CPU, the active Multi-Processing Module (MPM), PHP or other application runtimes, database connections, traffic mix, TLS, request duration, and upstream services. Apache’s documented defaults are starting points, not performance targets.

Establish a baseline before changing configuration

Make a record that you can reproduce after every change. Use the same representative URLs, request mix, concurrency, cache state, and test duration. A short synthetic test can reveal configuration errors, but it is not a substitute for observing real traffic.

#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.

Record server and application measurements

  • Latency, including median and high percentiles such as p95 and p99.
  • Requests per second or total completed requests.
  • HTTP status codes, especially 4xx, 5xx, and upstream timeout errors.
  • CPU utilization and load average.
  • Apache and application resident memory.
  • Swap-in, swap-out, and whether swap usage grows during the test.
  • Active, idle, and waiting connections.
  • Disk I/O and network saturation.
  • Time spent in the application or upstream service, not only time spent in Apache.

Keep a copy of the current configuration and a documented rollback command. On a systemd distribution, a typical validation and reload sequence is:

sudo apachectl configtest
sudo systemctl reload apache2

The service name may be httpd rather than apache2. Never reload a configuration that has not passed configtest; if a change prevents startup, restore the previous file and run the distribution’s service status and journal commands.

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

Check the build and loaded modules

Distribution packages differ in paths, module names, and compiled defaults. Inspect the running build instead of assuming a guide written for another operating system applies:

apachectl -V
apachectl -M
apachectl -t -D DUMP_RUN_CFG
apachectl -t -D DUMP_VHOSTS

Use the output to identify the active MPM, configuration directory, loaded modules, virtual hosts, and effective runtime values. Only one MPM can be loaded at a time.

Choose the MPM that matches your application

Apache’s MPM controls how it creates processes and threads. The three commonly encountered choices are prefork, worker, and event.

Event MPM

Event is generally the best starting point for a modern, thread-safe stack. It is threaded like worker but is designed to hand some connection-management work to supporting threads, allowing the main request threads to accept new work more efficiently. This is especially useful for many keep-alive connections and HTTP/2 multiplexing.

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.

Event requires that loaded modules and the application runtime be thread-safe. A module that assumes process isolation can make event unsafe or impossible to use. Verify compatibility rather than switching solely because event is newer.

Worker MPM

Worker uses multiple processes, each with multiple threads. It normally has a smaller memory footprint than prefork while retaining process boundaries between groups of threads. It can be appropriate when event is unavailable or when your traffic and module set do not benefit from event’s connection handling.

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 MPM

Prefork uses separate child processes and processes one request at a time per connection. It remains relevant when a required module or embedded runtime is not thread-safe and needs process isolation. The trade-off is a larger memory footprint and less efficient concurrency, particularly with HTTP/2: Apache’s HTTP/2 documentation notes that prefork processes only one HTTP/2 request at a time per connection.

Safe selection procedure

  1. Run apachectl -M and identify the loaded MPM and modules.
  2. List application integrations, such as PHP handlers, authentication modules, and vendor modules, and confirm thread safety in their documentation.
  3. Stage the alternative MPM on a maintenance window or a disposable VPS.
  4. Run apachectl configtest, restart in the staging environment, and exercise dynamic pages, uploads, authentication, background callbacks, and error paths.
  5. Compare memory, latency, errors, and CPU under the same workload before considering production use.

Set MaxRequestWorkers from memory capacity

MaxRequestWorkers limits simultaneous requests. With prefork it limits child processes; with worker and event it limits the total available request threads. Apache explicitly recommends controlling this value so the server does not create so many children that it starts swapping. Swap activity is a clear sign that the concurrency limit is too high for the workload or that another process is consuming the memory budget.

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

Build a memory budget

Start with total RAM, then reserve memory for the operating system, filesystem cache, TLS, monitoring, the application runtime, database clients, queues, and any control-panel services. Measure Apache processes during representative traffic rather than relying on a package estimate. For prefork, inspect several children and use a conservative high-end resident size; for threaded MPMs, account for the parent, child processes, thread stacks, and application libraries.

A practical sequence is:

  1. Measure idle and busy resident memory for Apache and the application.
  2. Set aside a safety margin so normal bursts do not consume all RAM.
  3. Calculate how much memory is available for additional concurrent Apache work.
  4. Increase MaxRequestWorkers gradually while watching swap, p95/p99 latency, and error rates.
  5. Stop increasing when CPU is saturated, latency rises, memory becomes unstable, or swap begins.

Do not treat Apache’s documented defaults as recommendations. A prefork default of 256 and a threaded default calculated as 16 server processes multiplied by 25 threads are build defaults that vary by distribution and version. They may be far above what a small VPS can sustain.

Coordinate ServerLimit and ThreadsPerChild

For worker and event, ServerLimit sets the maximum number of child processes and ThreadsPerChild sets threads per child. Their product must provide at least the configured MaxRequestWorkers; Apache requires threaded values to be at least ThreadsPerChild and recommends integer multiples. Oversized limits reserve unnecessary shared memory, can prevent startup, and make later tuning confusing.

<IfModule mpm_event_module>
    ServerLimit         4
    StartServers        2
    ThreadsPerChild     25
    MinSpareThreads     25
    MaxSpareThreads     75
    MaxRequestWorkers   100
    MaxConnectionsPerChild 0
</IfModule>

The numbers above are an example of internally consistent relationships, not a universal VPS recommendation. Size them from measurements. For prefork, use process-oriented directives and verify the resident size of children before selecting a limit.

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

Tune keep-alive and connection behavior

Keep-alive lets a client reuse a TCP/TLS connection for multiple requests, avoiding repeated handshakes. It is usually beneficial for pages that load many assets, but every open connection consumes resources and can occupy capacity while a client is idle.

KeepAliveTimeout

Apache documents a default KeepAliveTimeout of 5 seconds. That value is a compromise between reducing connection setup and avoiding long resource retention. Lower it when clients hold many idle connections and request bursts are short. A somewhat longer value can help high-latency clients that fetch several assets in sequence. Use access logs, active-connection counts, and tail latency to choose; do not change it in isolation from the MPM.

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

Request timeouts

Review request and proxy timeouts separately from keep-alive. A very long timeout allows slow clients or a stalled upstream to consume concurrency; a very short timeout can terminate legitimate uploads or long-running application requests. Set limits that reflect real upload sizes, upstream response times, and client behavior, then monitor timeout status codes.

Enable HTTP/2 when the complete stack supports it

HTTP/2 can multiplex requests over one TLS connection and reduce connection overhead, but it requires TLS, a build with mod_http2, and an application stack that behaves correctly under multiplexing. Apache’s HTTP/2 guidance identifies event as the preferred MPM when the platform supports it.

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

HTTP/2 checklist

  • Confirm the module is present and enabled with apachectl -M.
  • Ensure the virtual host has a valid certificate and advertises HTTP/2 through the distribution’s supported configuration.
  • Verify negotiation with browser developer tools or a protocol-aware command-line client.
  • Test dynamic requests, streaming, uploads, redirects, and authentication.
  • Watch CPU, active request queues, memory, and error logs after rollout.

Do not assume HTTP/2 automatically makes every page faster. A CPU-constrained VPS, an incompatible module, or a prefork deployment can erase its benefits. Keep a rollback path to HTTP/1.1 if errors or tail latency increase.

Compress text without wasting CPU or exposing secrets

mod_deflate provides a DEFLATE output filter and supports gzip encoding. Target text formats such as HTML, plain text, CSS, JavaScript, XML, and JSON. JPEG, PNG, GIF, most video, archives, and other already-compressed files generally should not be compressed again.

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/css
    AddOutputFilterByType DEFLATE application/javascript application/json
    AddOutputFilterByType DEFLATE application/xml text/xml
</IfModule>

Use the exact MIME types emitted by your application; a rule that lists the wrong type will silently miss responses. Ensure responses include Vary: Accept-Encoding so shared caches keep compressed and uncompressed variants separate. Apache’s module documentation identifies gzip as the compatibility choice for older browsers.

Balance compression level and CPU

Higher compression levels can reduce bytes further but consume more CPU and may increase response time on a small VPS. Begin with a balanced level, measure transfer size and CPU, and test static precompressed assets where your deployment pipeline supports them. Do not compress responses containing secrets or user-specific tokens merely because they are text. Compression over TLS can create information-disclosure risks such as BREACH when an attacker can observe size differences while influencing input. Exclude sensitive responses or redesign them before enabling compression broadly.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

Use browser caching for static assets

mod_expires can emit Expires and Cache-Control: max-age headers. The safest long-lived policy is for fingerprinted assets whose filenames change when their contents change. HTML that changes frequently generally needs a short lifetime or revalidation.

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css "access plus 7 days"
    ExpiresByType application/javascript "access plus 7 days"
    ExpiresByType image/svg+xml "access plus 30 days"
    ExpiresByType image/png "access plus 30 days"
</IfModule>

The example durations are policy examples, not universal values. An access-time base gives each request a fresh period, while a modification-time base ties freshness to the file’s modification time. Choose deliberately and verify the resulting headers with a client. For assets without fingerprinting, shorter lifetimes reduce the risk of serving stale files after a deployment.

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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Consider server-side caching only for public content

mod_cache can avoid regenerating unchanged responses and can provide a substantial benefit when conditional requests are handled correctly. It is not automatically safe for every virtual host.

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

Responses that require special care

  • Session pages, account dashboards, carts, and other personalized responses.
  • Responses containing authorization decisions, private identifiers, or user data.
  • Pages whose output varies by cookie, authorization header, host, or device.
  • Endpoints with side effects, such as form submissions or state-changing API calls.

Apache warns that quick-handler caching can bypass host-based Allow and Deny controls. Never cache private or access-controlled output until cache keys, authorization behavior, invalidation, and failure handling have been explicitly designed and tested. Start with public, immutable assets or clearly public GET responses, then inspect headers and cache hits under multiple users.

Observe Apache while it serves traffic

Enable mod_status only on a protected administrative endpoint. Restrict it by network policy or authentication and do not expose the scoreboard publicly. Use it with access and error logs plus host metrics.

Metrics that reveal bottlenecks

  • Busy versus idle workers and the number of waiting connections.
  • Request-duration percentiles and upstream response time.
  • Status-code distribution and bursts of 408, 429, 500, 502, 503, or 504 responses.
  • Resident memory, swap activity, CPU saturation, and load.
  • Disk latency, file-descriptor pressure, and network throughput.
  • Connection counts by protocol and virtual host.

Correlate timestamps across Apache access logs, error logs, application logs, and system metrics. A rising Apache latency with normal upstream time points to connection, worker, TLS, or I/O pressure; rising upstream time with idle Apache capacity points to the application or database.

A safe optimization workflow

  1. Freeze a baseline. Save configuration, package versions, active modules, and representative measurements.
  2. Fix correctness first. Remove errors, redirect loops, failed upstream connections, and oversized or missing resource limits before chasing speed.
  3. Choose the MPM. Prefer event for a verified thread-safe modern stack; retain prefork when compatibility requires process isolation.
  4. Set a conservative concurrency ceiling. Calculate memory headroom and increase MaxRequestWorkers only while swap and tail latency remain healthy.
  5. Tune connections. Adjust keep-alive and timeout values using observed idle-connection and request-duration patterns.
  6. Enable HTTP/2 if supported. Confirm TLS, module, application, and MPM compatibility, then verify negotiated protocols.
  7. Compress selected content. Exclude already-compressed media and secret-bearing responses; measure CPU and bytes transferred.
  8. Add browser caching. Start with fingerprinted static assets and verify headers.
  9. Add server caching cautiously. Limit it to demonstrably public responses and test authorization boundaries.
  10. Re-run the same workload. Keep the change only if the intended metric improves without unacceptable regressions.
  11. Document and retain rollback. Record the old and new values, observed effects, and the exact command to revert.

Common symptoms and corrective actions

The VPS starts swapping after increasing workers

Reduce MaxRequestWorkers, check application and database memory, and confirm that no unrelated service consumed the remaining RAM. Swapping is not a harmless indication that Apache is using available capacity; it usually increases latency dramatically.

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

CPU reaches saturation after enabling compression

Lower the compression level, narrow the MIME-type rules, exclude large or already-compressed files, and consider precompressed static assets. Compare transfer savings with request CPU and p95 latency.

HTTP/2 increases errors or queueing

Confirm event support, module compatibility, TLS negotiation, and application behavior. Inspect error logs and request queues, then roll back protocol enablement while retaining the baseline for comparison.

Users receive stale or private cached content

Remove the affected cache rule immediately, purge stored objects, and inspect Cache-Control, Vary, cookies, authorization headers, and cache keys. Do not re-enable caching until personalized and access-controlled responses are demonstrably excluded.

Apache will not restart after a tuning change

Run apachectl configtest and read the exact syntax or module error. Check that ServerLimit, ThreadsPerChild, and MaxRequestWorkers are valid for the active MPM, restore the last known-good file, and restart only after validation passes.

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

What a successful result looks like

A successful optimization is not a larger directive value or a single impressive benchmark number. It is a repeatable reduction in the bottleneck that mattered: lower tail latency at the same load, more completed requests before saturation, fewer upstream timeouts, lower network transfer for compressible assets, or less repeated application work from safe caching. Keep the configuration that improves those outcomes while preserving memory headroom, predictable failure behavior, and a simple rollback.

Frequently Asked Questions

What is the best Apache MPM for a VPS?

Event is generally preferred for a modern, thread-safe application stack, especially with HTTP/2 and many keep-alive connections. Worker is a viable threaded alternative. Prefork remains appropriate when a required module or runtime is not thread-safe.

How do I calculate MaxRequestWorkers?

Measure the real resident memory of busy Apache workers, reserve RAM for the OS, application, database clients, TLS, and filesystem cache, then increase the limit gradually while monitoring swap and tail latency. There is no safe value based on VPS RAM alone.

Is Apache’s default KeepAliveTimeout of 5 seconds right for every server?

No. Five seconds is Apache’s documented default and a compromise. Adjust it using idle-connection counts, client latency, request patterns, and available concurrency.

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

Should I enable gzip on a small VPS?

Enable gzip for text responses when the CPU cost is acceptable, but exclude already-compressed media and secret-bearing responses. Measure CPU, transfer bytes, and latency after enabling it.

Can mod_cache cache logged-in pages?

Do not cache logged-in, session-specific, personalized, or authorization-sensitive pages unless you have explicitly designed and tested cache keys, authorization handling, and invalidation.

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
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

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.