10 Tips for Building Resilient Payment Systems
Ten lessons from Shopify's payment infrastructure for keeping payment systems reliable at scale. Start with low timeouts everywhere: about 1s to open a connection and 5s to read, write or query. Use circuit breakers via Semian, keyed per merchant country so one local acquirer outage stays isolated, and reason about capacity with Little's Law. Track the four golden signals, use structured logs with correlation IDs, and make retries safe with idempotency keys. ULID keys cut INSERT time by 50% versus UUIDv4. The rest covers reconciliation anomalies, load testing against a simulated benchmark gateway, checkout throttling, and incident management and retrospectives.
Related posts
- How a shared merchant data service can degrade gracefully
Grab Engineering mediumAdeptGrab's merchant data service suffered a cascading failure when cache read timeouts fell back to the database, retries piled on, and availability collapsed. The redesign rests on one rule: a fallback is only safe if its work is bounded. Requests get a priority class derived from authentication. A weighted, cross-instance token budget sits in front of the database on the fallback path, and deferrable traffic is rejected outright on cache errors. Per-class connection pools and circuit breakers act as bulkheads, scoped runtime throttles give responders control without deploys, and an opt-in SDK cache serves stale values within explicit freshness windows.
- Incident Report: June 6th, 2025
Railway mediumAdeptDatabase connection pressure at Railway tripped backend circuit breakers, which set off aggressive websocket reconnects from every connected client at once. Websocket handshakes sat outside the WAF policy, and a vendor contract change had removed permission to edit WAF rules, so the reconnect flood bypassed rate limiting. Timed-out clients fell back to the login page, which cleared sessions and sent enough traffic to GitHub OAuth to trigger a secondary rate limit, leaving users unable to log in for several hours. Fixes include client reconnect backoff, OAuth login rate-limit queues, websocket-aware rate-limiting rules, moving real-time reads to a read replica, WAF rules API testing, and showing login buttons only when the backend is ready.
- Interning at incident.io: rate limiting, resiliently
incident.io mediumAdeptincident.io made its rate limiter keep working when its Valkey backing store (Google Cloud Memorystore) is unavailable, instead of failing open. Each pod tracks the top-k busiest traffic gates in local memory and keeps an in-memory budget buffer for them, so it can grant up to its local budget and then deny. A simulation benchmark chose HeavyKeeper over Space-saving because Space-saving lost precision under high-cardinality traffic. The change was validated by killing a local Valkey cluster mid-test and was rolled out gradually by gate risk; a follow-up used a Kubernetes informer to divide the limit by the live pod count so the effective limit didn't become limit × pods. The post is framed as an intern's experience and recruiting pitch.
- How we prepare Shopify for BFCM
Shopify Engineering mediumAdeptShopify readies for Black Friday Cyber Monday with a year-long program that runs from March to October. It combines capacity planning on Google Cloud, What Could Go Wrong risk assessments, chaos-engineering Game Days on critical journeys like checkout, and a centralized Resiliency Matrix of failure modes, RTOs and runbooks. Five scale tests at forecast and p99 load (up to 200M requests per minute) used the Genghis load generator from three GCP regions, Toxiproxy fault injection and regional failovers. The tests surfaced issues such as checkout queue backups, rate-limit paths in authenticated checkout and slow region rebalancing. The newly rebuilt analytics platform needed more Kafka partitions, API memory optimization, connection-timeout tuning and load-balancer changes before facing its first holiday peak.
- Beyond Test Cards: A Fake Payment Provider for Testing at Scale
Lyft Engineering mediumAdeptLyft built a Fake Payment Provider that implements the same provider interface as real processors (tokenize, authorize, increment, capture, charge, refund, void), so it can simulate partial failures, soft declines with retries, pending responses, timeouts and outages that processor test cards cannot. Each test scenario is encoded into a fake low-value token, persisted as a high-value token, and kept stable across the charge lifecycle. Scenarios are dictionaries of per-action specs with success predicates (including a 50% chaos mode), delays, network decline codes and per-attempt retry specs. Strict routing rules confine the fake to simulated users. That lets it run safely in production for load testing the full payment stack, and new scenarios can be added through an AI coding skill whose output still goes through code review.