TEOH KAI SHUN VOL. 27 · 33⅓ AI MODELDEPLOYMENTPLATFORMモデル基盤 The log of what fired is the lock.

Inheriting the platform

completed
The platform

The team's model-serving platform deploys, scales, health-checks and tears down GPU model-serving services on Kubernetes for several business units, 50+ services on well over 1,000 GPUs. I build the platform; other teams run the GPUs and the services on it.

The handover in

The codebase dates from 2024. I joined in March 2026, and by October I had written about 450 of its 550 commits.

continuedつづく

GPUs that keep time

completed
The idea

Built from scratch, starting on 30 March 2026. Inference services scale their GPUs up and down on a daily schedule, with schedules checked for conflicts and a scheduler that fires several configs per tick.

Exactly once

The scheduler runs on every replica. Redis or ZooKeeper would have been a new dependency for one feature, so a UNIQUE constraint on the execution log is the lock. One INSERT wins; the rest get a duplicate key and skip.

Two steps

A design choice, asked for in May. Asking a shared cluster for every GPU at once can starve other workloads or fail on the last few replicas. So scale-up takes 80% first, waits for it to be ready, then asks for the rest.

The record

GPU usage history in 30-minute snapshots, and fixed GPU accounting behind the resource reports.

Clean-up

Reconciliation turns off schedules whose services have gone.

continuedつづく

Which model, which GPU

completed
The bill

GPU usage totals per project and per service group, first as two API calls, then refactored into one.

The right versions

Each service is bound to the model versions it can be updated to, so an update only offers valid models.

Where it lands

Deploys from GPU-type templates, the GPU cards each template supports, cluster and namespace selection, and model-version search. And a fix for the platform taking services offline whenever its own access to the cluster manager was refused.

continuedつづく

Bugs that make no noise

completed
Three spare weeks

In July the frontend's schedule slipped, so I audited the server end to end. About 30 defects found and fixed between 9 July and 11 August, each written up with its cause and fix, then tested and merged to production on 17–19 August.

Offline, still running

Two status constants had been copied the wrong way round, so the scheduler could scale an offline service back up. On one call path, taking a service offline did nothing at all and still returned success.

The clean-up that never ran

The rollback after a failed deploy only deleted zero-replica deployments, so it was refused on every real deploy, and the GPU leak it existed to stop happened every time.

Ten models

"The TTS model is missing from the wizard" was a hard-coded LIMIT 10. And a duplicate job ID hid a whole service group, because MySQL treats every NULL deleted_at as distinct.

Guards

An empty config push can no longer wipe the templates and cluster credentials. The Kubernetes client rebuilds itself when its token expires, and one slow cluster no longer hangs every list.

Keys out of the code

The object-storage keys and the cluster manager's API token used to sit in the source. Now the config centre and the cluster credentials deliver them, the server won't start without them, and the keys that had been committed were rotated.

Both ends

In November, still in testing. A deploy now finishes its database write even past the request's deadline, and a sweep removes Deployments no service row points to. The orphaned-GPU leak is closed from both ends.

The copy that broke everything

Later, one version of cloning refused any copy whose saved config held values the template no longer declared. Correct in principle, it broke every real copy within 24 hours. I reverted it to report those values instead, and kept the principle.

24 hours

A copy replays the service; it doesn't copy the row.

continuedつづく

Whose config is it?

completed
The job

From 19 August to 30 September 2026, turned a single-tenant deployment platform into a multi-tenant one, so several business units and their app groups share it. Every query is scoped by business unit with ownership checks, and environment tags are bound to the clusters each tenant may deploy into.

The guess

The obvious way to pick a tenant's config was to join two request labels into a directory name. On the live payload that resolved to a directory that doesn't exist, and nothing reported the failure.

The fix

Tenancy now comes from an explicit table keyed on the ID pair every request carries. An undeclared tenant is refused, never served someone else's templates.

Don't rebuild it

I rejected a server-side config-merge layer, because the company's config system already copies shared config into each tenant's group. As a bonus, each tenant can pin a known-good version.

continuedつづく

For the next person

completed
Less code

A four-phase refactor splitting monolith handlers into packages, shorter modular functions, and dead code removed.

Readable logs

Request-ID tracing across every RPC and logs that say what they mean, plus the team's protocol for moving config changes between dev and prod, both ways.

The handover out

The platform's bilingual (English and Chinese) handover. Runtime view, release and rollback, eleven recorded design decisions, a runbook, and the known debt.

the end完