Websteps last “competence evening” before the summer vacations gathered 14 consultants, that despite the beautiful weather had decided to stay inside for some quality time together learning about CockroachDB. Kai Niemi had agreed to share his knowledge on the topic.
Kai started with a summary of the evolution of databases and the reasons behind the rise of the so-called NoSQL databases in the second half of the 90’s. That rise was as you might suspect caused by the growing popularity of internet and the increasing demand for accessible information. The traditional databases weren’t able to keep up so new and more flexible ones were developed. I always appreciate some (historical) context, so this introduction was perfect.
It soon became clear that Kai is very passionate and knowledgeable about databases in general and CockroachDB in particular. I for once did not expect such a well-prepared talk. Kai had loads of material and knew what parts to focus on to tailor the talk to the audience. He kept us interested and focused for over two hours, which I think is quite impressive.
What did I learn?
A lot, but if I must list three things it would be that CockroachDB is:
- A highly scalable and distributed SQL database
- Extremely resilient, can even handle outages of entire data centers
- Very easy to get started with
CockroachDB is designed to be both scalable and consistent. Is that possible you may ask yourself, start by reading this to make up your mind:
If you are not up for reading that or any of the many blog post about CockroachDB you could just have a look at the diagram below to get an idea of the concept.
One key component that is not mentioned in this picture is RAFT, the consensus protocol that enables the consistency between the nodes. Follow the link to read more about it.
Try it yourself
Kai underlined that one objective of the creators of CockroachDB was to make it as easy as possible to install and start using. I encourage you to try this and see for yourself.
And follow this guide:
Kai had set up a CockroachDB cluster with three different regions/zones US, Europe (AWS) and Åkersberga (on premise). He then showed how CockroachDB handles nodes going down and finally entire data centers/regions. As long as the majority of the nodes were still up the database just kept on going as nothing had happen from a client’s point of view. It should take you only 5–10 minutes to set up and test a local cluster. I did this and tried out the same thing Kai demoed at the end of his talk (but on my local cluster).
This talk gave me a great introduction to CockroachDB and also quite a few deep dives and explanations of interesting issues that you need to pay attention to when working with databases: ACID, clock skew, true time, serialization and linearization etc. Time well spent.
Thanks to Kai for an interesting talk and a great evening!
Written by: Magnus Andersson