# Lessons learned from working with 2000 event-driven microservices

- Speaker: [Natan Silnitsky](/wiki/speakers/natan-silnitsky.md)
- Event: [Reversim Summit 2022](/wiki/years/2022.md)
- Video: https://www.youtube.com/watch?v=MqRL2vwRlJg
- Transcript: [/transcripts/2022/21-MqRL2vwRlJg.md](/transcripts/2022/21-MqRL2vwRlJg.md)
- Language: Hebrew · Type: talk · Level: intermediate
- Topics: [Distributed Systems](/wiki/topics/distributed-systems.md), [Microservices](/wiki/topics/microservices.md), [Databases](/wiki/topics/databases.md), [Software Engineering](/wiki/topics/software-engineering.md)

> Written by an LLM from machine transcripts. It can contain errors. Check the transcript before you quote it.

## Summary

The speaker shares lessons learned from adopting an event-driven architecture across thousands of microservices at a large web development platform. The presentation details common failure modes such as message publishing errors, out-of-order execution, non-idempotent consumers, and oversized payloads. The audience learns how infrastructural patterns, wrapper libraries, and self-service debugging tools can solve these challenges and ensure data consistency. Ultimately, developers gain actionable strategies for scaling reliable event-driven systems.

## Key points

- [2:23](https://www.youtube.com/watch?v=MqRL2vwRlJg&t=143s) Scaling to thousands of microservices introduced major challenges including message loss, out-of-order processing, and payload size limitations.
- [6:59](https://www.youtube.com/watch?v=MqRL2vwRlJg&t=419s) Moving from synchronous REST calls to an event-driven architecture decoupled services and localized failures, improving overall system resilience.
- [10:09](https://www.youtube.com/watch?v=MqRL2vwRlJg&t=609s) To fix message publishing failures caused by a lack of atomicity, the team wrapped message producers to fallback to object storage and a healer service.
- [13:14](https://www.youtube.com/watch?v=MqRL2vwRlJg&t=794s) Out-of-order message delivery was addressed at the application level by attaching sequential version IDs to entities and schemas.
- [16:33](https://www.youtube.com/watch?v=MqRL2vwRlJg&t=993s) Non-idempotent consumer issues were solved by storing event IDs in database schemas to safely ignore duplicate messages.
- [17:43](https://www.youtube.com/watch?v=MqRL2vwRlJg&t=1063s) Oversized payloads that exceeded message broker limits were handled via compression and offloading large data payloads to object storage.
- [21:25](https://www.youtube.com/watch?v=MqRL2vwRlJg&t=1285s) Providing self-service control planes and monitoring dashboards empowered developers to debug production traffic and consumer lags independently.

## Takeaways

- Wrap message producers with fallback mechanisms like object storage to ensure reliable publishing when the message broker is temporarily unavailable.
- Enforce idempotency and ordering in consumers by embedding sequence numbers or unique event IDs directly into database schemas.
- Build self-service monitoring and debugging tools early to help developers trace distributed event flows and investigate consumer lags.

## Questions this talk answers

- How can you guarantee data consistency and handle message publishing failures in an event-driven microservices architecture?
- What strategies prevent out-of-order execution and non-idempotent message processing in event consumers?
- How do you deal with oversized payloads and monitor consumer lag at a massive scale?

## Technologies

Kafka, S3

## Tags

data consistency, distributed systems, error handling, event-driven architecture, message queues, microservices, scalability
