1. Container Packing vs Microservices
Free-tier Hugging Face Spaces sleep after periods of inactivity. Deploying each subproject to an
isolated Space multiplies cold starts and introduces 80–120ms of cross-space network latency. Packing
standalone Python packages into a single container uses the full 16 GB memory allocation, shares the
PyTorch runtime, and routes requests in memory.
2. Prefix-Based Fault Isolation
Subprojects install from git tags into the Python environment and expose independent router instances.
The gateway attaches them under explicit path prefixes (/heartflow,
/semantic). If an upstream dependency fails during import or warmup,
the gateway logs the traceback, reports degraded health, and continues serving the remaining
subprojects.
3. Streaming Ingress Guards
Before reaching router handlers, incoming requests pass through Starlette middleware that counts raw
stream bytes in chunks. Oversized payloads reject immediately at 10 MB with HTTP 413, preventing
unbounded memory allocation from exhausting the container RAM or stalling the event loop.