Skip to content

perf: improve seckill consumption and timeout dispatch - #166

Merged
ChanTso merged 5 commits into
mainfrom
codex/seckill-consumer-throughput
Sep 8, 2026
Merged

ChanTso merged 5 commits into
mainfrom
codex/seckill-consumer-throughput

Conversation

@ChanTso

@ChanTso ChanTso commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Commerce could admit requests faster than the single-hotspot order consumer completed them, and long runs exposed a second backlog in timeout dispatch. This change permits four bounded order consumers, narrows inventory locking, and makes timeout dispatch proportional to the ready batch instead of the accumulated queue.

  • Use a shared activity lock for read-only checks and conditional stock/version updates before inserting the order. Preserve one order per transaction, rollback on publication races, and ACK after commit.
  • Register four actual receive/transaction/ACK schedules. Add concurrent-stock, publication-change and scheduler coverage.
  • Index the generated ready-to-dispatch predicate in retry order. Send MQ messages outside the database transaction, then commit the batch's delivery receipts in a separate transaction; a lost receipt permits replay, and duplicate cancellation does not restore inventory twice.
  • Use the same 10-second observer for both comparison versions and handle only the observed k6-exit EOF case. Retain raw outputs and all unsuccessful probes.

At the same local 200/s five-minute load, baseline and final code each completed 60,001 orders with no dropped iterations; SQL reservation-to-order p99 changed from 9.26s to 1.70s. The repeat completed all 59,963 admitted orders but had 37 unissued startup iterations. The 400/s run still accumulated orders and had one negative receiving-time sample, so it is an overload/recovery case, not a certified sustained capacity. All final SQL inventory/ledger invariants passed. The ready-query average changed from 15,004 examined rows / 47.85ms to 4.61 rows / 0.191ms in the approximately 320-second native sampling intervals.

Environment: local M4, Docker 8 CPU / 14GB, Commerce 4 CPU, MySQL buffer pool 1GiB, durable commit settings unchanged. No positive warmup. Historical fixtures and shared Broker timers are disclosed. Final measured code is 9bb08c6; the report commit is not substituted for that SHA.

Validation: make java-ci python-ci web-ci repo-ci passed; make test-catalog-integration passed 207 tests, including 17 seckill transaction tests. Independent read-only code and evidence reviews found no blocking issues. Repository checks and secret scan passed after the final reports. The final code's remote 26-check gate passed. The merged main commit e6bed53 also passed all 26 checks in https://github.com/ChanTso/citybuddy/actions/runs/34203315877. Original signing metadata and MySQL cache size were restored and Docker stopped; isolated fixtures remain explicitly UNPAID/SENT, not falsely recorded as cancelled.

Results: final comparison, transaction overview.

@ChanTso ChanTso changed the title perf: overlap seckill consumption and narrow inventory locking perf: improve seckill consumption and timeout dispatch Sep 8, 2026
@ChanTso
ChanTso merged commit e6bed53 into main Sep 8, 2026
@ChanTso
ChanTso deleted the codex/seckill-consumer-throughput branch September 12, 2026 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant