Latest / The API Podcast with Fexingo: REST, GraphQL, and Modern Web APIs / API Choreography vs Orchestration
Transcript
- Lucas: If today's conversation about API design gave you one concrete takeaway, it's this: stop trying to be the conductor for every single service interaction. Most teams are still building monolithic orchestrators that sit in the middle of everything, and by September twenty twenty six, that approach is becoming a liability for anything beyond simple CRUD apps. Luna: Right, because that central node becomes the bottleneck. If the orchestrator goes down, the whole system stops, regardless of how resilient the individual services are. Lucas: Exactly. And it's not just about availability; it's about cognitive load. When you have a central orchestrator managing fifty different service calls, you're essentially writing a distributed monolith in disguise. The coupling is hidden, but it's there. Every change to one service requires a review of the orchestrator logic. Luna: So instead of a central brain, we let the services decide for themselves? That sounds like chaos without some serious guardrails. Lucas: It feels chaotic until you see the data. We looked at three mid-sized fintech platforms that migrated from an orchestration-heavy model to event-driven choreography last year. Their average latency dropped by roughly thirty percent, and their deployment frequency doubled because teams no longer had to coordinate on a shared integration layer. Luna: Thirty percent is massive for transaction processing. But how do they handle errors if there's no central manager to catch the fall? Lucas: That's the million dollar question, and it's where most people get it wrong. Choreography isn't 'no rules.' It's about shifting responsibility from the controller to the participants through explicit contracts and compensating transactions. Let me walk you through a specific order fulfillment scenario to make this click. Luna: I'm with you. Give me the concrete example. Lucas: Imagine a customer places an order. In the old orchestration world, the Order Service talks to Inventory, then to Payment, then to Shipping, one by one. If Payment fails, the Order Service has to go back and tell Inventory to release the stock. It's a long chain of synchronous calls. Luna: Yeah, and if Shipping is slow, the whole thing hangs waiting for that response. Synchronous chains are fragile. Lucas: Precisely. Now, swap that for choreography. The Order Service publishes an 'OrderCreated' event to a message bus. It doesn't care who hears it. The Inventory Service sees that event, checks stock, and if it's available, it publishes an 'InventoryReserved' event. Then the Payment Service sees that, charges the card, and publishes 'PaymentCompleted'. Only then does Shipping start working. Luna: So the flow is driven by the events themselves, not a central command structure. Each service reacts to what it needs to do next. Lucas: Yes, and crucially, if Payment fails, the Payment Service publishes an 'PaymentFailed' event. The Inventory Service listens for that specific event and releases the stock. No central coordinator needed to tell it what to do. It just follows its own contract. Luna: That's elegant, but it sounds like debugging nightmare fuel. How do you trace a request across five different services reacting to each other asynchronously? Lucas: You need distributed tracing, which brings us to the real cost here. Observability becomes non-negotiable. In orchestration, you can log the state of the orchestrator. In choreography, you have to inject correlation IDs into every event so you can reconstruct the saga later. If you don't invest in tracing upfront, you'll regret it. Luna: Makes sense. Tracing is the price of admission for decentralization. Without it, you're flying blind. Lucas: Agreed. And there's another layer: idempotency. Since services might receive the same event twice due to network retries, every action must be safe to repeat. If the Inventory Service receives 'OrderCreated' twice, it shouldn't reserve stock twice. Your APIs need to handle that gracefully. Luna: Right, so you're trading complexity in control for complexity in data integrity and observability. Which is usually the harder problem to solve well. Lucas: It absolutely is. That's why many companies stay in orchestration for too long. They underestimate the operational overhead of maintaining a robust event bus and tracing infrastructure. But once they cross that threshold, the velocity gains are undeniable. Luna: I think the key distinction is scale. For small teams, orchestration is probably faster to build. Choreography pays off when you have multiple autonomous teams. Lucas: Spot on. If you have ten developers all touching the same orchestrator code, you're going to merge conflicts and deployment freezes. With choreography, the Inventory team owns the Inventory logic. They deploy independently. The only contract is the event schema, which is much easier to manage version-wise than complex synchronous workflows. Luna: Schema evolution is still tricky though. If Inventory changes its event format, Payment might break. How do you handle backward compatibility there? Lucas: You treat events as immutable facts. You never delete or change a field in a published event. You add new fields, and you publish new event types for new behaviors. Old consumers ignore what they don't understand. This is why schema registries are critical in choreographed systems. Luna: Immutable events... that actually simplifies a lot of things. It prevents those silent data corruption issues we talked about in previous episodes. Lucas: Exactly. Silent corruption happens when you mutate state centrally and someone forgets to update a dependent service. With choreography, every change is an explicit event. If something breaks, you can replay the history. You have a ledger of truth, not just a snapshot. Luna: Replayability is a huge advantage. I can imagine using that for testing or even recovering from accidental deletions. Lucas: Absolutely. But let's be clear: choreography doesn't replace orchestration entirely. There are cases where you need strict ordering or complex branching that's easier to visualize in a workflow diagram. The hybrid approach is often best. Luna: So you use orchestration for high-level business processes and choreography for the underlying domain interactions? That seems like a pragmatic compromise. Lucas: That's the sweet spot. Use orchestration to define the saga boundaries, but delegate the actual execution steps to event-driven choreography within those boundaries. It gives you visibility without creating a bottleneck. Luna: I like that. It keeps the system flexible while still giving architects a map of what's happening. Lucas: Before we dive deeper into the technical implementation details, I want to mention something quick. If this conversation about API architecture helped clarify your thinking today, consider supporting the show. It's ad-free and independent, and listener support keeps Lucas and Luna able to dig into these topics deeply. Honestly, if today was worth a coffee to you, that's the link — buy me a coffee dot com slash fexingo. Luna: Yeah, it really helps us keep the signal to noise ratio high for you guys. Thanks for keeping the lights on. Lucas: Let's get back to the practical side. One common pitfall in choreography is the 'fire and forget' mentality. Teams publish events and assume everything is fine. But if an event is lost, the entire business process stalls silently. You need dead letter queues and alerting for unprocessed events. Luna: Dead letter queues are essential. You need a place to inspect failed messages without blocking the main flow. Lucas: Exactly. And you need SLAs for those queues. If an event sits in a dead letter queue for more than five minutes, it should trigger an immediate alert. Because in a choreographed system, that stuck event might mean a customer hasn't been charged, or inventory is locked up indefinitely. Luna: That turns an invisible bug into a visible ops ticket. Much better than finding out a week later that revenue dropped. Lucas: Right. And another tip: document your sagas. Not the code, but the flow. A simple diagram showing which events trigger which actions is invaluable for new hires. It replaces the mental model of 'who calls whom' with 'what happens when.' Luna: Documentation is often the first thing to rot in fast-moving projects. Enforcing it as part of the PR process is key. Lucas: Definitely. Treat the saga definition like a legal contract. Everyone signs off on the event schemas before any code is written. It forces alignment upfront rather than arguing about integration points after deployment. Luna: Shifting the conflict left, so to speak. That's a smart way to reduce friction during development. Lucas: It is. And it scales better. As you add more services, the number of synchronous calls grows exponentially in orchestration. In choreography, adding a new service is just subscribing to existing events. Linear growth in complexity, not exponential. Luna: That linear scaling is the holy grail for growing engineering organizations. It lets you hire and onboard without collapsing the system under its own weight. Lucas: Precisely. So, as you evaluate your current API landscape, ask yourself: where is the coupling? Is it hiding in a central orchestrator? If so, identify one low-risk workflow and try refactoring it to event-driven choreography. Measure the latency and the deployment time. Luna: A controlled experiment. See if the theory holds up in practice. That's a solid way to convince stakeholders. Lucas: It works. Data always wins over opinion. And remember, you don't have to boil the ocean. Start with one saga. Prove the value. Then expand. Luna: Small wins build momentum. I think that's the real lesson here. Decentralization is a journey, not a switch you flip. Lucas: Agreed. It's about evolving your culture towards ownership. When teams own their events, they own their outcomes. That's when the real productivity boost happens. Luna: Ownership changes everything. From coding style to incident response. It's a fundamental shift in how we build software. Lucas: And that shift is accelerating. By the end of this quarter, expect to see more case studies from enterprise firms making this transition. The early adopters are already seeing the benefits. Luna: Hard to argue with results. If the latency drops and deployments speed up, the rest follows. Lucas: Exactly. So, next time you're designing a new microservice interaction, ask yourself: do I really need to control this, or can I just let it happen? Luna: A powerful question to end on. Less control, more freedom. Sounds like a trade-off worth exploring. Lucas: It is. And if you find that balance, your system will thank you. Thanks for listening, Luna. Luna: Thanks, Lucas. See you next time.