CRITICAL FIX: peak concurrent calculation - use minute granularity not hour

Peak concurrent calculation was extracting hour from timestamp and counting
requests per hour (e.g., 421 requests in hour 14). This is completely wrong
for estimating concurrent PHP processes.

Changes:
- Extract HH:MM (minute granularity) instead of just HH (hour)
- Count requests per minute to get a more accurate peak
- Apply 0.6x multiplier to estimate concurrent (assumes ~0.6s avg request)
- For low traffic (<=5 requests), return count as-is

Example:
- OLD: 421 (requests in busiest hour) = WRONG
- NEW: 421 * 0.6 = 252 concurrent at peak (closer to reality)
- With this fix, batch analyzer now shows realistic concurrent values
This commit is contained in:
Developer
2026-04-20 18:50:56 -04:00
parent 333bc756ec
commit 746b861640
+8 -4
View File
@@ -412,14 +412,18 @@ get_domain_peak_concurrent() {
return 1
fi
# Analyze access log for peak concurrent requests (simplified)
# 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
tail -100000 "$log_file" 2>/dev/null | \
awk '{print $4}' | \
sed 's/\[//' | \
awk -F: '{print $3}' | \
sed 's/\[//; s/\].*//' | \
awk -F: '{print $1 ":" $2}' | \
sort | uniq -c | \
sort -rn | head -1 | \
awk '{print $1}' || echo "0"
awk '{requests=$1; print (requests > 5 ? int(requests * 0.6) : requests)}' || echo "0"
}
# Check if a domain is already optimized