Skip to content
BIASED

Serving models

Block 1 of 6~3 min

Choose the response contract

Suppose a preview-quality scorer takes six milliseconds to process one request. Six requests arriving close together still do not all finish in six milliseconds: they compete for the same worker. Serving begins with that queue and with the action taken when a request can no longer meet its deadline.

Separate the artifact from the request handler

Load a known scoring artifact when a worker starts, validate its schema, and expose readiness only after initialization succeeds. Loading weights for every request adds repeated work and makes latency depend on storage availability. The request handler validates input, assigns a deadline and invokes the initialized scorer. A valid HTTP response still needs an explicit success or failure meaning for the caller.

Keep prediction identity in the response or its trace: request ID, model version and feature version. If a deployment label moves between two requests, these identifiers let an operator distinguish the outputs. MLflow's registry describes versioned models and aliases; pinning the resolved version avoids treating a movable alias as immutable evidence (MLflow).

Choose how results become available

A batch job computes a finite collection, such as last night's previews, and stores outputs for later reading. An online request waits for one answer before its deadline. A stream processes events as they arrive and must define ordering, duplicates and late events. These are interface and scheduling choices; the same scoring function can appear in all three.

For a slow preview repair, returning an accepted job ID can be preferable to keeping a connection open. That changes the contract: the client must be able to inspect completion, and a repeated submission with the same idempotency key should not create duplicate paid work. It does not make the computation itself faster.

Answers are saved on the server and tied to this browser until you sign in.

Go deeper — optional

Code and labs do not count toward the main percentage or the certificate.

  • A batch clock and its limitsoptional

    Arrivals are ordered, nonempty, nonnegative timestamps. One worker serves every admitted item; service is 4+2b ms. The wait target uses the oldest arrival, but a busy worker can dispatch after that target. This finite simulation has no cancellation or admission policy and is not a server implementation.

    ~20 min · easier on a computer · The corresponding lesson and basic Python functions.

    Self-check in the notebook — not part of mastery or the certificate.