4

I'm looking for an EventStore for an EvenSourcing and CQRS system that i'm considering to develop in the neares future. I've startet to get familiar with CockroachDB and impressed by scalability, while having all that guaranties, that are nice for Event Store and queries on it.

I'm thinking here about, i guess one(?) table for events. Something looking similar to this:

Columns in the Table

  • AggregateId [Guid]
  • Data [Blob]
  • SequenceNumber [Long]
  • Version [Int]

So i have two questions:

  1. Is CockroachDB a good choice as EventStore at all?
  2. Will it match my performance and scale expentations in this scenario. E.g would it scale as expected on increasing data over time and more read an write traffic/operations?
aholbreich
  • 4,443
  • 1
  • 20
  • 32
  • Take a look at my answer: https://stackoverflow.com/questions/43408599/choosing-a-nosql-database-for-storing-events-in-a-cqrs-designed-application/43409269#43409269 – Constantin Galbenu Jul 14 '17 at 06:17
  • You ask if it will match you performance and scale expentations but you haven't said what they are. – Michal Borowiecki Jul 16 '17 at 11:34
  • @MichalBorowiecki - basically Cockroach DB states a very good scaling attributes with the increasing nodes count in average. So basically i asking if One big Event table undermines CockroachDB assumptions or not. – aholbreich Jul 17 '17 at 13:29
  • Again, this is very abstract. How big is big, what throughput do you expect? There is little point debating performance without concrete numbers. – Michal Borowiecki Jul 17 '17 at 13:44
  • It should be abstract. Consider that i would start with one CockroachDB instance and when things go well i end up with 3 or maybe 10 instances in 2 years... Don't know in advance. And i expect that the performace (latency and throughput) scales linearly (it sound like in the docu of Cockroach, but they are not precise on this) with every new node. – aholbreich Jul 17 '17 at 13:57

2 Answers2

3

Cockroachdb is a good choice as an Event Store. One thing to watch out for is how you pick your primary key. If you use a timestamp as the primary key for instance, you will see all writes hit the same node, so it is better to pick a key such that writes done close in time are distributed evenly over all nodes. Picking a random number as an eventID and using that as a key will work.

CockroachDB doesn't as of yet (coming soon) support notifications on changes to the database which can be useful when using it as an event store

susegado
  • 31
  • 1
  • Thank you very much for the hint with PrimaryKey! And yes if notification are not build in i need to do them my self. But mabye they arrive sooner than i do any progress ;) – aholbreich Jul 17 '17 at 13:37
1

CockroachDB now supports notification on changes to the database in the form of Change Data Capture (CDC) change feeds. Here's the documentation:

https://www.cockroachlabs.com/docs/stable/stream-data-out-of-cockroachdb-using-changefeeds.html

and a couple relevant blog posts:

There's also a recorded presentation/demonstration of CRDB change feeds on YouTube:

https://www.youtube.com/watch?v=UTaRWpNcOgk