HNSW & Token Tuning
Async Celery Fact Ingestion & Qdrant Batch Upsert Tuning
Eliminate user-facing write latency by queuing conversation turns to Redis + Celery workers with Xiaomi MiMo extraction and batched vector upserts.
0 ms Chat Blocking · 32-64 Point Batches · Dead-Letter Retry
Never Block the User Response on mem0.add()
A synchronous mem0.add() call waits on fact extraction, embedding generation, vector search for duplicates, and HNSW insertion—adding 700-1,500ms per turn. Push the turn pair to Redis immediately and return the assistant reply.
Per-User Mutex Keys to Prevent Race Conditions
Use a short Redis lock per user_id inside Celery workers so two rapid back-to-back messages from the same user do not overwrite each other during deduplication.
Measured Thresholds & Vector Stack Parameters
| Pipeline Stage | Recommended Setting | Stability Impact |
|---|---|---|
| Redis Queue Broker | maxmemory-policy noeviction | Prevents silent job drops during extraction bursts |
| Celery Concurrency | 2-8 workers (I/O bound) | Matches Xiaomi MiMo HTTP concurrency cleanly |
| Qdrant Upsert Batch | 32-64 points per upsert() | Cuts HNSW segment churn under heavy ingestion |