Rob Reid

Practical CockroachDB

Building Fault-Tolerant Distributed SQL Databases

Rob Reid
Liss, Hampshire, UK
ISBN 978-1-4842-8223-6e-ISBN 978-1-4842-8224-3
© Rob Reid 2022
This work is subject to copyright. All rights are solely and exclusively licensed by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors, and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, expressed or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

This Apress imprint is published by the registered company APress Media, LLC, part of Springer Nature.

The registered company address is: 1 New York Plaza, New York, NY 10004, U.S.A.

For Emily, Ruby, and our little one on the way. Thank you for giving me the space and patience I needed to put this wonderful project together.

Introduction

Every so often, the technology community is blessed with truly disruptive technology. We’ve seen the likes of Kubernetes for orchestration, Kafka for streaming, gRPC for Remote Procedure Call, and Terraform for infrastructure. CockroachDB does what these technologies have done for their respective use cases; it’s a game changer for data.

I first discovered CockroachDB in 2016, where I used it to create rapid prototypes during company Hackathons at my then employer. It immediately felt familiar and as if it had been designed for a developer to build reliable and scalable software without an army of database specialists to help them.

In this book, I’ll share my excitement for this database and the experience I’ve gained from using it for many different use cases.

Who Should Read This Book

This book is for developers, database specialists, and enterprise owners. So whether you’re in a position of convincing people to use CockroachDB or you’re looking for a tool to complement your enterprise tech stack, there’s something in this book for you.

You don’t need to have existing knowledge of CockroachDB, as we’ll start with the basics and quickly ramp up to real-world examples. Any experience with relational databases (especially Postgres) will be beneficial but is not required.

Navigating This Book

This book is both an introduction and a reference to CockroachDB. It starts with the “why” of CockroachDB why it was created and what problems it solves. It then dives into the “what” the database’s data types, constructs, and fundamentals. Finally, it covers the “how” how you can use what you’ve learned to solve real-world scaling, safety, and performance challenges.

The book aims to remain practical, so it hovers above the database’s internal details. To continue your journey, I recommend reading the excellent documentation and blog posts available on the Cockroach Labs website: www.​cockroachlabs.​com.

Using Code Examples

Code examples can be found in GitHub and are arranged in chapters to help you find what you’re looking for as you make your way through the book.

https://​github.​com/​codingconcepts/​practical-cockroachdb

Code is self-contained to a chapter, meaning you won’t have to read the whole book to get something working. In some cases, code examples are split across adjoining code blocks, but this will be highlighted.

I execute all of the code examples against version v21.1.7 of CockroachDB, which is the current stable version of the database at the time of writing.

Contacts

CockroachDB

[email protected]

53 W 23rd Street

8th Floor

New York, NY

10010

www.​cockroachlabs.​com

https://​forum.​cockroachlabs.​com

Rob Reid

[email protected]

https://​robreid.​io

https://​twitter.​com/​robreid_​io

https://​github.​com/​codingconcepts

www.​linkedin.​com/​in/​rob-reid

Acknowledgments

I’m incredibly grateful to the following people. Their contributions to this book have been invaluable to me.

Kai Niemi (Solutions Engineer (EMEA) at Cockroach Labs) I met Kai when he was a customer of Cockroach Labs and have witnessed him transition from being a CockroachDB expert at one company to an expert the global CockroachDB community can be grateful to have.

Daniel Holt (Director, Sales Engineering, International (EMEA and APAC), at Cockroach Labs) I worked very closely with Daniel from the moment he joined Cockroach Labs and have often marvelled at his comprehensive knowledge of the database.

Katarina Vetrakova (Privacy Programme Manager at GoCardless) Katarina is quite possibly the most enthusiastic data privacy specialist you could ever hope to meet. She’s completely dedicated to the art, and since working with her at Lush, her passion and knowledge have been inspiring to me.

Jonathan Gennick (Assistant Editorial Director of Databases at Apress) I’d like to thank Jonathan Gennick for approaching me to write this book. Without him, this amazing (and terrifying) opportunity wouldn’t have found me. He has been amazing throughout the process of writing this book, and his patient knowledge sharing allowed this first-time author to really find his feet and enjoyment in writing.

The Cockroach Labs team The Cockroach Labs team is among the smartest people I’ve ever met. They’re incredibly dedicated to their database and its customers and are a big reason for my affection toward CockroachDB. I’d like to thank the following people from Cockroach Labs (past and present) for their help, inspiration, hospitality, and friendship: Jim Walker, Jeff Miller, Carolyn Parrish, Jordan Lewis, Bram Gruneir, Kai Niemi, Daniel Holt, Glenn Fawcett, Tim Veil, Jessica Edwards, Dan Kelly, Lakshmi Kannan, Spencer Kimball, Peter Mattis, Ben Darnell, Nate Stewart, Jesse Seldess, Andy Woods, Meagan Goldman, Megan Mueller, Andrew Deally, Isaac Wong, Vincent Giacomazza, Maria Toft, Tom Hannon, Mikael Austin, Eric Goldstein, Amruta Ranade, Armen Kopoyan, Robert Lee, Charles Sutton, Kevin Maro, James Weitzman, and anyone I’ve failed to mention.

Table of Contents
Index 249
About the Author
Rob Reid

is a software developer from London, England. In his career, he has written back-end, front-end, and messaging software for the police, travel, finance, commodity, sports betting, telecom, retail, and aerospace industries. He is an avid user of CockroachDB and has worked with the Cockroach Labs team in recent years to promote the database and embed it into development teams in the United States and the UK.

 
About the Technical Reviewer
Fernando Ipar

has been working on and with open source databases since 2000, focusing on performance, scaling, and high availability. He currently works as a Database Reliability Engineer at Life360. Before that, he has worked at Perceptyx, Pythian, and Percona, among other places. When not working, Fernando enjoys going to plant nurseries with his wife and playing music with their children while being a good service employee for the family’s cat.

 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.227.46.229