OCR & Container Tuning
Tuning Postgres 16 shared_buffers & Work Mem for Large Vaults
Keep tag, custom-field, and date queries sub-25ms from 50k to 500k documents by sizing Postgres shared_buffers and effective_cache_size.
25% RAM shared_buffers · Sub-25ms Filter Queries at 500k Docs
Why Default Postgres 16 Config Bottlenecks Large Vaults
Stock Postgres Docker images boot with shared_buffers=128MB regardless of host memory. Once custom fields, audit logs, and document tags pass 100,000 rows, small shared buffers force constant disk reads during bulk UI filtering.
Balancing Postgres Against Tesseract Spikes
Cap db memory at ~25-30% of host RAM so Celery consumer bursts never collide with database cache allocations.
Measured Thresholds & Container Limits
| Host RAM | shared_buffers | effective_cache_size | db Container Limit |
|---|---|---|---|
| 2 GB (1-Slice) | 384 MB | 1024 MB | 512M |
| 4 GB (2-Slice) | 1024 MB | 2048 MB | 1280M |
| 8 GB (KVM 2 / 4-Slice) | 2048 MB | 4096 MB | 2560M |
| 16-32 GB (KVM 4 / 8) | 4096 MB | 10240 MB | 5120M |