# Reshaping a tenant instead of raising platform limits

Author: Chris Chabot
Canonical URL: https://chabot.dev/blog/reshaping-a-tenant-instead-of-raising-platform-limits/
Published: 2026-10-13

Serving a 65 MB browser desktop through 4 MiB replies: chunked model delivery, a small TensorFlow Lite interpreter, a CSS-order regression from code splitting, and right-sized storage.

Platform limits on reply size, deployment records, reserved disk, and test-runner resources exist for good reasons: bounded memory, predictable cost, and isolated builds. Small demo apps never get anywhere near those ceilings, so nobody learns whether they are livable until something large arrives. When a showcase application finally hits one, raising the limit or granting an exception for the demo weakens the platform and teaches nothing. Dogfooding with your hardest tenant only works when you reshape the tenant instead of the limit.

On Ferrite, my cloud platform for verified applications running under fixed resource ceilings, that tenant is Macalicious: macOS Catalina rebuilt as a working browser desktop of 49 apps in React and Base UI, a library of unstyled React primitives, served at macalicious.ferrite.cloud. A single cloud app with 256 MiB of memory and half a CPU serves the entire site; its backend stores state and enforces authorization while everything compute-heavy runs in the visitor's browser, leaving that small process to deliver a 65 MB frontend through replies capped at about 4 MiB.

## Shaping model assets around a 4 MiB reply limit

Because the application serves its own frontend, every asset has to fit inside a single reply of about 4 MiB. Three did not: a 63 MB chess neural network, a scene-classification model, and the main script.

The desktop's Chess app runs Reckless, an open-source Rust NNUE chess engine, compiled to WebAssembly in a Web Worker with its search, evaluation, and full 63 MB network unchanged, matching native Reckless move for move. The network ships as sixteen 4 MiB slices compressed below the reply limit, and nothing downloads until a visitor opens Chess. On launch, the worker fetches and decompresses each slice, verifies its SHA-256 digest, and writes it straight into WebAssembly linear memory at its offset before initializing the engine, so the browser never holds a second 63 MB copy. The scene-classification model in the desktop's Photos app takes the same chunked-delivery approach, shipping as two halves that the client joins in memory before running inference.

## Replacing a 14.6 MB ML runtime with a 435-line interpreter

Ferrite stores each deployed source file as a single record capped at 16 MiB. On Macalicious, Photo Booth tracks faces for camera effects and Photos labels images by scene, both in the browser so user pictures never reach the server. The obvious dependency is MediaPipe, Google's on-device ML runtime, whose 14.6 MB WebAssembly binary exceeds a 16 MiB source record once base64-encoded.

A general ML runtime is mostly operator coverage and execution machinery a single model never touches. BlazeFace, a face detector, uses nine TensorFlow Lite operators. To stay inside the record limit, face detection runs in a Web Worker on a 435-line TypeScript TensorFlow Lite interpreter, combining a minimal FlatBuffers reader with those nine operators. Photos reuses the reader and its convolution kernels to run EfficientNet-Lite0, an image classifier, for scene labels, adding only the handful of operators that network requires. The trade-off is verification: numerical agreement with MediaPipe is tested behaviorally against expected detections and outputs rather than inherited from running the reference runtime.

## When code splitting breaks CSS source order

The third file over the 4 MiB reply ceiling was the main script. Enabling code splitting in rolldown, a Rust bundler used by Vite, brought every chunk under the limit and produced a passing build.

After signing in on the live desktop, the workspace filled only the top 334 pixels of a 900-pixel window. Code splitting breaks stylesheets up alongside scripts and can reorder rules in the emitted CSS. Here, a layout rule setting `position: absolute; inset: 0` on the desktop container was emitted ahead of the equal-specificity component rule setting `position: relative` that it was written to override, letting the component rule win on source order and collapse the container; other equal-specificity overrides failed the same way.

No CSS option restores source order while scripts remain split. I undid the split to keep the compiled stylesheet byte-identical and served the main script compressed-only. Both brotli and gzip copies fit well inside 4 MiB, so the server omits uncompressed delivery for any file whose raw size exceeds the ceiling and answers with HTTP 406 to a client accepting neither encoding, which rules out very few browsers capable of running a 49-app React desktop.

## Sizing declared storage to actual use

Ferrite requires applications to declare reserved disk volumes per service rather than drawing on unbounded shared storage, keeping production capacity predictable and test environments isolated. Macalicious initially reserved 17 GB per environment across its blob stores, data store, and queues, which meant three concurrent hosted test environments filled the disk on the platform's build host. Sizing each service's volume to what the desktop actually holds cut the reservation from 17 GB to about 6 GB per environment, leaving volume enforcement and the build hosts untouched.

## Running integration tests inside hosted runner limits

Every Ferrite deployment has to pass its integration suite inside the platform's hosted test runner, which enforces fixed open-file descriptor limits and bounded runtimes. In one hosted run of Macalicious's suite, 330 tests failed, nearly all from open-file exhaustion during test setup rather than application faults. Running at full thread concurrency while each test booted its own in-process platform services overran the descriptor limit, and waits without deadlines let stalled operations sit until the runner's overall timeout fired.

Rather than raising descriptor limits on the build host, I capped concurrent live environments with a counting semaphore in the test support layer, letting any test that boots a second environment take another slot without waiting so it cannot deadlock against itself, and added hard deadlines to every wait so a hang fails its own test immediately. Those two changes took the hosted suite from 330 failures to 1,068 passing tests.
