Performance Guide¶
Optimize for predictable latency and stable memory under burst traffic.
Handler Design Rules¶
- keep event handlers short and non-blocking
- offload heavy CPU to workers
- avoid synchronous I/O in async handler path
Target
Keep p95 handler latency low enough that user-facing replies remain responsive under burst load.
Throughput Tactics¶
- cache repeated lookup results
- avoid repeated protobuf parsing for the same payload
- batch outbound calls where safe
- use bounded worker queues
- stream large blobs to disk/object storage
- avoid retaining many blobs in process memory
Measurement Baseline¶
Track at minimum:
- event receive timestamp
- handler start/end timestamp
- outbound API duration
- queue depth (if queue used)
- memory watermark
Profiling Workflow¶
- capture trace under realistic traffic.
- identify top handler hotspots.
- optimize one hotspot at a time.
- rerun same workload and compare metrics.
Capacity Planning Checklist¶
- message rate per minute
- media download/upload volume
- active callback concurrency
- reconnect frequency
False optimization
Optimize after measuring. Guess-based micro-optimizations often increase complexity without improving bottlenecks.