This story is about distributed open-source database called Event Store (http://geteventstore.com). Event Store is developed by distributed team, part of which are ELEKS employees. I am going to talk about Event Store purpose and how it works, share some lessons we learned during the development and how it feels when you develop distributed high-performance system of that complexity. The talk will be interesting for technical people: software architects and engineers in general and .NET developers in particular as Event Store is written in C#.
3. Few notes before we start
1.This story is about the development, technology
and lessons learned, not a product
2.Neither about Event Sourcing
3.Outsourcing point of view
4.I was there on pre-sales and initiation phases.
When the team was formed I left the project.
9. 140 characters long definition:
Event sourcing - persisting entities by appending all
business events to transaction log. To rebuild the
state, we replay this log.
11. Event Sourcing
Pros Cons
Performance Performance
Simplification Versioning
Audit Trail Querying
Integration with other systems Not common approach
Troubleshooting Better tastes with CQRS
Fixing errors
Testing
Flexibility
34. Read Index
1.Maps stream name and version to position in
transaction log
2.Index = MemTable + PTables
3.MemTable = Dictionary of Lists
4.Index entry – record of fixed length
5.PTable = file with sorted sequence of entries
and cached midpoints
6.Binary search FTW!
35. Scavenger
1.Background process that go through transaction
log chunks and clean it from obsolete data (e.g.
deleted streams, $maxCount, $maxAge etc.)
2.Simply writes data to a new chunk file
3.Last one out shut the lights off
37. High Availability
1.Master-Slave replication
2.Automatic master elections (N/2 + 1 quorum)
3.Wins the one with most actual state
4.Write always to master, read from master or
slave, depending on client’s choice
5.Byte stream replication
6.Available in commercial version
52. Bugs in .NET
[System.Security.SecuritySafeCritical]
public virtual void Flush(Boolean flushToDisk) {
// This code is duplicated in Dispose
if (_handle.IsClosed) __Error.FileNotOpen();
if (_writePos > 0) {
FlushWrite(false);
if (flushToDisk) {
if (!Win32Native.FlushFileBuffers(_handle)) {
__Error.WinIOError();
}
}
}
else if (_readPos < _readLen && CanSeek) {
FlushRead();
}
_readPos = 0;
_readLen = 0;
}
*Appears to be fixed in 4.5
53. Bugs in Mono
TCP/IP Stack deadlocks Concurrent Stack/Queue
XML Serializer
File Stream issues
General slowness:
20K w/s
59. Links
1. GetEventStore.com – official web site
2. GitHub.com/EventStore/EventStore – source code
3. OreDev.org/2012/sessions/a-deep-look-into-the-event-store – A
deep look into The Event Store by Greg Young
4. MartinFowler.com/eaaDev/EventSourcing.html – Event Sourcing
overview by Martin Fowler
5. Google <Event Sourcing|Event Store>