Preparing your design workspace

Loading the problem and your latest saved attempt…

Design an Embedding and Classification API

Design an API that turns an already-stored file into a classification result through an ordered pair of opaque model services.

Problem statement

For this exercise, assume an authenticated tenant already has an immutable file in managed storage and wants its classification result. File upload and model training are outside scope.

The first opaque service accepts the file and produces an embedding; the second accepts that embedding and produces an opaque classification JSON document. They must run in that order, and a classification must use the embedding produced for that exact file and operation.

Design the customer API and the orchestration behind it. As bounded practice assumptions, return a durable operation handle after admission, expose pending, successful and failed outcomes, and let a client retry the same logical request without creating another operation.

Pin one configured pair of service revisions when the operation is accepted; do not substitute revisions midway. Files are authorized by tenant, are immutable while referenced, and may be read through a short-lived storage reference.

Persist accepted progress and the successful result so a worker restart does not lose it. Opaque service calls may time out after doing work, and workers may receive a job more than once; do not promise that an external computation executes exactly once. Explain safe result publication, recovery and overload.

Do not design the models, invent the contents of the classification schema, accept uploaded bytes at this API, or add bulk model-training and release workflows.

What to build

  1. A tenant can request classification of one authorized, already-stored immutable file and retry that logical request to obtain the same operation.
  2. The service runs file-to-embedding before embedding-to-classification, binds each artifact to the accepted file and service revisions, and durably recovers accepted work.
  3. The owner can read operation status and retrieve the stored classification JSON after success; failures and overload have explicit bounded outcomes.

At scale

  • For this exercise, assume 2,000 operation admissions per second with short bursts to 10,000, files up to 100 MB, and a small number of tenants producing most traffic.
  • Assume the file-to-embedding service takes 1–20 seconds and embedding-to-classification takes 0.1–2 seconds for admitted work; both may time out or return retryable errors. Size admission and concurrency separately for the two stages.
  • Target p99 admission and status requests below 200 milliseconds when their dependencies are healthy, and 99.9% availability for these control APIs; inference completion is asynchronous and exposes queueing delay.
  • Accepted operations and published results survive one zone loss. Keep terminal operation results for seven days; return an explicit expired/not-found result afterward. No unlimited backlog or universal inference-completion deadline is promised.