Review and Scale a Fixed-Stage Document Pipeline
Distinguish stage concurrency from completion rate, move a mandatory-pipeline bottleneck, and recover bounded accepted work during a slower stage or uncertain attempt.
Problem statement
For this exercise, assume an existing document-processing service has six mandatory stages. Use this authored fixed graph: A runs first, B and C run in parallel, D waits for both committed outputs, then E and F run. The original interview diagram is unavailable; this graph is a practice assumption.
Each immutable document visits every stage once, stages are pure transformations, and different documents may overlap. A client submits with a retry key and observes durable progress; completion means every required stage has committed one authoritative output.
Retry computations may repeat, but stale attempts cannot overwrite committed output or advance successors twice.
Start one replica per stage with active-attempt limits A=10, B=20, C=50, D=15, E=30 and F=25. Healthy mean service time is one second at each stage. These are authored planning values, not original interview numbers or a latency guarantee.
An identical added replica contributes the same stage limit when shared dependencies permit it. Design the processing, capacity-observation and guarded reconfiguration path, and compare useful horizontal capacity with service-time improvement. The first plan may add at most two replicas.
Offered load is 15 documents/s and bursts reach 40 documents/s for 30 seconds. At most 500 accepted documents may remain unfinished; overload is explicitly rejected before acceptance. The starting configuration may be underprovisioned.
After a suitable change, target at least 20 documents/s sustainable capacity and healthy p95 completion below 10 seconds at the 15 documents/s offered load, validated from measurements. Accepted state and committed outputs survive a controller or worker restart.
Authorized operators change versioned pool settings; active capacity includes physical attempts, so an expired lease does not prove an uncertain computation stopped. Exclude arbitrary graphs, transformation business logic, deployment pipelines, cancellation and external stage side effects.
What to build
- Authenticated clients idempotently submit immutable documents and read their durable progress or final/failed result.
- Every accepted document advances only from committed prerequisites and produces one authoritative final result after all required stages.
- Authorized operators inspect timestamped service-time, active-attempt, completion and backlog evidence and apply guarded versioned pool changes.
- Bound unfinished accepted work and physical execution reservations, reject excess before acceptance, and recover committed progress after worker/controller loss.
At scale
- For this exercise, each initial stage has one replica with active limits [10,20,50,15,30,25] for A through F and healthy one-second mean service time; useful replica capacity depends on measured shared limits.
- For this exercise, offered load is 15 documents/s with 40 documents/s bursts lasting 30 seconds, and at most 500 accepted documents may remain unfinished.
- For this exercise, the first plan adds at most two identical replicas and targets sustainable capacity of at least 20 documents/s with measured healthy p95 completion below 10 seconds at the 15 documents/s offered load.
- For this exercise, accepted state and committed stage outputs survive controller/worker restart; stage F later takes five seconds on average, and lost contact may leave a physical reservation uncertain.