Decompose: Documented concurrency contract (throughput, per-request bounds, failure semantics) #43
Labels
No labels
blocked:children
blocked:depends-101
blocked:depends-103
blocked:depends-104
blocked:needs-attention
blocked:needs-decision
blocked:no-changes
blocked:preflight
bug
chore
feature-request
in-progress
lint-cleanup
needs-decompose
performance
quality
quickfix
security/medium
triage-approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Mark/easystitch#43
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Documented concurrency contract for the service
Context
The HTTP service (issue #31) needs explicit answers to 7 concurrency
questions. Without documented values, every implementer has to guess:
what's the max concurrent digitize? per-request timeout? memory cap?
what happens on overload? partial failure? cancellation? The guesses
will diverge.
Goal
docs/concurrency.mdwith concrete, testable values for everyquestion. A load test that asserts the documented behavior.
Decomposition
The 7 questions cluster into 3 categories. Each phase answers one
category and writes the relevant doc sections + tests.
P1: Throughput answers (questions 1, 5, 6)
Goal: Lock the throughput policy.
Specifically:
the target box; configurable via
WORKER_POOL_SIZE).size.
Retry-After: Nheader, where N is the p50 queue wait time. Document the exact
header shape.
Files:
docs/concurrency.md(initial version with these 3 questionsanswered; the other 4 follow in P2/P3)
docs/service/operations.md(issue #40 P2) to referencethe concurrency policy
Acceptance:
docs/concurrency.mdhas a section per answered question with thevalue, the rationale, and the source (benchmark, calculation, or
decision doc).
requests get 503 with Retry-After" against the spec.
Why first: throughput answers constrain the design of the worker
pool and the request queue. They should be locked before any service
code is written.
P2: Per-request bounds (questions 2, 3, 4)
Goal: Lock the per-request resource limits.
Specifically:
seconds for export. Justify: a 4 MP image at 0.4mm density is
~600K stitches, generated in < 5 seconds; 60s gives 12× headroom.
pipeline at 4 MP peaks at ~800 MB.
worker thread is interrupted within 1 second (set a flag the
pipeline checks between stages; full thread cancellation is unsafe
because of numpy/scipy GIL interactions).
Files:
docs/concurrency.md(add these 3 answers)Acceptance:
Gateway Timeout.
503 with a clear error.
worker to stop within 1 second.
Depends on: P1 (overall policy).
P3: Failure semantics (questions 7, plus the "what if stage N fails?" case)
Goal: Lock the failure-mode behavior.
Specifically:
the response is 503 with body
{"error": "...", "failed_stage": "...", "completed_stages": [...], "request_id": "..."}. Thepipeline cleans up any partial state (temp files, half-built
stitch objects).
upload, unsupported format)? Answer: 400 Bad Request with a
specific error code per failure mode (NOT 500).
with
request_id,stage,error,stack(configurable).Files:
docs/concurrency.md(add failure-mode section)docs/service/operations.md(cross-link from the errorresponse shape)
Acceptance:
asserts the partial-state cleanup happened (no orphan temp files).
Depends on: P1, P2.
Out of scope
cancellation logic. Those go in the relevant service tickets
(issue #31 P2 for the handlers, P5 for the worker pool).
A/B testing, blue-green) — separate doc, separate ticket.
If multi-user support is added later, a rate-limit section can be
added to
docs/concurrency.md.No documented concurrency contract for the service — queue depth, timeouts, memory capsto Decompose: Documented concurrency contract (throughput, per-request bounds, failure semantics)This issue has been decomposed into the following sub-issues:
Each sub-issue has been labeled with
triage-approvedand is ready for queue routing.