Skip to content

14.15 Performance Engineering & Async Workers ​

1. Latency Percentiles & Connection Pooling ​

  • p50 Ingestion Latency: 4.2 milliseconds
  • p95 Ingestion Latency: 12.8 milliseconds
  • p99 Ingestion Latency: 28.5 milliseconds

Critical Optimizations ​

  1. Async Connection Pooling: SQLAlchemy connection pooling with pool_size=20, max_overflow=10 reuses open TCP sockets to PostgreSQL.
  2. Pre-Compiled Templates: AST structures are compiled once into bytecode, eliminating repeated regex matching.
  3. Index-Only Scans: Queue polling utilizes composite indexes, avoiding table lookups during job acquisition.

2. Say It Out Loud ​

"We optimized OmniPost for high throughput by enforcing non-blocking I/O across every layer. Database connections are pooled using SQLAlchemy AsyncEngine, pre-compiling Jinja2 ASTs into memory, and leveraging composite database indexes to ensure queue dequeueing executes in under two milliseconds."