Multi Tenancy and Feature Flags, Spring to NestJS: Tenant A Saw Tenant B

1 October 2026 nestjstypescriptnodejsjavaspring-bootfeature-flags
PDF The design sheet The full architecture and the verified references. Free, no email.
Thumbnail for Multi Tenancy and Feature Flags, Spring to NestJS: Tenant A Saw Tenant B 4:15
Watch on YouTube, or read on below.
Run this yourself → Clone the repo, docker compose up, and watch it happen

Two customers call a NestJS payment service at almost the same moment, and acme’s request answers with globex’s tenant id. Measured on 1 October 2026, in the last episode of the series. Request context must be scoped to the request, and rollout decisions must agree across stacks.

The current tenant

On Spring, a deliberately broken filter set a ThreadLocal and never cleared it: Tomcat reused the thread, and the next request, with no tenant at all, saw acme. Clearing it in finally fixed it.

On Nest, the same habit as a module-level variable is worse: two requests in flight overwrote each other. AsyncLocalStorage, and a request-scoped provider, kept them apart. But a singleton that injected a request-scoped tenant was promoted into request scope: 100 requests, 100 instances.

One rollout, two stacks

A 20% rollout, bucketing ported mechanically from Java to JavaScript: Spring enabled it for 208 users, Nest for 999, and 791 users got a different answer from the two stacks. With OpenFeature and the flagd provider reading one flags.json on both, none did. Share the evaluation contract, not just the percentage.

Forty episodes, and the theme held to the end: the syntax often transfers, the runtime contracts do not. The full code for every measurement is in the repository, and the free design sheet above has the checklist on one page.


Watch next

New videos land on Code with Sam - subscribe there if this was useful.

Get the interview pack

A free, practical pack for engineers preparing for senior backend interviews - the questions that actually get asked, and how to answer them like someone who has done the work.

New articles and videos when they land. No spam, and one click to leave.