# Scaling Production data across Microservices @ Fiverr

- Speaker: [Erik Ashepa](/wiki/speakers/erik-ashepa.md)
- Event: [Reversim Summit 2019](/wiki/years/2019.md)
- Video: https://www.youtube.com/watch?v=cZnlssdwG4Y
- Transcript: [/transcripts/2019/69-cZnlssdwG4Y.md](/transcripts/2019/69-cZnlssdwG4Y.md)
- Language: Hebrew and English · Type: talk · Level: intermediate
- Topics: [Architecture](/wiki/topics/architecture.md), [Distributed Systems](/wiki/topics/distributed-systems.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 how their company evolved its architecture from a monolith to microservices and addressed the data-scaling challenges that arose along the way. They explain the concept of the data dichotomy, where services encapsulate data while databases empower complex querying. To solve performance and coupling issues, the speaker introduces state change events and read-optimized views. Ultimately, the audience learns practical patterns for decoupling services and handling data distribution in a microservices environment.

## Key points

- [2:25](https://www.youtube.com/watch?v=cZnlssdwG4Y&t=145s) Moving everything into a single monolithic codebase created a weak sense of ownership and difficult deployment bottlenecks.
- [3:33](https://www.youtube.com/watch?v=cZnlssdwG4Y&t=213s) Splitting the monolith into microservices based strictly on MVC models eventually led to a distributed monolith with complex cross-service dependencies.
- [5:41](https://www.youtube.com/watch?v=cZnlssdwG4Y&t=341s) Encapsulating data within microservices forced complex REST API queries, memory joins, and heavy caching.
- [10:05](https://www.youtube.com/watch?v=cZnlssdwG4Y&t=605s) The speaker defines the data dichotomy between service encapsulation and database query power.
- [11:12](https://www.youtube.com/watch?v=cZnlssdwG4Y&t=672s) The company introduced state change events called ravens to represent fine-grained state changes agnostic to business flows.
- [13:12](https://www.youtube.com/watch?v=cZnlssdwG4Y&t=792s) Kafka was chosen over RabbitMQ to transport ravens because of its persistence, partitioning, and compaction features.
- [15:18](https://www.youtube.com/watch?v=cZnlssdwG4Y&t=918s) Projections consume ravens to build read-optimized views tailored to specific microservice query patterns without caching.
- [21:43](https://www.youtube.com/watch?v=cZnlssdwG4Y&t=1303s) Domain events are introduced alongside state change events to drive specific business flows and choreography.

## Takeaways

- Adopt an evolutionary architecture rather than jumping straight into overly complex solutions too early.
- Use state change events combined with read-optimized views to decouple microservice queries.
- Choose Kafka for event streaming when you need persistent, partition-ordered message buffering.

## Questions this talk answers

- How can you avoid distributed monolith anti-patterns when breaking down a large monolithic codebase?
- What is the best way to handle data joining across multiple microservices without heavy in-memory caching?
- When should you use state change events versus domain events in an event-driven architecture?

## Technologies

Ruby on Rails, MySQL, RabbitMQ, Nginx, Google Protocol Buffers, Kafka, Elasticsearch, MongoDB

## Tags

architecture, databases, domain-driven design, event-driven, kafka, microservices, scaling
