Optimizing Performance

1. Implementing Connection Pooling

SettingRecommended
Pool size2x CPU cores
Idle timeout60-120s
Max lifetime30 min (avoid stale)
Health checkValidate before reuse
Per-upstream poolIsolate noisy neighbors

2. Using Keep-Alive Connections

BenefitDetail
Save TLS handshake1-2 RTT saved per request
Lower CPUNo new TCP/TLS setup
Better latencyp99 drops significantly
More memoryTrade-off

3. Configuring HTTP/2 Server Push

Warning: Server Push was removed from Chrome (M106). Use 103 Early Hints with Link: rel=preload instead.
AlternativeDetail
103 Early HintsModern, broadly supported
Link: rel=preloadHint in response headers
HTTP/3 prioritizationStream priorities

4. Using Compression

AlgorithmRecommendation
br (Brotli)Default for text (HTTPS only)
gzipUniversal fallback
zstdBetter than gzip, growing support
identityAlready compressed (images, video)

5. Implementing Request Pipelining

ProtocolSupport
HTTP/1.1 pipeliningSpec yes, practice broken (HOL)
HTTP/2 multiplexNative, preferred
HTTP/3 streamsMultiplexed, no TCP HOL

6. Configuring Database Connection Pooling

SettingValue
Pool size(cores * 2) + spindles
Connection timeout30s
Validation querySELECT 1
Statement cacheEnable, size 256
PgBouncer/RDS ProxyExternal pooler for many clients

7. Using Async Non-Blocking I/O

ModelImplementations
Reactor (epoll)NGINX, Envoy, Node.js
io_uringLinux 5.1+ NEW
CoroutinesGo, Kotlin, Project Loom
Worker threadsTomcat NIO, Netty

8. Implementing CDN Integration

CDNUse
CloudflareGlobal edge, free tier
FastlyVCL programmability
AWS CloudFrontS3/ALB integration
AkamaiEnterprise, large footprint
bunny.netCost-effective

9. Setting Up Edge Caching

StrategyDetail
Cache-Control on originCDN respects directives
Stale-while-revalidateServe stale, refresh async
Surrogate-ControlCDN-only TTL
Surrogate-Key purgeTag-based invalidation
Origin shieldingOne regional cache → origin

10. Using Content Delivery Optimization

TechniqueBenefit
HTTP/3 (QUIC)0-RTT, no HOL blocking
Brotli compression20-25% smaller than gzip
AVIF/WebP images50% smaller than JPEG
Anycast routingNearest POP
TCP BBRBetter congestion control
Connection coalescingHTTP/2 reuse across origins