Paul: Hi there, and welcome to PodRocket. Today we're joined with Aydrian Howard, who is a developer advocate over at Cockroach Labs with over eight years of development, Cockroach DB. It's a distributed SQL database designed for speed, scale, and survival. And Aydrian's with us today, we're going to be talking about key functionalities, use cases, the roadmap that's coming up, and some endeavors that you've been going into recently with Cockroach on the Edge and with some popular framework such as Next.js. Thrilled to have you. Welcome Aydrian. Aydrian: Hey, thank you. Glad to be here. Paul: So how long have you been with Cockroach Labs? That's the company that puts out CockroachDB, right? Aydrian: Yes, we are the creators and maintainers of CockroachDB, so I believe it's the world's largest open source project. Written and go. I have been there about a year and a half, so I started in September of '21. Paul: In the time there, did you come to Cockroach because you were a database aficionado from the start and you were really attracted by the cool stuff they were doing, or how'd you end up at Cockroach Labs? Aydrian: I've worked at another database company and I've not really been into databases a lot growing up. So if you look at all the engineers, we have just geniuses working on some of the hardest problems in computer science. That's what databases are. I don't geek out on it that way. I come from the application developer perspective. So I'm building all of these things. I was originally a front end developer, and then I kind of went full stack and then I pivoted into developer relations. And so I went through this time where I kind of had a love hate relationship with databases because if you wanted one in your application, you had to shell out all this money and I'm cheap. So I didn't do things for the longest time, but I worked for MongoDB a while ago, and then I kind of took a break and went back into the communication space, working with email and texts and all of that, and then decided to come back and come back to a kind of more SQL relational database this time. Paul: So you really went around the world. Document and now you're back into relational and SQL. Aydrian: Yes. Paul: Yeah. I mean, your engineers must be solving the hardest problems on the planet because what Cockroach does is pretty wild. I'd love to break it down real quick for any listeners that are tuning in who might not be familiar with Cockroach. Could you give us the elevator pitch? Aydrian: Yeah. So CockroachDB, it was actually really built from the ground up to solve today's data problems. So it's cloud native, we deploy onto Kubernetes and that kind of architecture. We're distributed so we can host data all around the world, and then we have strong consistency and asset compliant transactions. So it's really a cool database. It's made up of nodes. All the nodes are read write, and they can even survive a node failing. So one thing that I love about when we're out at conventions is we have this demo called Cube Doom, where the aliens in Doom, I might be dating myself here, but the aliens in Doom are actually represent different nodes in a CockroachDB cluster. And whenever you kill them, it actually kills the node. And so you can see in the admin consoles, the node dying, draining out, rejoining, healing itself and becoming part of the cluster again. So that's really cool. And some of the things that we can bring to databases. Paul: And when you say node, we're talking about a distributed SQL database here. That that's really the cool thing that Cockroach is offering, amongst many other things, of course, but at its core, we're talking about a distributed database, right? Aydrian: Right. So something that not a lot of relational databases can do, we can scale horizontally. So in the old days with your Postgres and your MySQL, if you wanted to add more power to your database, you had to add ram, you had to add hard drive space. We can scale horizontally like a lot of document databases just by adding more nodes. And those can be physical machines, they can be virtual machines. A lot of our nodes are actually deployed on different clouds, so AWS or GCP for instance. And you can just keep adding those. So we recommend that you start with three that will allow you to survive single node failure, but if resiliency is something that you require, you can add more. I think if you do five, you can survive two nodes and et cetera. So we are using the raft protocol for that. Paul: I feel like this feels very modern tech to me as somebody who has always reached for a single node database or my SQL like database. But Cockroach isn't new, right? It's been around for a little bit. How old exactly is Cockroach? Aydrian: I want to say that the project itself is nine years old, and I think tomorrow we're celebrating Cockroach Labs eighth birthday. So the company has been around for eight years and the project has been around for nine, I believe. Paul: So it's an open source technology. And then there's the company, and I'm assuming the company, is it like the enterprise offering model and there's support and that's the company's role? Aydrian: Oh yeah, absolutely. First off, we were an open source project. You can still today, if you want to run a single node on your laptop for development, you can do that. You can even deploy whole clusters working things just from the open source. We've had customers who had been using us for years and we had no idea, and they came to us and they wanted to add the support and some of the enterprise features. And so it's amazing who comes out of the woodwork that's using it. But yeah, we also have an enterprise edition that adds some extra features. And then we also have a database as a service. So we have the Cockroach cloud where we have a couple offerings. We have dedicated where you can specify upfront all the resources that you want for each of the nodes and place them wherever you would like them to be. And then we also have, which is very exciting for me, we have a serverless option. So we've taken the concepts that are associated with serverless infrastructure, like elastic scale and consumption based pricing, and applied that to the database. And that's what's really cool because developers can start using it for free. We've given out a very generous, free tier 250 million request units a month and five gigs of storage. Back when I was building... Yeah, five gigs- Paul: Five gigs. That that's all I could ever need for most of my apps. Like gosh. Aydrian: I have multiple apps running on my clusters and it's so great. And you can either lock it to the free tier and you'll get throttled, or you can put in a credit card and say, "I'm willing to spend up to 25 bucks a month," and it will scale for you. But the great thing about the serverless is it can actually scale all the way down to zero. So my example is always if you're building, say a fantasy football app, most of the time people are going to be using it during football games, but it might actually be used for three or four days out of the week. And so the database will actually scale all the way down to zero, and then you'll pay nothing for that time. And so those 250 million request units go a very long way each month. Paul: That reminds me of why people reach to Cloud Run so often. I can post up a fully functional Docker container and that thing scales to zero when I'm not using, and that's the cheapest gosh darn way you can run anything. It's really nice. So on the database level, that's the thing now. You can have a zero... That's very cool. I'm sure. That's great. Yeah, you say, "oh, all my personal projects are running off of that." I'm sure I want to do that too, because running my own database under my stairs in the closet is a pain in the butt. The thing keeps crashing. I don't want to maintain that. So I reach to Cockroach and Cockroach Cloud as my first stop shop for using a database because in my eyes it's like, well, if I need something reliable and I'm not doing a gov cloud or something like that, and RDS is never going to go down. And in my eyes, I'm not going to toll it really hard, it's never going to go down. So why should I reach to Cockroach? Would you suggest that being a good first place to reach for as a developer? Aydrian: I mean, I think so. And I travel around the country. I lead our hackathon program, and so I'm going around to all these different colleges trying to get students to start using us and using for their products. But it's free to start. That doesn't hurt. Not having to deal with any of the infrastructure, any of the updates. You never have to worry about doing a security patch again. I know that back in the day, I would have my own Linux server and I'd host all my own stuff, and then next thing you know, a security patch would come out and then I would have to spend the weekend doing all that. It takes care of everything. And then we also have that scale. So you never know when your side project is going to be the next big thing and land up on the front page of Hacker News. So we can totally take care of that scale and grow with you, which I think is really cool. But as long as you are looking for a database that has asset compliance, can handle transactions, can handle the resiliency and everything, I think we're a great place to start, especially because one thing I haven't mentioned yet is we've implemented the Postgres wire protocol. So if you're used to using Postgres, then it's going to be super easy for you to continue building because you can continue to use any of your favorite clients out there. Paul: And speaking of the protocol, you all have done some work recently with Prisma. Prisma, I'm not sure if it's in beta still or alpha, but Prisma can connect directly into Cockroach on the native level, right? Aydrian: Oh, yeah. Prisma is my preferred way of connecting to Cockroach right now. Whenever I interviewed, I was like, "are you getting a Prisma connector?" And they're like, "we're working on it." I'm like, "okay, that's what I want to hear." But Prisma is really great because it can handle kind of the migrations of data. So I build all of my database schema in their schema language, and then I do Prisma DB push and it just builds everything. And CockroachDB handles all of the foreign keys, handles the different relations and things like that. And then whenever I need to make updates, I just do it in Prisma and it push it and it does a migration. But then the other thing is it takes that Schema file that you've created and generates a type safe client. So I'm trying to get better at using type script. And I think part of that is kind of this journey that I've been going on with Prisma because it's very nice to see things come out in the right types whenever you're looking through the database. Paul: If you're writing a DB query and you're wondering what fields are there, to have the Prisma client pop it up for you is... And then you throw GitHub code pilot in there and it's like [inaudible 00:11:13]. I'm like... Aydrian: Yeah, what fields? And then I think more importantly, what fields are required because how many times have you executed a script and you realized that you didn't pass over a field that was required? Paul: Those are ghost bugs that are so hard to catch that really Prisma saves you time down the line. I think it's amazing that Prisma offers that level of native connectivity to Cockroach because that opens the floodgate to people like you, Aydrian, to people like me. The Prisma swear bys makes it very easy for us to step into that ecosystem. So Prisma will let developers access Cockroach more easily, and there's things that are going on in the backend as well in terms of how can you access it, how can you connect to Prisma. So you put out some blog posts recently. One of them was focusing on Remix, which is an up and coming popular framework. I mean, that thing's exploding in popularity right now. Aydrian: That is part of my new favorite stack. I'm actually one of the organizers for Remix NYC. And so we have monthly meetups that I host at the Cockroach Labs headquarters. It's going to be really nice whenever the weather gets nice, because we have a great roof deck and everything. But no, that's what I'm really into right now and using it with Prisma. The great thing is Remix has custom stacks where people can put together like, "here's a stack that has this deployment with this set of component libraries and-" Paul: Like a prefab prefab? Aydrian: Yeah, prefab, where you can get really opinionated, but every one of them uses Prisma. And so I just wrote this little tutorial of how to switch any of those databases over to using CockroachDB and you're off to the races. So for people wanting to get started very quickly, but then also want to use CockroachDB, those stacks are really great. Paul: They're great because of the fact they use Prisma, which gives you that verbal capability to talk to all these databases of which Cockroach is in the... Gotcha. Okay. In the post that you put out about using Remix with Cockroach, is the main message you kind of want to convey with that this is simple, there's prefab stacks, you should try it out, you should download it, and really offering a channel for people to try it out? Aydrian: Yeah, I think that's one thing that helps. The other thing is I just really talking about Remix because it really brings the joy of developing back. It's really focused on using the platform and the platform being the browser, and there's a lot of cool things that you can gain from it. If you turn off JavaScript, Remix applications still work because it's using the underlying technology that we've always used. I've been a web developer for a very long time. Again, not the date myself, but my first web application was written in regular ASP and VB script. And so we're doing the same things. People who love PHP are going to see very similar things to how they're doing it because we're using forms. We're using Submit buttons and things like that. And JavaScript just enhances an application. It's no longer a requirement. And so if you turn it off or you're in a situation where you still can't get good internet access in some parts of Africa and they might be using these slow phones, they can still get a very nice user experience. Paul: And you also have another post that's out using CockroachDB with Next.js and Vercel, which is sort of walking through an Next.js app and connecting on using the serverless options. Aydrian: So using the Vercel serverless functions along with Next.js, before I was using Remix, Next.js was kind of my framework of choice. And I'll still use it on occasion, but I think the main point of that was we also have an integration with Vercel. So if you are using Vercel and you want to get up and running with CockroachDB very quickly, you can go to the marketplace and click the button and it will set up your cluster and put your database URL in a environment variable, and then you're just ready to go. And so if you're interested in that whole ecosystem with Next and Vercel and CockroachDB again, we're just trying to make it really easy for you to get up and going. Paul: Awesome. So there's a prefab, Next.js integration and Vercel's making that easy with their project generation. And then Remix has just natively, the community is really great and they're putting out all these prefab stacks. One thing that I thought was interesting, they're all like music themed, right? The stacks? Aydrian: Oh, the stacks for Remix? Yeah, they're named after subgenres. Paul: Genres. Okay. That's right. Aydrian: So there's the K-pop stack. I made one, I haven't published it yet, but we called it the Roachella stack. Paul: The Roachella. So is Roachella, how many letters? R-O-A-C-H-E-L-L-A. Aydrian, that's nine letters. What are the nine technologies? Aydrian: Oh, that was just my subgenre. I didn't come up with all those letters, but give me some time and I'll think of some. Paul: Do the letters in the names correspond to... You know how they have the jam stack in JMS? Is it that same sort of thing with K-pop? Aydrian: No, I think they're just picking out genres. Paul: Gotcha, gotcha. Aydrian: Yeah, so they're just names. So there's the indie stack, the Blues stack, and I think the Rock stack that are the ones that Remix put out and then everybody's putting out their own. But yeah, I had a friend working on the K-pop stack with Netlify. Paul: All right, so we got these two great blog posts. We also said we're going to go over some of the interesting features of Cockroach. I mean every DB has special things that maybe attract some application, some other application. Cockroach has a whole basket of different plugins and things you can activate. One of the ones that stood out to me when I was watching another talk that you were giving a stream was about the TTL on Rose. That's one I haven't heard of offered before, which is kind of interesting. Wondered, when did that come onto the scene and what do you think is an interesting use case for using the TTL? Aydrian: So TTL has been around for document databases for a while. MongoDB has TTL indexes, and I think DynamoDB also has some kind of TTL. And so TTL is time to live. And so what we're doing is basically putting an expiration date on rows on a database. And I was very excited when we came out with this because again, we are a relational database and you don't usually see this feature on there. And so yeah, with row level TTL, you can set basically a time to live on a row row and it will be automatically deleted. And so this is really great for things if you are just writing data from an instrument and you only care about the last 30 days, because if you think about it, you're say checking the temperature every five seconds, that's a lot of records to hold for 30 days. And so if you don't care about that data outside of there, you can just have it automatically delete. For the example that I was doing on the livestream, it was for a shopping cart. So we have a lot of problems with abandoned carts in the e-commerce space because they actually have to put a soft hold on the inventory. So we won't go into that, but so that's why you get those emails. It's like, "Hey, you left this in the cart, do you want to do it?" And so what we did is we hooked up the shopping cart to a row level TTL, so that way after a day, the items just disappear from your cart and we don't have to worry about that. Paul: Do you feel like having row TTL at the database layer is in any way overstepping the responsibility of the database in a given application architecture? Or is that more the direction we want to move in? As a body of developers? Aydrian: I think it makes sense because otherwise you would have to implement it on the client side. Paul: Or some backend service. Aydrian: Some backend service and things like that. And you also have to remember that we're doing this in a distributed way. So the procedures that are running to take care of the data are close to the data. So you don't know where the data could be. So if you have shopping carts for people who live in Australia, maybe you have implemented multi-region and you're keeping their data close to them, the row level TTL will take care of the things in its own region. I like it because you set it up in the database and then if you decide to have a mobile client that's different from the web client, then you just get this functionality for free, basically. Paul: You mentioned multi-region. So multi-region is special because it lets us bring the data close to the customers, close to where they're physically located. So Cockroach, at its core, we already established it's a distributed system, so that means there's several nodes, several servers all working together. Now multi-region, is that another derivative layer on top? Can you kind of paint that picture for me? Aydrian: Yeah, so at first we were deploying multiple nodes for resiliency, and then it turns out you can deploy those nodes in different AZs and different geographic regions, which helps keep the data close to you. So you might have 25 plus nodes all around the world, but it still looks like one logical database to the developer, which I think is really cool. There's a load balancer on the front that just knows where to send your request so it gets the right data. And so you have situations where you have a global application, but think about the application that stores their data in US East one in Virginia, but they have someone in Australia that has to access it. They have all of those latency problems. And so on the front end we have CDNs that take care of the latency on the front end. And so now we have things like CockroachDB that will help with the latency on the backend because you can say at the table level, at the row level that this data needs to stay in this region. And it helps a lot for compliance because we now have GDPR. So if you have European customers, their data needs to stay in European data centers, and that's very easy to do with CockroachDB and the developer doesn't need to know that it's happening. So in other databases, you have to worry about setting up the sharding plan and making sure all of that is set. CockroachDB takes care of all of that underlying, so you just say, based on this column, this row stays in this region and it just happens. Paul: That is going to be immensely powerful because from my point of view, we have all these services coming on now that are like, "oh, two clicks. You can deploy your app to 93 countries." And it's like, doesn't matter if your database is still in US East One, it's not going to matter because... It will matter a little bit as I guess, but you still need to do that transaction. You still have that bottleneck. But this is going to make it really easy for me to say the tables of cart, inventory or whatever, that you interact with those on every page load. So those need to be distributed. Those need to be... Aydrian: Yeah. And what's great with CockroachDB is as we scale out nodes, we're not only scaling reads, we're scaling rights as well, so we don't have to worry about write latency, there's a lot of databases out there that whenever they do scale globally, whenever they distribute globally, then they're basically distributing reads. So the read access is really fast, but you still have that latency with the write, but that's not how we work because every node can do both. Paul: You're really using the machine for what it can give. So there must be some really well-engineered go... Thinking back to what you were saying, you have some of the best engineers working in your group, reforming this bottom data layer that's talking and whispering between these nodes, that's really neat to think about that this level innovation is going on within a Postgres context too, so that anybody can hook in and benefit from this. Aydrian: Yeah, I mean, the database itself is completely new. The Postgres stops at the SQL layer, so we have a whole query layer that translates the Postgres into what it needs to be able to find the data and the appropriate ranges and the appropriate nodes. I tell everybody, I was like, "if you're interested in this stuff, like the nerdy stuff, we have Cockroach University," which is our free online courses. And my favorite one is still the very first course, which is the introduction of CockroachDB and distributed SQL, because it will actually show you step by step what happens to the data when it goes through the query layer and how it gets stored. Because spoiler alert, tables are a lie. All of our data is actually stored in a key value store that's called Pebble, which is something that we rewrote RocksDB, which is written in C, and we wrote it in, and I matched the rest of the stuff. And so it's very interesting to see how things get chunked up, and that's really what allows us to do the horizontal distributed. Paul: A window of secret sauce into what's going on. So you're using RocksDB originally written in C, got some engineers working it in ToGo, so you can work with the rest of the stack. That's fascinating. And all this is open source too, so people can go check it out on the GitHub. Aydrian: I was like, there's no secret sauce. You can just look and see how we're doing everything. Paul: It's all out there for people to go learn from themselves. And yeah, you mentioned Cockroach University, that first lesson, you're really touting, you're saying it's a good one for people to go check out? Aydrian: I really enjoy it just because I've worked with other databases. I know how they scale. So when I worked at MongoDB, I had to do the same thing, but they scale out with a primary and two secondaries, and so they've got secondary reads. So it's different, but I don't know. I found it very interesting. And then we also put out a course on CockroachDB Serverless, which I have a talk that I do about how we architected it because if you think about serverless and serverless functions, you have the problem of Cold Start. And so we have how we've figured out how to get around most of the Cold Start and also be able to scale it out in a cloud native way. Paul: The serverless stuff is so exciting. I think it's driving a lot of innovation in the space. A few weeks ago we had Matt Robeno on from From Planet Scale who's doing testing of contacting database over http, not using the TCP layer. So you could hit Postgres straight from an Edge function. I mean, imagine if everybody was writing like CloudFlare workers hitting serverless CockroachDB? That's a nice world to live in. I'd like that. Yeah. Aydrian: Yeah. Paul: So Aydrian, if people wanted to find out more about Cockroach and get started, they can go to Cockroach Labs, like you mentioned, that first lesson. If you're writing, do you write on Medium? Post anywhere? Where can people find more blog posts from you? Aydrian: So we do have a blog. If you go to our cockroachlabs.com, you'll find our blog. So most of the posts that I put out are on there, but I also stream every week, every Tuesday at 3:00 PM Eastern. So I've been working on what I'm calling Fur Reel, which is a B reel clone for pets. So yeah, F-U-R. And so I've been building that in a Remix with Prisma and CockroachDB, and it's been a lot of fun. Paul: On Twitch? Aydrian: Yeah, on Twitch. Paul: Oh, what's your Twitch handle if people want- Aydrian: It's Adrian. So most places on the internet, I'm I-T-S-A-Y-D-R-I-A-N. Paul: Awesome. Well, Aydrian, thank you for your time coming on and talking about Cockroach and some of the cool, exciting features that are coming out. So we got TTL, the serverless stuff, and if people wanted to come watch your stream, go tune in. Aydrian: Yep, absolutely. Paul: Thank you again.