Returning to PHP development after an extended break, I encountered an unexpected latency issue in my WAMP environment. Simple requests that previously executed instantly now take 5+ seconds to serve a basic 300B HTML page, despite minimal CPU usage (0-2%) and idle Apache processes.
First, verify your WAMP components:
// Check running services
netstat -ano | findstr :80
tasklist /svc | findstr httpd
wmic process where name="httpd.exe" get CommandLine
Modern Apache installations often include DNS lookups that can introduce latency. Check your httpd.conf
:
# Disable reverse DNS lookups
HostnameLookups Off
# Add this to prevent delays
EnableMMAP off
EnableSendfile off
For WAMP on Windows, these adjustments help:
# In httpd.conf
AcceptFilter http none
AcceptFilter https none
# Adjust thread priority
Win32DisableAcceptEx
Inspect php.ini
for problematic settings:
; Disable unnecessary modules
disable_functions = "pcntl_alarm,pcntl_fork,pcntl_waitpid"
; Adjust realpath cache
realpath_cache_size = 256k
realpath_cache_ttl = 600
Windows TCP stack settings affect localhost performance:
# Run in elevated CMD
netsh int tcp set global autotuninglevel=restricted
netsh interface ipv4 set dynamicport tcp start=49152 num=16384
For WAMP users, try these additional steps:
- Right-click WAMP icon → Tools → Reinstall services
- Check "Put Online" status
- Test with different PHP versions
Add this to php.ini
for profiling:
[xdebug]
xdebug.profiler_enable_trigger = 1
xdebug.profiler_output_dir = "c:/wamp/tmp"
xdebug.profiler_output_name = "cachegrind.out.%t"
Verify if the issue is Apache-specific:
# Test raw TCP response time
echo -e "GET / HTTP/1.1\\r\\nHost: localhost\\r\\n\\r\\n" | nc localhost 80
# Or using PowerShell:
Measure-Command { Invoke-WebRequest http://localhost }
- Verify hosts file entry:
127.0.0.1 localhost
- Disable IPv6 in Apache if unused
- Check for conflicting .htaccess rules
- Test with fresh virtual host configuration
After returning to my WAMP development environment following an extended break, I encountered a perplexing issue: simple PHP pages that should load instantly were taking 5+ seconds to respond, despite minimal system resource usage. The symptoms were particularly puzzling:
- 300B HTML files taking 5 seconds to serve
- Apache httpd processes showing 0% CPU usage
- Overall system load at 0-2%
First, I verified the basic configuration wasn't causing the delay:
# Check if this is a DNS resolution issue
ping localhost
# Test raw Apache response time without PHP
curl -I http://localhost/test.html
When these basic tests confirmed the latency was specific to PHP processing, I dug deeper into the WAMP stack configuration.
These are the most frequent causes I've encountered for localhost latency issues:
- IPv6 vs IPv4 resolution: Windows sometimes prefers IPv6 for localhost
- Apache/PHP module configuration: Especially with newer PHP versions
- Windows hosts file issues
- XDebug or other debugging tools inadvertently enabled
After extensive testing, the solution was in the Windows hosts file. Here's how to implement it:
# Open Notepad as administrator
# Edit C:\Windows\System32\drivers\etc\hosts
# Ensure these lines exist and are uncommented:
127.0.0.1 localhost
::1 localhost
Additionally, I modified my httpd.conf with these performance tweaks:
# In Apache httpd.conf
EnableMMAP off
EnableSendfile off
HostnameLookups off
# For PHP (php.ini)
realpath_cache_size = 4096K
realpath_cache_ttl = 600
opcache.enable=1
To test if the changes worked, I created a simple benchmark script:
<?php
$start = microtime(true);
echo "Test response";
$end = microtime(true);
file_put_contents('perf.log', ($end-$start).PHP_EOL, FILE_APPEND);
?>
After implementing these changes, response times dropped from 5000ms to consistent sub-10ms performance.
For developers wanting to squeeze every millisecond from their WAMP setup:
- Disable unused Apache modules (mod_rewrite, mod_ssl if not needed)
- Adjust ThreadsPerChild and MaxRequestWorkers in httpd-mpm.conf
- Set PHP's realpath_cache_size appropriately for your project size
- Consider using WAMP alternatives like Laragon for better performance
The key takeaway: localhost slowness is almost always a configuration issue rather than a hardware limitation, even when system metrics don't immediately reveal the cause.