Event-Driven Architecture Best Practices, From a Data Pipeline That Had to Work
Event-driven architecture best practices from building data pipelines that have to keep running: clear events, idempotency, a shared standard and monitoring that catches silent failures.
Most articles about event-driven architecture are written from a whiteboard. This one comes from a data pipeline that had to work.
I have been building scraping and data pipelines since 2012, and the ones that survive years of source changes are almost always built around events. Each step publishes what it did, the next step picks it up, and a failure in one place does not take the whole thing down.
These are the practices that matter. None of them are new. What surprised me was how much damage each one causes when it is skipped.
1. Events describe facts, not code paths
A good event says something happened in the business: a listing was found, a price changed, a source was fully processed. A bad event says some function ran or a table changed.
Events built around facts survive refactors. Events built around implementation details force every consumer to understand the producer’s internals, and then nobody can change anything.
In a scraping pipeline the natural facts are simple: a page was fetched, items were extracted, a batch passed its checks, a delivery is ready. Each step publishes what it did, and the next step does not care how.
2. Assume duplicates and out-of-order delivery
Messages will arrive twice. They will arrive late. They will arrive in the wrong order. Design every consumer so that processing the same event twice does no harm.
For data, that means stable identifiers for every item, so that a listing seen twice is updated, not duplicated. It sounds obvious. Duplicates are still the most common data quality problem I see in pipelines built without it.
3. Agree on one envelope for every event
I use the CloudEvents standard for every event. A shared envelope (who produced it, what type it is, when, which version) means every service can route, log and debug any event without special cases.
The specific standard matters less than having one. The alternative is every team inventing its own format and every integration becoming a translation project.
4. Version your contracts
Sooner or later an event needs a new field or a different shape. If consumers break when that happens, you will stop changing things, and the system will fossilize.
Add fields without removing old ones, put a version in the event type, and give consumers time to move. Boring discipline, enormous payoff.
5. Monitor the data, not just the services
This is the lesson I carry into every data project. Services can be healthy while the data is wrong.
A source changes its layout, extraction returns half the items, every service is green, and nothing alerts. The only way to catch it is to watch the data itself: volumes per source compared with previous runs, required fields that suddenly come empty, values outside normal ranges. In an event-driven pipeline, that check is just another consumer of the “batch extracted” event, and it is the most valuable one. It is also the part most in-house scrapers skip, which is a big reason building them costs more than it looks.
6. Plan for failure: retries, dead letters and replay
Things will fail: a source times out, a parser hits a page it does not understand, a downstream system is down. Retry what is worth retrying, park what keeps failing somewhere a human can look at it, and keep the raw inputs so you can replay a step after fixing it.
Replay is underrated. When a parser bug is found, being able to reprocess last week’s pages instead of fetching them again saves time and keeps you off the sources’ radar.
7. Do not turn everything into choreography
Pure event choreography, where every service reacts to others with no coordinator, looks elegant and becomes impossible to follow once a process has more than a few steps. For a pipeline with a clear sequence (fetch, extract, check, deliver), an explicit orchestrating step that knows the whole flow is easier to reason about and to debug.
Use events to decouple. Do not use them to hide the process.
8. Ownership follows the architecture
Every event type needs an owner: the team or person who answers when it changes or breaks. Without ownership, events become a shared dumping ground and the architecture quietly decays.
In my experience, the teams that ship on time with events are small and have clear ownership. The architecture makes it possible, but people make it happen.
9. Start smaller than you think
You do not need a message bus for everything on day one. Start with the parts that genuinely need decoupling, prove the patterns there, and grow. Many event-driven failures come from going all in before anyone understands the failure modes.
What this looks like today
I now run a managed web data service: large companies tell me what data they need, it arrives on schedule for one fixed yearly price, and keeping the pipeline alive is my problem. Every practice above is still in it, especially number 5. The worst failure in data is not the one that crashes. It is the one that keeps running and delivers half the data.
Related reading
- I Read 59 "Best Web Scraping Services" Lists. 28 Ranked Their Own Author First. Who writes the "best web scraping companies" lists, who comes out on top, and why someone looking for a managed data service gets a list of software instead. 59 lists, coded one by one.
- How Much Does Web Scraping Cost? Pricing Models and What Really Drives the Price Per request, per hour, per project or per year: how web scraping is priced, why the same number of items can cost very different amounts, and where the hidden costs hide.
- Build or Buy Web Scraping: What It Really Costs to Keep a Scraper Alive Writing a scraper takes a week. Keeping it alive takes years. What in-house web scraping really costs, when building makes sense, and when buying the data is cheaper.
- The Mirror That Ended a Team War Two tech leads, same grievances, zero communication. How a simple conversation technique defused a conflict that was tearing a team apart.