Skip to content
Python

FastAPI, Async IO, and Sub-200ms Match Scoring with NumPy

Author: GeniusXLab

·9 min read

FastAPI plus Socket.IO gives async-friendly endpoints and persistent connections, but CPU-heavy scoring can still stall the loop if you let it run inline. We treat match scoring as a bounded worker path: vectorized NumPy/Pandas where possible, with clear batching.

Sub-200ms scoring is a product requirement when users expect instant feedback. That means profiling the actual hot functions, not guessing–then pushing allocation-heavy work off the critical WebSocket ack path.

PostgreSQL gets composite indexes aligned to real filters: location, preferences, activity–whatever the queries actually use in production. Connection pooling prevents thundering herds when thousands of sockets are active.

The architecture that survives is explicit: async IO for I/O, controlled parallelism for CPU, and the database indexed for the patterns we run at scale–not the ones we imagined in design docs.