ElixirConf US 2018 – Event Sourcing in Real World Applications: Challenges, Successes and Lessons Learned. – James Smith
Our client came to us wanting to build a real time auction application for supplying fuel to ships.
This was exciting! We were going to be auctioning upwards of 1000 metric tons of fuel using Elixir and Phoenix! What could go wrong?
From the beginning of the project there was a hard requirement for auditing. Anything that happened in the system needed to be recorded. This lead us to the idea of Event Sourcing.
What is Event Sourcing?
Event Sourcing is a way of ensuring all changes to an application’s state are stored as a sequence of events. Those events can be queried, logged and used to reconstruct past states.
In this talk I’ll cover the benefits and challenges with Event Sourcing and the solutions we came up with.
- Predictability. Having a list of Events helped us to troubleshoot and reason about the state of our application.
- *Testability. Using events to start the application in a desired state made Test setup easier.
- *Resiliency. The ability to rebuild the state of any auction at any time made our application more resilient. An auction crashing during the bidding process was no longer as scary.
- Complexity. Early on we struggled with deciding to implement the pattern ourselves or use a library. After trial and error we thought through our domain, and chose to implement it ourselves. This had both benefits and draw backs.
- Ordering. The order in which things happened our system was important. Ordering events across multiple asynchronous processes was complex.
- Race Conditions. Dealing with timers that trigger events without race conditions was difficult.
- This project was both fun and challenging. I want share the knowledge that we gained from it, as well as our mistakes.