Multi-tenancy & real-time delivery
Enterprise clients sharing the same backend, isolated at the session level and served status updates over stateful connections instead of polling.
Problem
Multiple enterprise clients, HDFC and Indira IVF among them, ran on the same shared backend infrastructure. That meant two problems at once. First, strict tenant isolation: auth and session state had to resolve to the correct client boundary, not just the correct user, with no chance of one tenant's data or session bleeding into another's. Second, the platform's video-generation jobs take real time to complete rather than resolving instantly, so client dashboards checking on job status needed a way to get live updates without polling the backend on a timer, which wastes requests and gets worse as tenant count and job volume grow.
Constraints
- Session auth had to resolve to the correct tenant boundary, not just authenticate the user — every request needed tenant context attached.
- A tenant's live-update connection had to carry the same tenant-scoping as its regular requests — no risk of one tenant's open connection surfacing another tenant's job status.
What I built
A multi-tenancy architecture with JWT session-based auth carrying tenant context, so every request and session resolves to its correct tenant rather than relying on the application layer to re-derive it each time. On top of that, results are delivered to clients over duplex, stateful connections instead of client-side polling — a client opens a connection and gets pushed updates as a job progresses, rather than asking on a timer whether anything changed. Third-party webhooks were connected into the same job model, so an external system's callback landed against the job that produced it.
Separately, I implemented a custom server health page backend — live at datareel.ai/server-health — using the Docker API in Python. It's a small service that can gate the whole platform: block new logins and surface an alert message if the underlying system is unhealthy, instead of letting tenants hit a degraded backend without warning.
The trade-off
The real cost is server-side state: every open connection has to be tracked, reconnections handled when a client drops mid-job and comes back, and that bookkeeping has to scale with tenant count rather than staying stateless the way a timer-based check would. That's more to build and more to operate than polling. It was worth carrying at HDFC and Indira IVF's scale: what it buys is that the request cost stays flat as tenants and jobs multiply, where polling's climbs with both — a client asking "still working?" on repeat, over and over, for every job it's waiting on.
Outcome
HDFC accepted the platform's service on this shared, multi-tenant backend, and Indira IVF ran high daily volume on it. Per-tenant isolation held at the session layer throughout, and status delivery over open connections kept pace as tenant and job counts grew, without the backend load piling up the way repeated polling would have.