Practical System Design. Cascade

reserve_fraud_call

  1. # remaining_ms = provider_ms =
  2. def reserve_fraud_call(request):
  3. deadline = request.child_deadline(
  4. maximum_ms=1000,
  5. reserve_ms=,
  6. )
  7. if not deadline.can_start_call():
  8. return deadline, None
  9. permit =
  10. def evaluate_risk(assessment, request, permit, deadline):
  11. with permit:
  12. cancellation=
  1. Child deadline420 ms, capped at 1000
  2. Caller420 ms of 500 left
  3. ProviderStill running 480 ms

Checkout, fraud, provider

Checkout calls fraud with a child deadline. Fraud calls the provider only when a permit was acquired. Cancellation is what stops the provider when checkout is out of time.

Provider stopped

requestassessscorepermit

Client

Client

Checkout

Risk 0%

Fraud

Deadline without cancellation

Provider

Stopped with the caller

Permit

Permit acquired

Live metrics

ReadyCheckout calls Fraud Service with a child deadline. Leftover provider work should stop when that deadline is spent.
Metric definitions
MetricValueWhat it means
Child deadline420 msmin(1000, time left minus the reserve).
Caller420 msHow long checkout waits. It should finish inside the time it had left.
Still running480 msProvider work after checkout returns. Pass when this is 0.
PermitacquiredA missing permit defers the call. That is not the same as stopping it.
480 ms
420 ms