Apache Web Server/Ingress Configuration for High Scale
Table of Contents
Section titled “Table of Contents”- Overview
- Architecture Pattern
- High-Scale Design Goals
- Apache Edge and Upstream Roles
- Core Apache Tuning Controls
- Ingress Controller Configuration
- Timeouts, Retries, and Connection Reuse
- TLS and Security Hardening
- Rate Limiting and Abuse Controls
- Observability and Alerting
- Failure Modes and Mitigations
- Reference Configurations
- Production Checklist
- Conclusion
Apache Web Server/Ingress Configuration for High Scale
Section titled “Apache Web Server/Ingress Configuration for High Scale”Overview
Section titled “Overview”At high scale, web tier failures often come from connection pressure, bad timeout defaults, and weak overload controls. The fix is not one setting. It is a coordinated edge strategy across Apache, ingress, and backend services.
Architecture Pattern
Section titled “Architecture Pattern”Typical deployment model:
- Global DNS and CDN.
- Apache edge or reverse proxy tier.
- Kubernetes ingress controller.
- Internal services behind
ClusterIP.
Client -> CDN/WAF -> Apache (edge proxy) -> K8s Ingress -> ServicesHigh-Scale Design Goals
Section titled “High-Scale Design Goals”- Keep p95 latency stable during burst traffic.
- Prevent connection storms from collapsing upstream services.
- Enforce deterministic behavior for retries and timeouts.
- Preserve request traceability across all hops.
Apache Edge and Upstream Roles
Section titled “Apache Edge and Upstream Roles”Apache responsibilities at scale:
- TLS termination or passthrough policy enforcement.
- Request normalization and header sanitation.
- Connection reuse to upstream ingress.
- Optional coarse rate limiting and bot controls.
- Structured access/error logging with request IDs.
Ingress responsibilities:
- Host/path routing to internal services.
- Service-aware load balancing.
- Per-route policies (timeouts, body size, auth integration).
Core Apache Tuning Controls
Section titled “Core Apache Tuning Controls”Key controls for event MPM workloads:
ServerLimit,ThreadsPerChild,MaxRequestWorkerssized to CPU/memory.KeepAlive Onwith conservativeKeepAliveTimeout.MaxConnectionsPerChildto recycle workers and limit memory leak impact.- Upstream keepalive pools in
mod_proxyfor backend reuse. - Explicit timeout boundaries for request read, proxy connect, and backend response.
High-level rule:
- Bound every queue and timeout.
- Never allow unbounded waiting paths.
Ingress Controller Configuration
Section titled “Ingress Controller Configuration”For NGINX ingress-like controllers:
- Set request timeout values intentionally by workload.
- Configure buffer/body limits to prevent memory pressure.
- Tune upstream keepalive and worker connection limits.
- Use separate ingress classes for internal and external traffic when needed.
Do not rely on defaults for high-traffic launch windows.
Timeouts, Retries, and Connection Reuse
Section titled “Timeouts, Retries, and Connection Reuse”Timeout policy should be layered:
- Client edge timeout.
- Apache proxy timeout.
- Ingress upstream timeout.
- Application timeout.
Rules:
- Upstream timeout should be less than client timeout.
- Retries should be idempotency-aware.
- Avoid blind retries on non-idempotent POST operations.
- Reuse connections to reduce handshake and CPU overhead.
TLS and Security Hardening
Section titled “TLS and Security Hardening”- Enforce modern TLS versions and cipher suites.
- Enable HSTS for public domains as appropriate.
- Forward security headers consistently (
X-Forwarded-*, request ID). - Sanitize/limit inbound headers and body sizes.
- Isolate admin endpoints from public routing paths.
Rate Limiting and Abuse Controls
Section titled “Rate Limiting and Abuse Controls”Use tiered protection:
- Coarse global rate limit at CDN/WAF.
- Per-IP and per-path controls at Apache or ingress.
- Per-tenant or auth-aware limits in application layer.
This avoids overloading origin infrastructure with abusive traffic.
Observability and Alerting
Section titled “Observability and Alerting”Track these at each tier:
- Request rate, error rate, and saturation.
- Upstream connect and response latency.
- 4xx/5xx by route and host.
- Connection pool utilization and resets.
- Retry counts and timeout distributions.
Alert on trend breaks, not only hard thresholds.
Failure Modes and Mitigations
Section titled “Failure Modes and Mitigations”- Connection exhaustion at Apache:
- Mitigation: tune worker/thread caps, keepalive timeout, and upstream reuse.
- Ingress 502/504 spikes:
- Mitigation: verify backend readiness, upstream timeout mismatch, and service endpoint health.
- Retry storm under partial outage:
- Mitigation: cap retries, add jitter, fail fast for non-critical paths.
- Slowloris-style request pressure:
- Mitigation: request read timeouts and WAF protection.
Reference Configurations
Section titled “Reference Configurations”Apache reverse proxy baseline:
ServerTokens ProdServerSignature Off
KeepAlive OnMaxKeepAliveRequests 1000KeepAliveTimeout 2Timeout 30
<IfModule mpm_event_module> StartServers 4 MinSpareThreads 75 MaxSpareThreads 250 ThreadsPerChild 50 MaxRequestWorkers 800 MaxConnectionsPerChild 10000</IfModule>
ProxyRequests OffProxyPreserveHost On
<Proxy "balancer://ingress_pool"> BalancerMember "http://ingress-a.internal:80" retry=1 keepalive=On BalancerMember "http://ingress-b.internal:80" retry=1 keepalive=On ProxySet lbmethod=byrequests</Proxy>
RequestHeader set X-Request-Id %{UNIQUE_ID}eProxyPass "/" "balancer://ingress_pool/"ProxyPassReverse "/" "balancer://ingress_pool/"Kubernetes ingress baseline:
apiVersion: networking.k8s.io/v1kind: Ingressmetadata: name: web-ingress namespace: web annotations: nginx.ingress.kubernetes.io/proxy-read-timeout: "30" nginx.ingress.kubernetes.io/proxy-send-timeout: "30" nginx.ingress.kubernetes.io/proxy-body-size: "8m"spec: ingressClassName: nginx tls: - hosts: ["www.example.com"] secretName: web-tls rules: - host: www.example.com http: paths: - path: / pathType: Prefix backend: service: name: web-frontend port: number: 80Production Checklist
Section titled “Production Checklist”- Size Apache workers/threads based on load tests and memory budgets.
- Set strict timeout hierarchy across edge, ingress, and app.
- Enable connection reuse and avoid excessive handshake churn.
- Add layered rate limits and bot protection.
- Log request IDs end-to-end for incident triage.
- Run regular game days for 502/504 and retry-storm scenarios.
Conclusion
Section titled “Conclusion”High-scale Apache and ingress reliability comes from explicit limits, clear timeout policy, and measurable behavior during failure. Treat edge and ingress as one delivery system, not isolated components.