Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building Durable, Performant Systems Integratio...

Building Durable, Performant Systems Integrations at Scale

Systems integrations kinda… suck. On one hand, they're among the most important parts of complex ecommerce builds, but on the other hand, they're arguably the most frequently botched. Poor design can result in integrations that test well but bog down quickly at scale, or encounter frequent, annoying errors that require a lot of "encouragement" from a human operator.

This talk explores how a decoupled approach can solve many of the problems that plague systems integrations. Architectural patterns like microservices and message buses enable more durable, performant systems integrations that can more easily recover from outages and handle load spikes. While these architectural patterns may be trendy, there's no need to abandon your whole tech stack: we can apply these principles to anything from a SQL table to an FTP bucket.

Avatar for Thayer Luscian

Thayer Luscian

October 10, 2023
Tweet

More Decks by Thayer Luscian

Other Decks in Technology

Transcript

  1. Head of Engineering abovethefray.io • thayer.dev Based in Lancaster, PA

    Has a cat (pictured) As of July, has a wife (not pictured) ThayerLuscian.phtml
  2. Platform-agnostic (but I 🧡 Magento) Architecture-agnostic (mostly) In context of

    two systems Assumes a “blind” integrator Ground rules 1 2 3 4
  3. Stability A system’s ability to perform by consistently maintaining stasis

    Keeping the lights on Durability A system’s ability to perform consistently despite loss of stasis Stasis A state of equilibrium, wherein “it’s all chill bruv” (remember, from biology class?)
  4. Almost anything can be a message bus, if you only

    believe… pub sub pub sub A B
  5. Entities & events • Integrations synchronize entities (nouns) • Integrations

    are driven by events (verbs) product updated product sales order placed sales order Transactional Non-transactional entity event
  6. Event listener (observer) • Make sure to pick the right

    event! • A (welcome) exception to the rule • Save publication status in DB! Cron job • Use these sparingly and efficiently • Can bring other performance issues • Make sure you know what you’re doing Webhooks • Should be paired with a “full load” • Availability is a toss-up, since you’re already dealing with a closed system Polling • Extra care needed to ensure efficiency • Requires extra work for change tracking • Should be paired with a “full load” How do we know when events happen? Active Passive Closed system Open system
  7. We always know what Magento’s up to pub B app/code

    sales order placed Mind palace Great unknown
  8. APIs: a window into another world pub B app/code sales

    order placed Mind palace Great unknown API
  9. Magento isn’t really special pub B X++ product updated Someone

    else’s mind palace “The shopping cart” API
  10. We’ll take what we can get pub B app/code sales

    order placed Mind palace Great unknown something something ibm? DB2
  11. Use the Force, Luke pub app/code sales order placed Mind

    palace Not-so-great unknown API pub microservice API I/F A B web hook
  12. Consuming is a little easier! sub app/code product update Mind

    palace Not-so-great unknown API sub microservice API I/F A B
  13. Be careful where you step! INSERT Create a new entity,

    even if an identical one already exists (not idempotent) REPLACE Apply all values as provided (including blank) to all fields for an existing entity (idempotent) MERGE Apply certain provided values to specified fields for an existing entity (idempotent) Idempotent Has the same effect, no matter how many times you do it POST PATCH PUT (technically)
  14. Rule #2 Keep all business logic separate from the integration

    layer. Warehouse A = 15 Warehouse B = 12 qty = whA + whB qty: 27 Quantity = 27 Warehouse A = 15 Warehouse B = 12 whA: 15 whB: 12 Warehouse A = 15 Warehouse B = 12 qty = whA + whB Quantity = 27 Correct Incorrect ERP Integration Magento
  15. Rule #3 Log errors in all three layers, and keep

    at least one copy of payloads. → ~/var/log tail -f integration.log Jun 16 14:12:01admin user [email protected] not found with role "Sales Rep" thayer - ssh - [email protected]
  16. Rule #4 Optimize publishers and consumers to use the fewest

    possible resources. GET https://erp.acme.co/api/orders?status=open GET https://erp.acme.co/api/orders?status=open &updated_start=2023-06-16T23:49:00Z ↑ 5,000 orders loaded to memory & filtered ↓ 35 orders loaded to memory, no filtering needed &updated_end=2023-06-16T23:50:00Z