Hi,
How do people implement horizontal partitioning/sharding in
conjunction with event sourcing? Are there best practices available?
The documentation of Greg Young's Event Store says
(
http://geteventstore.com/docs/what-is-an-event-store.html):
"One problem when attempting to use Horizontal Partitioning with a
Relational Database it is necessary to define the key with which the
partitioning should operate. This problem goes away when using events.
Aggregate IDs are the only partition point in the system. No matter
how many aggregates exist or how they may change structures, the
Aggregate Id associated with events is the only partition point in the
system. Horizontally Partitioning an Event Store is a very simple
process."
But what if I have a requirement to partition based on a logical key
rather than on the Aggregate ID? Say I have a system where the storage
of event-sourced aggregates should be partitioned according to some
sort of geographical location (e.g., in order to improve performance
of the command side and to allow for network partitioning). I.e.,
aggregates associated with the North should be stored within an event
store located in the North, aggregates associated with the South
should be stored within an event store located in the South.
How would I approach this requirement?
Ideas I have myself:
- Define aggregate IDs to contain the logical ID as well, e.g.,
"North-1234" rather than just "1234". This, however, wouldn't allow me
to move aggregates from North to South.
- Don't partition at all; prefer an asynchronous command side and
cache any commands while the network is partitioned.
- Other options?
Best regards,
Fabian