← Selected systems work

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.

Where
9AI — DataReel video-generation platform
Role
Designed and implemented
Scale
Multiple enterprise clients (HDFC, Indira IVF) on shared infrastructure
Stack
Python, JWT, duplex connections, webhooks, Docker API
JWT
session-based, per-tenant auth
Duplex
replacing polling for long-running jobs
Docker API
backend for the live server-health gate

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

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.

client (tenant A) client (tenant B) JWT auth (resolves tenant) duplex connection (stateful, no polling)
Every session resolves to its tenant at the auth layer; job status flows back over one open connection, not repeated polls.

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.

JWTmulti-tenancyduplex connectionswebhooksDocker APIsession auth