Skip to content

Latest commit

 

History

History
46 lines (39 loc) · 2.36 KB

File metadata and controls

46 lines (39 loc) · 2.36 KB

System Design: pricing-orchestration

1. Problem

Compute and govern price changes across a large catalog, enforcing business rules and approvals, and propagate published prices to downstream contexts (catalog, search) reliably -- with safe rollout.

2. SLOs

Concern Target
Price-change API latency p99 < 150 ms
Rule evaluation correctness 100% (no price published that violates a HARD rule)
Publish propagation Catalog/search consistent within seconds (eventual)
Deploy safety No pricing bug reaches >5% of stores before SLO gate (canary)
Availability 99.95%

3. Bounded contexts (DDD)

  • Pricing: owns proposals, rules, lifecycle. Aggregate: PriceChangeProposal.
  • Catalog: owns the published price read model.
  • Search/Index: owns discovery indexing (reacts to catalog updates). These map to MACH microservices; here they are packages sharing a process for demo simplicity.

4. Orchestration vs choreography (the key design choice)

  • The approval lifecycle is orchestrated: a single state machine owns submit -> evaluate -> approve/reject -> publish. Complex, human-involved decisioning benefits from one authoritative flow (this is the Camunda BPMN / Temporal workflow role).
  • The post-publish propagation is choreographed: catalog and search react to PriceChangePublished independently with no coordinator. This decouples teams and scales across the org. The trade-off is that end-to-end visibility is harder, so we add a compensation path (PriceChangeRollbackRequested).

5. Capacity

  • Catalog of 50M SKUs; price changes are bursty (promotions, cost updates). Design for 5k proposals/sec peak during repricing events.
  • Rule evaluation is O(rules) per proposal and CPU-bound; horizontally scalable (stateless).
  • Publish fan-out goes to Kafka in production; partition by SKU for ordered per-SKU updates.

6. Failure modes

Failure Mitigation
Catalog update fails after publish Choreographed compensation rolls the proposal back
Bad rule deploy Canary + SLO gate auto-rollback
Approval never granted Proposal stays PENDING_APPROVAL (no price leaks); SLA alerts
Duplicate publish Idempotent catalog upsert keyed by SKU

7. Observability

Actuator + Prometheus; track proposals by status, rule-violation rates, approval latency, and publish-to-catalog propagation lag.