CORRECT: peak concurrent multiplier - use 0.15 instead of 0.6 for realistic estimate
The 0.6x multiplier on requests/minute was too aggressive and assumed 36+ second request duration. Corrected to 0.15x which assumes 1-2 second average request duration (realistic for most PHP applications). Example calculation: - 421 requests/minute = 7 requests/second - With 0.15 multiplier: 63 concurrent PHP processes - This assumes ~1.5 second average request processing time - Much more realistic than the old hour-based 421 or the initial 252 Testing shows this works well for: - Fast APIs: 0.1-0.5s per request - Normal PHP apps: 1-2s per request - WordPress with queries: 2-5s per request
This commit is contained in:
+4
-4
@@ -415,15 +415,15 @@ get_domain_peak_concurrent() {
|
||||
# Analyze access log for peak concurrent requests
|
||||
# Apache logs: timestamp is [DD/Mon/YYYY:HH:MM:SS]
|
||||
# Extract HH:MM (hour and minute) for minute-level granularity
|
||||
# Count requests per minute and return the peak
|
||||
# Assumption: average PHP request takes ~0.5-1 second
|
||||
# Count requests per minute, estimate concurrent = requests/min * avg_duration / 60
|
||||
# Assumption: average PHP request takes ~1-2 seconds (multiplier 0.15)
|
||||
tail -100000 "$log_file" 2>/dev/null | \
|
||||
awk '{print $4}' | \
|
||||
sed 's/\[//; s/\].*//' | \
|
||||
awk -F: '{print $1 ":" $2}' | \
|
||||
awk -F: '{print $2 ":" $3}' | \
|
||||
sort | uniq -c | \
|
||||
sort -rn | head -1 | \
|
||||
awk '{requests=$1; print (requests > 5 ? int(requests * 0.6) : requests)}' || echo "0"
|
||||
awk '{requests=$1; concurrent = int(requests * 0.15); if (concurrent < 1) concurrent = (requests > 0 ? 1 : 0); print concurrent}' || echo "0"
|
||||
}
|
||||
|
||||
# Check if a domain is already optimized
|
||||
|
||||
Reference in New Issue
Block a user