May 202554:383.5k views

20 years of hacking Postgres with Heikki Linnakangas (cofounder of Neon)

About

In this episode of Database School, I talk with Heikki Linnakangas, co-founder of Neon and longtime PostgreSQL hacker, to talk about 20+ years in the Postgres community, the architecture behind Neon, and the future of multi-threaded Postgres. From paternity leave patches to branching production databases, we cover a lot of ground in this deep-dive conversation.

Transcript

Everything we said

00:02

Aaron Francis

Hello, my friends. Welcome back to Database School, where, uh, some of the smartest people in i- industry school me about databases. Uh, very, very lucky to have Heikki here today. Heikki is one of the co-founders of Neon, which I'm sure you've heard of, and we'll talk a lot about, uh, during this interview. But going all the way back, I think more than 20 years now, i- if I remember correctly, it's like 22 years or something, you've been a Postgres developer, which they

00:32

very coolly call Postgres hackers. So that's kind of fun. Um, so thank you, Heikki, for being here, and do you wanna introduce yourself a little bit more?

00:40

Heikki Linnakangas

Thank you, Aaron. Uh, so yeah, I have been with the Postgres community since around 2003, depending on where exactly you count. Uh, I've been working, uh, professionally full-time on, on Postgres since 2006.

00:56

Aaron Francis

Wow. Yeah, so 19 years professionally. And then a few, a few years before that. Um, so you must have been a very young man when you got started. What, what got you into Postgres kind of there at the beginning?

01:08

Heikki Linnakangas

So I've, I always liked programming, like, that's always been a hobby even before I started to do that as a, as a job. Um, when I started to hack on Postgres, I, I was on paternity leave with my second child at the time. Uh, the... And he, she was a good sleeper, so I had a lot of, uh, you know, time on my hands.

01:31

Aaron Francis

Mm-hmm.

01:31

Heikki Linnakangas

Um, and I, you know, I've always been doing programming as a hobby. Uh, and I was really inter- interested in databases as a user of databases. I had been using relational databases at work, DB2 at the time, uh, so I wanted to look a little bit under the hood, like, well, what do database engines do, um, behind the scenes. So I started to look at, uh, different databases.

01:52

I think I looked at the MySQL code a little bit and, uh-

01:54

Aaron Francis

Mm

01:54

Heikki Linnakangas

... uh, but then I found Postgres, and I just spent a lot of time just reading the Postgres source code and, and, uh-

02:01

Aaron Francis

Hmm

02:01

Heikki Linnakangas

... reading the discussions on the hackers mailing list and, and kind of started to submit some small patches and, and got into that.

02:09

Aaron Francis

So I'm curious, uh, what was it that you looked at MySQL and you're like, "Nah, I'm not touching that at all"? Was it the closed source nature? Was it the code? What, what was it?

02:18

Heikki Linnakangas

It, I mean, it was very open source back then already. I mean, this is GPL. That was way before-

02:22

Aaron Francis

Yeah

02:22

Heikki Linnakangas

... any of the Oracle stuff happened. Um, so there was, I was fine with that aspect. I don't remember if there's an, I don't think there was anything that particularly turned me off, uh, from MySQL. It was just that I, I found the Postgres code, uh, much nicer-

02:34

Aaron Francis

Hmm

02:34

Heikki Linnakangas

... to work with.

02:36

Aaron Francis

Did you dive in at a certain, uh, like did you go in with a feature in mind you wanted to... Like, I guess, your first patch, what was that process like? Did you have something that wasn't there, or something you thought could be better, or something that somebody else was asking for? How did that work? Hey, we'll get back to the interview in just one second, but since you're here, you like databases, you probably like Postgres.

02:59

Let me tell you about Mastering Postgres. This is a course that I am teaching. This is a way that you can master the most important part of your stack, your database. So go to masteringpostgres.com. Okay, back to the interview.

03:15

Heikki Linnakangas

Uh, so the, the first bigger patch I did was two-phase commit, um, and that was just something that I, I found interesting. Uh, it was not something that a- anyone asked for. In, in fact, I don't know if a lot of people have used that feature since. It's like a table stakes feature that all the, all databases have, but I don't know if there are a lot of people using it. And I kind of regretting the, I've kind of regretted doing that afterwards because it's been kind of a pain in the ass in the last 20 years to keep, maintain that feature-

03:43

Aaron Francis

The last 20 years.

03:44

Heikki Linnakangas

... and have it work together with all kinds of other stuff. But, um, but oh well. Um, I, I'm sure there's someone using it out there. Uh, if anyone is using it, uh, you know, get in touch and let me know.

03:54

Aaron Francis

Yeah, please, make it all worth it.

03:56

Heikki Linnakangas

Exactly.

03:57

Aaron Francis

Send an email, for goodness sakes. Um, so I'm curious about kind of the nature of how, uh, how Postgres handles itself because from, from my understanding, it's all done via this, this mailing list. Um, there's no, like, I guess no like, you know, central authority.

04:18

There's definitely no benevolent dictator. Um, so how do you find that, uh, that process or that governance working? And you've been doing it for 20 years now, so it must be working okay. But are there parts of it, um, that you think work really well or, on the other hand, parts that could be improved about the actual, like, governance and contribution parts?

04:40

Heikki Linnakangas

I'm pretty happy with how the project has gone. Like, and, and I think we've, I've always been very happy with the decisions we've made as a community. The, I guess the... I mean, it's not that unusual if you look at how other big open pr- source projects work. Uh, I mean, each one is slightly different. You mentioned-

04:58

Aaron Francis

Mm-hmm

04:58

Heikki Linnakangas

... there's no benevolent dictator, which is true, uh, although we do put, we do give a lot of on, on unofficial way to people who have been with the project for a long time and kind of, uh, have been there from, from, from the early days. But I think the, and the, like, the committers are a self-selecting group of people.

05:17

Aaron Francis

Hmm.

05:17

Heikki Linnakangas

Uh, and I think we try to select for people who have, uh, who are easy to get along with and who kind of share the same vision of where the project should go. So I think that helps, and everyone has very high, you know, personal, everyone feels very high personal responsibility of the project.

05:32

Aaron Francis

Hmm.

05:33

Heikki Linnakangas

Um, now for the downsides, I think it's very har- like the, it's a very decentralized community, so if there's, if there was some big, like, decision that needs to be made, that's really difficult and it's, uh, sometimes hard to, like, find... Like it's, it's hard to make decisions, basically. There is no well-defined, you know, voting system or anything like that, so if there's anything that is even slightly controversial, or even if, even if it's not, it's kind of hard for someone to say that, you know, "Let's do X," and then- You know, how do you even determine if that's

06:03

gonna fly or not? I mean, there's no-

06:05

Aaron Francis

Mm-hmm

06:05

Heikki Linnakangas

... formal process for approving anything in particular. Um-

06:08

Aaron Francis

So how do you determine that? Because, like, I, you know, I'm in, I'm in the PHP world, and there's, like, there's no, you know, benevolent dictator there. Everything is done by this steering committee. But there is, like, an RFC process, and there's, like, a two-thirds vote that ratifies or, like, accepts any, like, new language features or anything big like that. And while it can be a little messy, it works pretty well because it's like, well, if 66% of the people say, "This is a good idea," well, it's probably a good idea.

06:38

So w- w- is it just, like, back channeling and, like, talking to people and trying to get a consensus? Or how does that actually work?

06:45

Heikki Linnakangas

It's, yeah, it's talking to people. It's trying to reach consensus. That, like, the consensus building is a big part of it. Uh, and, and we try to make all the decisions on the hackers mailing list. Um-

06:54

Aaron Francis

Mm

06:54

Heikki Linnakangas

... so kind of what the decision-making process, you know, or the lack of, is kind of visible from the threads on, on hackers.

07:02

Aaron Francis

Mm-hmm.

07:02

Heikki Linnakangas

Uh, so the way it usually goes is that someone proposes something, and then one of the committers picks that up and says, "Yeah, that sounds like a great idea." And if he thinks that, you know, no one is particularly objecting to that, then they go ahead and commit it. If it's a bigger change or, uh, then it, then it's harder. It can be hard to, for example, decide to deprecate some features or remove something-

07:23

Aaron Francis

Mm

07:23

Heikki Linnakangas

... because there is always someone who's using that feature. It might be a very small minority, but there's always someone. Or, uh, dropping, uh, support for old platforms.

07:33

Aaron Francis

Mm.

07:33

Heikki Linnakangas

That's been something that, you know, Postgres, we've, we've been kind of proud of supporting everything from, you know, old obsolete architectures, to PlayStations, to, to modern hardware. Um- But, uh, I think in the recent years we've actually been more aggressive in dropping support for things that, for, for systems that we don't have, so anyone maintaining, like, a build farm member, for example.

07:53

Aaron Francis

Mm.

07:53

Heikki Linnakangas

Uh, like, that's a pretty good, um, minimum requirement to support the platform, that there is someone actually, you know, at least building your, your software on it.

08:01

Aaron Francis

Yeah. That, that makes sense to me. So in the case of, like, um, getting somebody, getting somebody to commit, does it just require one person who is, as you said, self-selected into this group of committers? Does it just require convincing one of those people to say, "Yeah, we'll put, we'll throw this in"?

08:18

Heikki Linnakangas

Yeah. Basically, basically that's it.

08:20

Aaron Francis

Wow.

08:20

Heikki Linnakangas

Of course, if someone, if someone objects, that's a different story. Like, if, if it's not uncontroversial, then it's a lot harder-

08:26

Aaron Francis

Mm-hmm

08:26

Heikki Linnakangas

... to reach the decision. And as I said, there's no formal process, so, you know, how do you even, how do you even decide what the consensus is? That's not well-defined. But, but we, like, we have a high level of trust, uh, between the committers, and-

08:39

Aaron Francis

Yeah

08:39

Heikki Linnakangas

... the, like, that has worked remarkably well for us.

08:43

Aaron Francis

Well, if you had to guess, I know you're not gonna know this, but if you had to guess, what do you think the average tenure of, like, one of these, one of these, like, uh, I guess inner circle people in the, in the pg hackers group is? Are they all, like, kinda like lifers, like you have been around for 20 years? Or is it a pretty, uh, revolving door?

09:03

Heikki Linnakangas

It's, there's a lot of old-timers. There's a l- there's a lot of people still around who have been in the project-

09:07

Aaron Francis

That helps

09:08

Heikki Linnakangas

... longer than I have. Uh-

09:09

Aaron Francis

Wow

09:10

Heikki Linnakangas

... but, but there's also new people coming all the time, so it's, it, it keeps changing. And people, uh, and sometimes people are more active in the project, and they, they might go away, and they might come back, um-

09:21

Aaron Francis

Mm-hmm

09:21

Heikki Linnakangas

... do, do something else, uh, in between. So it's, uh, it's not a hugely growing community, like the core of developer community.

09:30

Aaron Francis

Mm-hmm.

09:30

Heikki Linnakangas

And that's something we always keep talking about among ourselves, like, how do we attract more people? How do we get new blood into the, into the system? Um-

09:38

Aaron Francis

Mm-hmm

09:38

Heikki Linnakangas

... but if you look at the actual, like, traffic on the hackers mailing list, it has been relatively flat for the last, I don't know, five or 10 years. Uh, it's not growing, but it's not shrinking either. Um-

09:48

Aaron Francis

Mm-hmm

09:48

Heikki Linnakangas

... so I, I think we're in a, in a fairly good s- uh, place. I think we have the, we have enough people contributing that it, it is, you know, a sustainable system.

09:58

Aaron Francis

Yeah. That makes sense that there would be a lot of old-timers, because it sounds like the way that this operates requires just a huge amount of trust between, like, a bunch of different parties, and the fact that y'all, some of y'all have known each other for more than a decade probably helps that be way less messy than if you were trying to get that particular thing started now with a group this size.

10:23

I have to imagine way back in the day, the group was much smaller, and so the, you know, the average tenure being lower wasn't that big of a deal. But now that Postgres is so big, you do have to have a core set of people that, like, trust each other to operate in good faith and make good decisions.

10:39

Heikki Linnakangas

Sure. And, and the project, like the core project, hasn't grown that much though. Like, uh, there's a lot of new stuff around Postgres and a lot of new projects using Postgres. There's a lot of, you know, people building new applications and frameworks and whatnot around Postgres. And, uh, like, the ecosystem has grown a lot.

10:55

Aaron Francis

Mm-hmm.

10:55

Heikki Linnakangas

But the core product and the core team, uh, uh, working on the, the actual SQL engine, it's not that much larger. Um, but it's-

11:04

Aaron Francis

I see

11:04

Heikki Linnakangas

... definitely become more popular, and there's a lot... The user base has grown dramatically.

11:08

Aaron Francis

Yeah.

11:08

Heikki Linnakangas

And, uh, and the whole ecosystem, like, there's a ton more extensions. There's a ton more kind of connection poolers or kind of-

11:15

Aaron Francis

Mm-hmm

11:16

Heikki Linnakangas

... tutorials, you know, uh-

11:17

Aaron Francis

Mm-hmm

11:18

Heikki Linnakangas

... learning material, course material on-

11:20

Aaron Francis

Yeah

11:20

Heikki Linnakangas

... how do you use Postgres in various environments. So that side has grown a lot.

11:24

Aaron Francis

And lots of new companies. So you've been-

11:27

Heikki Linnakangas

Yes

11:27

Aaron Francis

... working on, you've been working on Postgres for more than 20 years. You decided a few years ago now, you che- I have checked my math, maybe four years ago. Does that sound about right?

11:36

Heikki Linnakangas

Yes, four years ago.

11:36

Aaron Francis

Okay. So you decided around four years ago, um, that you were gonna go out and co-found a company. Um, so... And I think, did you have your, I won't spill it, but did you have your unique insight at the time? Is that why you decided to start Neon, or did that come later? So tell us kind of the story of how you decided, "I wanna start a database company," which seems crazy to me, but, uh, it's working okay.

11:59

So tell us that story.

12:01

Heikki Linnakangas

So- From my, my personal perspective, this is what it looked like. Uh, so I got a call from a guy called Nikita, who was the founder of SingleStore at the time, or-

12:11

Aaron Francis

Mm-hmm

12:11

Heikki Linnakangas

... was, and CEO and founder of, of SingleStore, or also known as MemSQL. Um, so he reached out to me and saying, "Hey, I have this idea. I wanna start a Postgres company. You know, would you join me?" And, uh, so I looked at the proposals, so I spoke with him, uh, and it made a lot of sense. I, like founding a company was not in my cards. It was not something I would've probably done, would have done otherwise, but, uh, but it was made very easy for me to say yes.

12:37

Uh, and the more I looked at it, like it's been the right choice. Like I've enjoyed the, the journey a lot. I learned a lot about how to build a company and, uh, and, uh, and it's been a great ride. And the one thing that, like, the, the initial reasons why, why did I say yes was, uh, first of all, I think they had a great idea for the architecture, the separation of compute storage.

12:56

Aaron Francis

Mm.

12:56

Heikki Linnakangas

That just makes a lot of sense to me. Um, secondly, I wanted there to be, like if someone's gonna build this company, I wanna be part of that. Like, and I think it was important for the success of the company that, uh, one of the Postgres people who have been around for a long time, uh, join the effort and make sure that the company's built with the right values and, you know, community friendly, open to those friendly way, so that it doesn't just become one, you know, one, one more proprietary software company doing their own thing.

13:24

Aaron Francis

Mm-hmm.

13:24

Heikki Linnakangas

Uh, but actually contribute back to the community and, uh, do things in, in an open source way.

13:30

Aaron Francis

So when he came to you, um, he must have had a pretty compelling pitch to, to get you to go on this, this journey. But when he came to you, was that, um, was that architecture, was that one of like the inciting incidents for starting the company altogether, was what if we separate storage and compute? And then you were like, "Oh, we, we have to do this." Was that one of like the beginning things?

13:55

Heikki Linnakangas

Yeah. That was, that was, that was the first sentence all, that started the company. Like, "Let's, let's do this architecture." And this is not new. Like, uh, the, this is some similar to Amazon Aurora had done that before.

14:06

Aaron Francis

Mm-hmm.

14:06

Heikki Linnakangas

Uh, like we, so we knew how that architecture behaves already. Uh, it's not like we invented something from, all the way from scratch. Although, you know, after we kind of did the first version, we've done a lot of things differently and we learned a lot, a lot about what can, what are all the cool things you can do when you separate the compute and storage. So it's not the ex- It's not in clone or anything like that, but the kind of the idea was sound and we already knew that it would work and what the properties would be.

14:32

Aaron Francis

What about that architecture, um, what about that was so compelling to you that you looked at that and you're like, "Oh, obviously"? Because like you said, uh, you know, it had been done before or other people have done it. And so when you looked at it, why did that strike you as like so, uh, powerful?

14:55

Heikki Linnakangas

Yeah. So, so in Postgres I've been working on the write-ahead logging a lot, uh, a lot of things around write-ahead logging, how does, uh, backups, restore, uh, point in time recovery. Uh, it was, uh, one of the big features I wrote on like 15 years ago, maybe 20 years ago, was, uh, streaming replication, um, and the point in time recovery stuff in Postgres.

15:16

So I, I've spent a lot of time with the write-ahead log and all, all the cool things you can do with that. And, uh, and the kind of the separation of compute and storage, it all comes... Like it's all built on the idea of that the write-ahead log is what matters. That's the, uh, you know, the system of record. That's where all the changes go.

15:35

Aaron Francis

Mm-hmm.

15:35

Heikki Linnakangas

And, uh, uh, because it allows you to do cool things like the, the point in time query, time travel query, branching, all of those things. And they're all kind of based on the idea that you take the write-ahead log stream, and then you just massage the data and the log into a different format that makes it accessible. So it was, it was kind of, that fitted really well into what I had been working on, and it solves a lot of practical problems with backups, uh, with the point in time recovery, uh, snapshots, all that kind of stuff that I, I think is really cool.

16:05

And, uh, and it can be hard to set up, for example, or replication and, uh, disaster recovery, like HA system with regular Postgres. Uh, I mean, there's like a million tutorials out there on the internet how to do that, so it's not like it's an unsolved problem. Uh, but you always have, like, it's a bit fiddly. Like you have to manage your backups, and you need to have a system where you take a, you know, do the wall archiving and stuff, and kind of integrating all that into the storage system just makes a lot of sense to me, and it solves a lot of these problems in a, in a nice

16:35

way.

16:37

Aaron Francis

So Nikita comes to you, gives you this pitch. You guys develop this, this vision together. At this point, so we're in 2021. At this point, what is the, uh, state of being able to separate storage and compute in Postgres? Nascent, non-existent, mature? Like where do we stand at that point?

16:59

Heikki Linnakangas

Oh, non-existent. Like that-

17:00

Aaron Francis

Mm-hmm

17:00

Heikki Linnakangas

... you know, that doesn't exist in Postgres itself. Uh, but the, the basics are there, like the write-ahead log, it's all based on the write-ahead log. So obviously that thing is already there and, uh, kind of the building blocks are already there. So we had to make some small changes to Postgres to make that work. Like there is no-

17:16

Aaron Francis

Mm

17:17

Heikki Linnakangas

... you know, ready-made extension point for the, for what we're doing, which is like replace the storage engine. Um, but we were able to hook into, uh, it's a small-

17:25

Aaron Francis

It's a pretty big hook to have. Yeah.

17:27

Heikki Linnakangas

It's, it's not really. Like, uh, the, you know, the patch is out there-

17:30

Aaron Francis

Sure

17:30

Heikki Linnakangas

... if you want to go on GitHub, but it's a, it's a small patch.

17:32

Aaron Francis

Okay.

17:32

Heikki Linnakangas

Like I'm actually very proud of how small that is 'cause I was working on, be- before Neon, I was working on Greenplum, which is a, uh, it's a fork of Postgres, al- also open sourced, although they went closed source.

17:43

Aaron Francis

Okay.

17:44

Heikki Linnakangas

Like they, they've gone back and forth on that. Uh, but at the time it was, uh, open source and, uh, and it's a big patch. Like it's a, it's a major, it's a major fork of Postgres. And I've kind of done that for a long time, and when we founded Neon, I, I, I didn't wanna do that again. Like I don't wanna maintain a fork of Postgres.

18:03

Aaron Francis

No.

18:03

Heikki Linnakangas

Uh, so, so that patch is quite small and, and we haven't been able to get rid of it completely, but we, mostly because we haven't put enough effort in that, to be honest. Like we, we, that's always on our to-do list, but it's never reaches the top of the priority list. But we would still like to get rid of the patch completely eventually, so you could run just unmodified Postgres on the Neon storage.

18:25

Aaron Francis

Hmm

18:25

Heikki Linnakangas

... but even today the patch is quite small, so I'm, I'm proud of that.

18:29

Aaron Francis

So y'all got started, Nikita's off doing whatever Nikita does, probably closing deals. Whatever, whatever CEOs or, you know, these business guys do. So he's off doing all this stuff, and you're, like, getting stuff landed into Postgres to support this separation. How long was it between like, "Hey, here's my proposal. Great, let's be co-founders," to, "We're ready to go.

18:52

Let's, let's bring on a, a beta customer"? What was that process like?

18:56

Heikki Linnakangas

Oh, gee. I don't remember the timeline off the top of my head, but I think it took, like, somewhere between three and six mon- maybe six months before we-

19:04

Aaron Francis

Hey, that's not bad at all

19:05

Heikki Linnakangas

... we, like, we, we had, like, the rough prototype version of e- of everything.

19:08

Aaron Francis

Yeah.

19:09

Heikki Linnakangas

Um, I don't think we had... I think it took another six months before we had the first customers. Um, and, like, there were, there were a few milestones, like our Hacker News posts that people were excited about-

19:19

Aaron Francis

Mm-hmm

19:20

Heikki Linnakangas

... that. And, uh, then we opened it up for, uh, for, like, closed beta. Like, that was exciting times when you start to have-

19:27

Aaron Francis

Mm-hmm

19:27

Heikki Linnakangas

... people actually using it and giving you feedback. Um, but then, yeah, I don't remember the timeline. I think it took us about, about a year or two years before we started to, you know, gradually have people pl- playing with it and, and finally actually paying us for the service as well.

19:44

Aaron Francis

Yeah. That's, that's not bad at all for something that seems pretty fundamental to me. I know you'll claim it was a small patch- ... and, you know, it's like, I don't know, man, that seems like a lot. Um-

19:54

Heikki Linnakangas

But then there's a lot of, like, that was the... That's the part I, I find most, most interesting, like, that core technology of separation, of compute-

20:01

Aaron Francis

Mm-hmm

20:01

Heikki Linnakangas

... and storage. But to actually run a cloud service to do that-

20:04

Aaron Francis

Hmm

20:04

Heikki Linnakangas

... there's a lot of other stuff you need to build. So roughly, roughly half of the engineering effort goes into the core, you know, Postgres, the storage, uh, what we call platform engineering.

20:16

Aaron Francis

Mm-hmm.

20:16

Heikki Linnakangas

And roughly the other half actually goes into the control plane of just managing this fleet of, of nodes and Kubernetes and, uh, billing, the user interface- ... public-facing APIs. All the... There's, like, a laundry list of stuff that you need to have, and it's cr- it's critical that both sides are working. Um, and it's kind of interesting, like, we spoke to other people who have done, like, run cloud services.

20:38

Like-

20:38

Aaron Francis

Mm-hmm

20:38

Heikki Linnakangas

... I think other people, like, many other people said the same thing, that it's roughly 50/50 between your core-

20:43

Aaron Francis

Wow

20:43

Heikki Linnakangas

... you know, database internals and the other stuff, which, which holds for us as well.

20:50

Aaron Francis

Man, that is, that sounds like a... Like, if you, if you take it out of, like, cloud platforms, that sounds like running a business. 50% admin, 50% doing the actual work. And it's like, man, doing the admin stuff is never as fun as, like, doing the actual work. And, uh, it sounds like you feel the same way. You like working on that core stuff and not so much the-

21:10

Heikki Linnakangas

Yeah. Although I wouldn't call it-

21:11

Aaron Francis

... the billing engine

21:12

Heikki Linnakangas

... admin stuff. Like, that other cloud, you know, the control plane stuff is also important. It's, it's also like-

21:16

Aaron Francis

Sure, yeah

21:16

Heikki Linnakangas

... serious engineering work.

21:18

Aaron Francis

It's, it's not the core stuff that you love.

21:20

Heikki Linnakangas

Sure.

21:20

Aaron Francis

You know?

21:21

Heikki Linnakangas

Yeah.

21:21

Aaron Francis

Yeah. So Neon, uh, Neon, uh, like, bills itself as serverless Postgres.

21:29

Heikki Linnakangas

Hmm.

21:29

Aaron Francis

And serverless means a lot of things, and it means no things. So tell us, when, when you say serverless Postgres, we've talked a little bit about, you know, the fundamental insight of separating storage and compute. So when you say serverless, make that word more rich for us. What does that mean to you?

21:48

Heikki Linnakangas

Sure. So yeah, as you said, it can mean a lot of things. I think from a user's point of view, the way I think about it is that when a server, when a service is serverless, it means that you don't think about what's running behind it, like you don't think about the servers.

22:01

Aaron Francis

Okay.

22:01

Heikki Linnakangas

I mean, there's always a server.

22:02

Aaron Francis

Of course.

22:03

Heikki Linnakangas

Well, basically, you know, software runs-

22:04

Aaron Francis

Yeah

22:04

Heikki Linnakangas

... on servers, but you don't think about it, and you think about it as a service that is just always there, and you connect to it, and you use it, but you don't, you know, configure the size of it, or you don't think about where it's running. That's from the user's point of view. But I can also walk through, like, what happens when you're using Neon.

22:21

Aaron Francis

Yeah.

22:22

Heikki Linnakangas

So when you use Neon, what you get is a connection string, like a Postgres-

22:25

Aaron Francis

Mm-hmm

22:25

Heikki Linnakangas

... connection string, host names or blah, blah, blah. Uh, and you put that in your application, or you can connect that to, to that directly with psql and run queries. Now, when you connect that, that URL, what happens behind the scenes in Neon is that we, we, first of all, we have a proxy that kind of takes the connection. Uh, like, that's the first thing you speak with.

22:48

You perform authentication, and the next step is that the proxy sees, like asks, asks the control plane, "Is this database currently running?" Like, "Is there a server running? Is this-

22:58

Aaron Francis

Hmm

22:58

Heikki Linnakangas

... is this server currently running?"

23:00

Aaron Francis

Mm-hmm.

23:00

Heikki Linnakangas

And if it's not, then we'll, uh, launch a Kubernetes pod, uh, and a VM that runs in a pod. Like, we launch Postgres at that point on, when you connect.

23:11

Aaron Francis

Okay.

23:11

Heikki Linnakangas

And, uh-

23:12

Aaron Francis

And how, how fast is that these days?

23:14

Heikki Linnakangas

So yeah, there's an interesting story on that, too. Like, when we started, we, like, we, we did, like, what I just said. We just actually start the pod, and that took about five seconds, uh-

23:24

Aaron Francis

Okay

23:24

Heikki Linnakangas

... to run, launch a Kubernetes pod, connect the connection to that, and until you can start to run queries. And we got a little feedback on that, like, "That's too slow." Like, uh, you know, "Neon is awesome, but this, this cold start latency, that's killing us." Uh, so we started to work on that, um, and we, we got it down by having, creating a, uh, pool of VMs pre-created and pre-warmed.

23:45

Aaron Francis

Hmm.

23:45

Heikki Linnakangas

And, uh, you know, lots of other tricks. We really looked into what goes, what happens when you connect, and, uh, got the latency down to about one second.

23:53

Aaron Francis

Hmm.

23:53

Heikki Linnakangas

Uh, and that's when we stopped getting that feedback. Uh so we don't care about that anymore.

23:57

Aaron Francis

That's great.

23:57

Heikki Linnakangas

People are happy-

23:58

Aaron Francis

Yeah, that's great

23:59

Heikki Linnakangas

... with the, with the cold start latency now, which is about 700 milliseconds, I think.

24:02

Aaron Francis

Okay.

24:03

Heikki Linnakangas

Uh, depending on, you know, which parts you actually, which parts you count. Uh, but we got it down to about 700 milliseconds, but that seems to be the tipping point. Like, somewhere between one second and five seconds, that's where people think it's-

24:16

Aaron Francis

That's where people are not happy

24:16

Heikki Linnakangas

... either too slow or, or great.

24:19

Aaron Francis

Okay. So I interrupted you. So, uh-

24:21

Heikki Linnakangas

Yeah

24:21

Aaron Francis

... you got a query string ... fire up a pod if one is not, or a VM in a pod if one is not running. Okay. So keep going.

24:29

Heikki Linnakangas

Uh, yeah. I think that's pretty much it. Like, so you, once you start or laun- once you launch the VM, or we take one of these pre-created ones-

24:36

Aaron Francis

Mm-hmm

24:36

Heikki Linnakangas

... uh, and then you, you, uh, you connect to that, and, uh, off you go. Then, uh, you can run queries. And then-

24:43

Aaron Francis

So-

24:43

Heikki Linnakangas

... if the da- if the database is idle for more than five minutes, or you can configure it, but the default is five minutes, then we shut it down again. And then-

24:51

Aaron Francis

Mm-hmm

24:51

Heikki Linnakangas

... the next time you connect, we launch it up again, and that's, that's all transparent to the users.

24:56

Aaron Francis

So this may be a dumb question, and if it is, forgive me, but we'll pretend I'm asking on behalf of the audience. I already know this. We'll just pretend. So you fire up this, uh, you fire up this compute, but we've talked about the storage is separate.

25:10

Heikki Linnakangas

Mm.

25:10

Aaron Francis

Where is this storage living, and how do you route those two things together, uh, inside that 700 milliseconds? I-

25:19

Heikki Linnakangas

Right

25:19

Aaron Francis

... imagine that's done then.

25:20

Heikki Linnakangas

So the, the core of the storage then is, uh, it's, uh, there's a set of servers that we call page servers because they-

25:27

Aaron Francis

Okay

25:27

Heikki Linnakangas

... serve, well, pages of data-

25:29

Aaron Francis

Yep

25:29

Heikki Linnakangas

... uh, to Postgres. And, uh, they, like they are continuously running, like we keep that fleet running, and we balance the tenants, like which database lives on... It's a multi-tenant service, so, like-

25:39

Aaron Francis

Mm-hmm

25:39

Heikki Linnakangas

... every page server holds, holds the data for many, many, many users. Um, and ultimately, all the data lives in, uh, Amazon S3 or Azure storage, like object storage. Uh-

25:52

Aaron Francis

Mm

25:52

Heikki Linnakangas

... so the page servers are also kind of a cache of the object storage. Uh-

25:57

Aaron Francis

Got it

25:57

Heikki Linnakangas

... but it's b- it's that fleet of servers that, like the storage servers that we, we manage separately from the compute. Like again, separation of compute-

26:04

Aaron Francis

Mm-hmm

26:04

Heikki Linnakangas

... and storage, so we can scale the storage layer independently. And, uh, and when the database is not active, it doesn't use a lot of resources. It's just a few files on disk on the page servers, or if it's been inactive for a very long time, we don't keep even that, and we just download the stuff from the object storage, uh, if it's needed again.

26:24

Aaron Francis

Yeah. So that was gonna be my next question. So if it's been, if it's been asleep for a long time, you just, you just delete it off the page servers and-

26:32

Heikki Linnakangas

Yeah

26:32

Aaron Francis

... rely on when it comes back, so when the next request comes in, as a part of the initialization phase, you notice that, that those pages are not on the page server. You read through it to S3 and pull it to the page server, and then you're back in action?

26:48

Heikki Linnakangas

That's correct. And so yeah, if you, if the, if the database has been inactive for a long time, I don't remember if it's weeks or a month or something-

26:55

Aaron Francis

Mm-hmm

26:55

Heikki Linnakangas

... uh, then we, then we do that, and then you will get a slightly, like even a slightly larger cold start latency the first time because-

27:01

Aaron Francis

Yeah

27:01

Heikki Linnakangas

... the stuff needs to be downloaded back. Although it's not as, you know, it's... Most people don't notice that. Uh, like it's, it's small enough, and much of that is, kind of happens at the same time with the, with the roughly one second latency you have anyway.

27:15

Aaron Francis

Mm.

27:15

Heikki Linnakangas

So it doesn't add too much to the, to the latency. But-

27:19

Aaron Francis

Smart

27:19

Heikki Linnakangas

... but realistically, if your database has been inactive for a week, and then it takes a few seconds longer, like no one pays attention to that.

27:26

Aaron Francis

Yeah. That's, that's smart. Talk to me about, um... Talk to me about these workloads that are, that are going to sleep. What is the shape of these, these workloads where people are like, "Yeah, let my... Like I'm not using my database often enough to keep it awake." So what is the segment of the market that is, that that is like, "Yeah, that's me." Because I'm thinking- I'm thinking, well, that's not very many requests per second, much less like requests per day to keep

27:56

the database awake. But you're saying a lot of them do go to sleep, and people-

28:00

Heikki Linnakangas

Mm-hmm

28:00

Aaron Francis

... love that they wake up quickly. So help me square that circle. Who, who's using this, uh, this feature?

28:05

Heikki Linnakangas

Well, a lot of people are just using it for one-off experiments. That's, that started. So a lot of the databases are inactive simply because they don't contain any interesting data. Uh-

28:14

Aaron Francis

Mm

28:14

Heikki Linnakangas

... but that's kind of not a very interesting class of databases. But we do, like I do jokingly say that we are the best platform for running emp- empty databases, like we're- There is a surprisingly large fleet of those. Uh, but aside from those, those-

28:28

Aaron Francis

That's a good bit. I like that bit.

28:31

Heikki Linnakangas

Um, aside from that, there's a lot of, uh, like l- l- or because paying customers are actually like SaaS companies who have, um-

28:40

Aaron Francis

Mm-hmm

28:40

Heikki Linnakangas

... it's very convenient to write your application in a SaaS way where you have one database per tenant. Uh-

28:46

Aaron Francis

Mm

28:46

Heikki Linnakangas

... but most of your users for a SaaS application would be inactive most of the time. Uh, so it kind of-

28:52

Aaron Francis

Okay. So that's a-

28:53

Heikki Linnakangas

... goes to that

28:53

Aaron Francis

... that's a big one, is multi-tenancy-

28:54

Heikki Linnakangas

Yeah, like we have customers who have-

28:56

Aaron Francis

... for your customers who-

28:57

Heikki Linnakangas

Right

28:57

Aaron Francis

... multi-tenant, uh, I see

28:58

Heikki Linnakangas

Like thousands of databases, but only a small fraction of them would be active at, at any given time. And all of them are, like small, but Neon is really good and cost-effective for that kind of workload where you have like large fleets of small databases, uh, mostly inactive.

29:14

Aaron Francis

That's interesting. Um, I have more questions, but let's pause there for a second. How are you, or how are they, I guess-

29:21

Heikki Linnakangas

Mm-hmm

29:21

Aaron Francis

... managing schemas across potentially thousands of little databases? Do y'all have workflows built into Neon, or is that something that they do on the application side? That seems like a lot. How are people managing this?

29:35

Heikki Linnakangas

That's, uh, we don't offer anything particular for that. So some of these, uh, basically just pass through the database as a, as an application platform. Uh, Vercel is a big partner for us. Uh-

29:47

Aaron Francis

Mm-hmm

29:47

Heikki Linnakangas

... the, and, and there's a few others like that where it's the end users who define their schema, and all of the schemas are different too.

29:53

Aaron Francis

Oh.

29:53

Heikki Linnakangas

So that's one class.

29:55

Aaron Francis

Okay. So-

29:55

Heikki Linnakangas

But then there's also-

29:56

Aaron Francis

Hold on. So that is-

29:57

Heikki Linnakangas

Yeah

29:57

Aaron Francis

... that is, uh, your customer is Vercel, but they are offering databases to their customers, which technically is truly multi-tenancy, but it's not multi-tenancy like I was thinking of, which is like I have a SaaS with a rigid schema, and I'm giving each of my customers the same schema, but in different databases.

30:19

Okay.

30:19

Heikki Linnakangas

Correct.

30:20

Aaron Francis

So I misunderstood-

30:20

Heikki Linnakangas

So that's-

30:21

Aaron Francis

... what multi-tenancy there

30:21

Heikki Linnakangas

No, no, no, that's, both of those are real. Like that's, that's one example-

30:24

Aaron Francis

Okay

30:25

Heikki Linnakangas

... uh, this, you know, where the data schemas are different. We do have a lot of customers using it to, like running a SaaS application where the schema is the same. Like that-

30:32

Aaron Francis

Mm-hmm

30:32

Heikki Linnakangas

... that use case is also very real. Uh- But we, we don't offer any particular support for that, so people use, uh, whatever tools come with their platform. Um-

30:42

Aaron Francis

Any community tools or anything like that?

30:43

Heikki Linnakangas

Yeah, there's a lot of those out there.

30:44

Aaron Francis

Okay.

30:44

Heikki Linnakangas

We, we haven't done anything special with that. That is something we are actually asking our customers, like, "How do you manage that?" And if there-

30:50

Aaron Francis

Yeah. If

30:51

Heikki Linnakangas

... if there would be something we could do, like, I think that would be very interesting. Uh, we're kind of looking into that, but, uh, nothing today.

30:57

Aaron Francis

Yeah. Okay. Yeah, that's super interesting, and I didn't think about the, the platform angle. That makes a ton of sense. Um, on the, on the platform angle, um, with all of these, like, I don't know what you even call them, like Bolt and Lovable and all-

31:11

Heikki Linnakangas

Mm

31:11

Aaron Francis

... of these tools that are like, "Hey, why don't you build an app in the next four seconds?" Are you guys-

31:16

Heikki Linnakangas

Yeah

31:16

Aaron Francis

... are you guys plugged into that movement at all? Because this seems like a great... Like, that seems like a great use case. Somebody who's like, "Hey, let me throw together an app. Let me get a database that can go to sleep because I'm just experimenting." Have you guys been riding that wave, or what's that been looking like?

31:32

Heikki Linnakangas

For, for sure. Like that's a lot of, lot of new databases are created by AI tools, uh-

31:38

Aaron Francis

Mm

31:38

Heikki Linnakangas

... for sure. I don't have many numbers, but, like-

31:40

Aaron Francis

That's okay

31:40

Heikki Linnakangas

... that's my gut feeling. That, like, that's, that's happening increasingly. And, and yeah, Neon is great for that kind of one-off experiment. Like, you just need a database for, for your AI-built app for a few seconds, four minutes maybe. You know, a small fraction of them might-

31:53

Aaron Francis

Sure

31:53

Heikki Linnakangas

... might live a little longer. If, you know, if you... Once you're happy with your, uh, with your application, then, then you, you know, you would keep that schema and copy that somewhere else or something. Uh, so that's definitely one use case, and we're seeing a lot of that. Uh, one interesting thing with AIs as well, they like to kind of, uh, go back and forth and they, you know, you might have an... You might develop an application and then you work on some changes on that, or AI works on some changes and you approve or disapprove them.

32:20

Uh, like the Neon's branching feature is actually really interesting for that-

32:23

Aaron Francis

Mm

32:23

Heikki Linnakangas

... for that use case. So you could have a database with, uh, lots of data in it, uh, maybe depending on your field of work, maybe you can even have a copy of your production database, um, and then play with a lot of small, you know, variations of that. You can iterate very quickly. You can create branches of your production database, try, uh, your schema change, see if you like it or not.

32:45

Uh, if you're not, you create a new one, and that's all, like, very easy to work with compared to taking backups of, you know, hundreds of gigabytes and-

32:53

Aaron Francis

Yeah

32:53

Heikki Linnakangas

... restoring them continuously.

32:55

Aaron Francis

Okay. So help me understand this. Um, just like the word serverless is overloaded, branching has gotten there too.

33:01

Heikki Linnakangas

Mm.

33:01

Aaron Francis

So in my, uh, observing of the market, we've got schema branching and data branching.

33:07

Heikki Linnakangas

Yeah.

33:07

Aaron Francis

And those are, you know, similar, but fundamentally discrete things. Are you telling me that data branching is available in Neon, and so you could branch the whole thing, data included, play around with some stuff with the, you know, I guess at that point it's not live data, but with what was formerly- ... a, a copy of the live data, make sure everything works okay, uh, and then, like, what?

33:30

Apply the test migrations back to the main branch?

33:35

Heikki Linnakangas

Exactly, yeah. Neon does data branching. It branches-

33:38

Aaron Francis

Okay.

33:38

Heikki Linnakangas

Branching works at the physical level. Like it's a, it's a, it's a branch at the physical level of the blocks and the indexes and, uh, and uh, and what- whatever else is there, not just the da- uh, not just the scheme, but, but everything, like the data as well. So yeah, exactly. You can take a branch of your 100 gigabyte database and, um, try out some migrations and see if you like them or not.

33:59

Aaron Francis

That's pretty cool. That's pretty cool. Does your, uh, does your architecture make that a lot easier, the separation? Does that make that part, the branching part, so much easier?

34:09

Heikki Linnakangas

Yeah.

34:09

Aaron Francis

'Cause you're just at that point dealing with the, the storage.

34:13

Heikki Linnakangas

Yeah. That, that kind of fell out accidentally from the storage we have.

34:18

Aaron Francis

I love that.

34:18

Heikki Linnakangas

Like a lot of-

34:19

Aaron Francis

I love it when a good decision leads to happy circumstances later.

34:22

Heikki Linnakangas

It's the, it's the best features are happened that way.

34:24

Aaron Francis

Yes.

34:25

Heikki Linnakangas

So we... Originally, like when we built the storage, we, we realized very q- early on that we need to be able to s- in order to support read-only replicas, which is another-

34:35

Aaron Francis

Mm

34:35

Heikki Linnakangas

... like cool feature, that you can connect multiple read-only nodes against the same storage, uh, in Neon.

34:41

Aaron Francis

Mm.

34:41

Heikki Linnakangas

Uh, so if you wanna have a read-only node, you don't need-

34:43

Aaron Francis

I guess

34:43

Heikki Linnakangas

... to create a copy of-

34:44

Aaron Francis

I guess so, yeah.

34:45

Heikki Linnakangas

So that's really cool. But in order to do that, the storage actually needs to be able to serve different versions of the data. 'Cause the replica might lag a little bit behind the primary. Uh, it might even lag, you know, more, more than a little. It maybe if you wanna run a one-off query that runs for a day-

35:03

Aaron Francis

Mm

35:03

Heikki Linnakangas

... uh, on a snapshot of your data, uh, then that read-only node needs to see the data as of that point in time, while your primary is overdue, uh, like ru- running further ahead. So we quickly realized that we would want to have a system that can serve and kind of keep all of the history, like you would normally with the write-ahead log and backups-

35:21

Aaron Francis

Mm-hmm

35:22

Heikki Linnakangas

... uh, but all integrated into the same storage system. And once you do that, like once you have a system that can keep the history and you can, like, ask for any page in the history and kind of do this time travel thing, then the branching is kind of a natural, uh, experience.

35:38

Aaron Francis

Mm.

35:38

Heikki Linnakangas

Like nat- it falls out of that naturally because a branch is just a, a point in time where, where the data diverges. And, uh, by being able to restore that old point in time, you can also create a branch and, uh, you can see the, just the changes from starting from that point in time. So that was kind of a very natural thing for our storage system to be able to do, uh-

36:00

Aaron Francis

So, uh-

36:00

Heikki Linnakangas

... once you have the time travel thing.

36:02

Aaron Francis

Am I understanding that time travel is, is possible? Um, no. Am I... I got, I got sidetracked in my own head there. Am I understanding that with the time travel, you could branch off of an older-

36:14

Heikki Linnakangas

Mm

36:15

Aaron Francis

... version of, like, the live production data-

36:18

Heikki Linnakangas

Yes

36:18

Aaron Francis

... and query against, like, yesterday's database?

36:21

Heikki Linnakangas

Correct. That's correct. We... And we do have in the user interface, like we do have what we call the time travel assistant. So you can actually, like, write a query, and there's a slider for what point in time you wanna run it at, and it will do that. It launches a new Postgres node at that point in time. It runs the query and gives you the results. Um, it's an amazing feature. Uh- It's mostly-

36:42

Aaron Francis

That's wild

36:42

Heikki Linnakangas

... it's mostly used for, like, point-in-time recovery. Like, if you accidentally-

36:46

Aaron Francis

Mm-hmm

36:46

Heikki Linnakangas

... drop a table, now you wanna go back. But it can be... Well, the, the databases can do point-in-time recovery, but it's always a bit tricky to find the exact point, uh-

36:56

Aaron Francis

Sure

36:56

Heikki Linnakangas

... where you wanna restore. But with the time travel system, you can, like, you can bisect what is the point where, where you accidentally dropped the table, and you can quickly find that.

37:04

Aaron Francis

Yeah.

37:05

Heikki Linnakangas

It's also very useful for if you wanna, wanna run long-running, like, reporting queries against your data-

37:10

Aaron Francis

Mm

37:10

Heikki Linnakangas

... for example. Or you can have the primary that is processing the online transactions, and you can launch one read-only node, um, at the current time, but also, like, if you wanna run a report, what did the data look like, uh, last night or something like that, you can do that as well.

37:27

Aaron Francis

That is wild, because anytime I think of, like, looking back in history, I think of audit logs. You know?

37:34

Heikki Linnakangas

Mm.

37:34

Aaron Francis

I think of, like, if I've got to figure out what something looked like, I'm, like, piecing stuff together and seeing, like, okay, well, it changed from this to this to this, so it must have been that at the time. But the ability to say, like, "Oh, at 6:00 PM yesterday, somebody, you know, went in and accidentally fat-fingered a, a record and just, like, blew everything up." And so being able to go look at that, that's pretty wild.

37:55

Heikki Linnakangas

Yeah. It's the kind of cool feature that, you know, point-in-time recovery, while archiving base backups, all of that kind of can do that, like, on, in regular systems.

38:03

Aaron Francis

Mm-hmm.

38:04

Heikki Linnakangas

But man, it's a pain to use. Like, if you-

38:06

Aaron Francis

Yeah

38:06

Heikki Linnakangas

... if you actually wanna restore to a specific point in time, now you need to have a server with enough disk space or a cloud instance or something, and you need to-

38:13

Aaron Francis

And it usually just takes-

38:14

Heikki Linnakangas

... do the restore and-

38:15

Aaron Francis

... a lot of time

38:16

Heikki Linnakangas

... and it takes a lot of time. Um-

38:17

Aaron Francis

It just takes so much time.

38:18

Heikki Linnakangas

Exactly. So Neon, but Neon makes that actually usable. Like, you can, you can actually play with it and, and try it.

38:24

Aaron Francis

Yeah. That's super interesting. Okay. Very cool. I'm starting to understand some of the things that have fallen out of this early architecture, like, decision, um, and why it was such a good one. Help me understand, okay, so we've talked about the, uh, you know, let, let a million databases bloom. On the big side-

38:43

Heikki Linnakangas

Mm

38:43

Aaron Francis

... on the people who are like, "My database goes to sleep? Not a chance." So these big customers, how, how big are we, like, how big are we able to go? And I'm sure there's a way to disable sleeping. You've said that already.

38:55

Heikki Linnakangas

Yeah.

38:55

Aaron Francis

So that part is less interesting to me, but, like, how big are we able to scale out, uh, inside of Neon, and what are some of the challenges that y'all faced when the big dogs were like, "No, we need more"?

39:08

Heikki Linnakangas

I mean, if you look at the architecture, the sky's the limit. The storage can, you can scale and add as many servers as you need. Uh, on the compute side, well, it's just one Postgres instance, so the, the kind of the limit there on the compute is how big a, how big of a VM can you get from, from the cloud providers to run it on. But even there, actually, Neon helps because it's very easy to set up the read node, so you can scale the reads-

39:31

Aaron Francis

Mm

39:31

Heikki Linnakangas

... very easily. Uh, you, you can just create as many read-only nodes, uh, as you need. And again, you don't need to copy the data. They all connect to the same storage.

39:39

Aaron Francis

Mm-hmm.

39:40

Heikki Linnakangas

Um, so that helps a lot. And, and you can push through a lot of writes through one Postgres instance as well.

39:45

Aaron Francis

Mm.

39:45

Heikki Linnakangas

Um, that, that's, I haven't seen that really become a, a big bottleneck. Um, so yeah, basically sky's the limit. But, uh, for individual, uh, Postgres instance, you know, it's the size of the VM. The storage can, you can scale that independently, so that, that's nice.

40:01

Aaron Francis

Yeah. Okay. And have y'all had a lot of these, um, have y'all had a lot of these, you know, these big old workloads come over becau- specifically for that reason? I'm sure you have a lot of big workloads, but specifically for that reason.

40:15

Heikki Linnakangas

We've had a lot of people play with it. Uh, people are very conservative with, with databases in general, and big databases are a pain to migrate, so, uh, we've had a lot of trouble, as with any big migration. It's just, you know, uh, if someone wants to try Neon and they have a multi-terabyte database, it's a, it's a bit of a hassle to, to always to move that, so we're-

40:32

Aaron Francis

Yeah

40:32

Heikki Linnakangas

... we're working heavily on, like, migration tools-

40:34

Aaron Francis

Mm

40:34

Heikki Linnakangas

... as we speak, how to make that easier. Uh, but that tends to be the bottleneck. Once you get your data inside Neon, it's, it's very easy to play with. Um, but yeah, we've got a lot of people interested because of these features, and, uh-

40:46

Aaron Francis

Mm

40:46

Heikki Linnakangas

... like, the data branching becomes much y- much nicer when you have a large database because it's not really feasible to do the copying, and all of that copying around data becomes harder when your database is large. Um, but with Neon, there's less need of that.

41:03

Aaron Francis

So I want, I want your personal answer. Don't give me, don't give me the company line here. What's your favorite Neon feature?

41:12

Heikki Linnakangas

It's the, I think it's the time travel thing. Like, as you said-

41:15

Aaron Francis

Time travel is pretty cool. Yeah

41:15

Heikki Linnakangas

... I could see a light bulb going when I, when I explained that.

41:18

Aaron Francis

Yeah. Yeah.

41:18

Heikki Linnakangas

And I've seen that, like, I had that little moment myself when I realized how cool that is. Um, it's, I don't think it's the most popular feature because it's something that people typically encounter when they're kind of fat-fingering or something.

41:29

Aaron Francis

When something's gone terribly wrong. Yeah.

41:32

Heikki Linnakangas

So they don't think about that, that they need that, uh, until they do.

41:36

Aaron Francis

Yeah.

41:36

Heikki Linnakangas

Uh, but I think that's my, that's my favorite feature.

41:39

Aaron Francis

Okay. Uh, it's the cool- it's the coolest one that I've heard of, so I, I tend to agree with you there. Um, okay, I wanna talk about, I wanna talk about this, this thread here.

41:48

Heikki Linnakangas

Mm-hmm.

41:48

Aaron Francis

In fact, it, the title is Let's Make Postgres Multi-Threaded. Um, so it's this, it's, it's from you. It was 2023, so a little while ago now. Um, and it's a, you know, a big email. It's an outline of making Postgres multi-threaded. I checked it on Hacker News. I think it had, like, 850 up votes or something.

42:11

So walk me through, walk, walk me through the genesis of this thread, um, and then kind of like the, the result of, of you having written this thing.

42:22

Heikki Linnakangas

Yeah. So those topics, uh-

42:24

Aaron Francis

You sound exhausted already. Oh, no.

42:26

Heikki Linnakangas

It's something that everyone asks me about, which is, which is fine. I love to talk about that, but it is-

42:31

Aaron Francis

Oh, it's a big deal

42:31

Heikki Linnakangas

... I feel like I'm getting more credit for that than I should. I haven't done all that much work towards it, but-

42:36

Aaron Francis

In, I will, I will defend you. In this email, you say, "I talked to a lot of people, and the silent consensus is this-"

42:43

Heikki Linnakangas

Yes

42:43

Aaron Francis

"... and I'm just bringing it up." So you're not taking credit. So I, I absolve you of that, so carry on.

42:49

Heikki Linnakangas

Thank you. So yeah, as I said in that email, like, and this kind of goes back to what we started with, like, the whole decision-making pro- process in the community.

42:56

Aaron Francis

Mm-hmm.

42:56

Heikki Linnakangas

For something like making it Like switching to multithreaded, that's exactly the kind of problems where the, you know, how do you even make the, the decision like that? That kind of-

43:05

Aaron Francis

Yeah

43:05

Heikki Linnakangas

... comes up. So the, the origin of that was that, uh, this in Canada on Postgres conference, like the biggest, uh, Postgres developer conference, uh, there was a group of, of, of us hackers and committers and other developers, uh, standing in the hallway basically chatting, and, uh, I think it was after a presentation that had something to do with memory management or something.

43:26

Aaron Francis

Mm-hmm.

43:27

Heikki Linnakangas

And we were kind of all sit- standing in a circle and discussing how much it sucks that Postgres has to, you know, has the multiprocess architecture, and how much nicer things would be in a multithreaded environment. And at some point I kind of looking at the people and I was like, "Hang on, this is exactly the right group of people to actually make this decision, and it looks like we are, we're all kind of agreeing that we don't particularly like the multiprocess model.

43:51

So, you know, why don't we, you know, raise the flag and, and, and decide that this is something we wanna do and we would like to switch?" And, uh, so I started to look at that more seriously then, and I wrote the email, you know, kind of saying the, the quiet part out loud, which is that-

44:05

Aaron Francis

Mm-hmm

44:05

Heikki Linnakangas

... we don't actually like the multiprocess model that well. Um, and a lot of the discussion in that thread was also repeating old, uh, arguments for like, why is the multiprocess model good? Um-

44:18

Aaron Francis

Mm-hmm

44:18

Heikki Linnakangas

... but I, it, I felt like all of those were, are just excuses. Like, they were kind of ju- trying to justify the-

44:23

Aaron Francis

Because it's hard that, I mean-

44:25

Heikki Linnakangas

Yeah, because it's hard

44:25

Aaron Francis

... that's probably the answer

44:26

Heikki Linnakangas

... so and it's kind of become the lore that Postgres is multiprocess system.

44:29

Aaron Francis

Right.

44:29

Heikki Linnakangas

And you know, what if it suddenly isn't, is it still Postgres? And that kind of, kind of an identity crisis if you, if you will, if, if, if you make big changes like that. Um, but yeah, in the end I think everyone pre- well, I think we reached a consensus and there's been some work, and not just from me. There's a lot of other people who have kind of submitted and contributed to, uh, towards that goal.

44:50

We haven't done much yet, but we have, like in the latest version 18, we've made a lot of changes to, uh, replace like library functions with the thread safe variants and stuff like that.

45:01

Aaron Francis

Hmm.

45:01

Heikki Linnakangas

Totally not visible to users and kind of very boring changes. Um, but they're all-

45:06

Aaron Francis

Those, those are the changes we like.

45:08

Heikki Linnakangas

Yeah. It's-

45:08

Aaron Francis

That's good.

45:09

Heikki Linnakangas

Yeah. True. Uh, and it's all like the necessary groundwork for, for eventually going to multithreaded.

45:17

Aaron Francis

And so you have this conversation with a bunch of people. You were somehow el- elected the federal head or the spokesperson. And so you wrote this email. Um, it sounds like that little core of, of people was like, "Yeah, we're on board." What about the like one step, two steps out, like the broader community that isn't privy to some of these like hallway conversations or doesn't super pay attention to the mailing list or something like that, um, what was some of the feedback there?

45:46

Heikki Linnakangas

Yeah. I don't think the, I don't think users care too much except they care about the stability and like the whole-

45:51

Aaron Francis

Sure

45:51

Heikki Linnakangas

... you know, don't, please don't break it. Like it's not broken, don't break it-

45:55

Aaron Francis

Mm-hmm

45:55

Heikki Linnakangas

... aspect. And, and, uh, a lot of the, I think, valid criticism or concern was, was that this could introduce a lot of bugs. Um-

46:03

Aaron Francis

Yeah

46:03

Heikki Linnakangas

... and we don't like bugs, uh, which is fair. But that's kind of fair, like that's true for any change you make. Like we, we can't, you know, stop making changes because we're, because we're afraid of bugs. We'll just have to manage the risk and, uh, you know, do a lot of testing and, uh, like do it correctly.

46:19

Aaron Francis

And describe to me and the people, uh, uh, all of the audience who may not be quite as in tune with, uh, Postgres and its process and the history, um, what does this buy you? So this sounds-

46:32

Heikki Linnakangas

Hmm

46:32

Aaron Francis

... like a monumental amount of work that a group of people has said is worth it, which means something on the other side is extremely valuable. What is this thing on the other side that y'all are working towards?

46:44

Heikki Linnakangas

Well, in fairness, a lot of the criticism was actually that it's probably not worth it. It's like, "Why don't you spend your time-

46:49

Aaron Francis

Hmm

46:49

Heikki Linnakangas

... on something more valuable or, you know, with more short-term benefit?"

46:52

Aaron Francis

Mm-hmm.

46:53

Heikki Linnakangas

Um, but that's, I'm, I'm actually learned over the years to ignore that argument because it's kind of, uh, you know, whatever people decide to work on, that's, you know, I don't get to decide what people work on, and no one else gets to decide what I work on. So-

47:06

Aaron Francis

Mm-hmm

47:06

Heikki Linnakangas

... you know, that's kind of not a very relevant argument. Um, but for the benefits, uh, immediately just from switching to threads, nothing much changes. I don't think that there would be a lot of benefit just from doing that, but it's all the things that it kind of unlocks and makes easier in the future. Once we can get rid of the process model, uh, the dealing with the multiprocess architecture adds a lot of, uh, friction, uh, to everything where you need to like share state, uh, between-

47:35

Aaron Francis

Mm-hmm

47:35

Heikki Linnakangas

... um, backends. We have a lot of caches in Postgres, like the relation cache, uh, plan quer- plan cache for queries. Um, a lot of caches like that, like little things, but they add up and, uh, it means that every connection is kind of heavy 'cause they're se- like we have a separate cache for every connection of those things, and there's a lot of duplication, which means if you have a database with 1,000 connections, for example, um, the memory, just the memory usage from all of those caches and all the overhead

48:05

actually starts to add up, and I've heard of people running into that problem, like the re- literally running out of memory just because they had a lot of, a lot of caches and a lot of connections. Like that's a very concrete thing, uh-

48:17

Aaron Francis

Yeah

48:17

Heikki Linnakangas

... that once you switch to the multithreaded model, we can start to work on those other pieces and, uh, start to share more data between the, be- between the threads. Uh, so that's one thing. The, in general, like anything that needs to deal with connection handling and connection management, memory management just becomes a lot easier with the multithreaded model. Uh, so a lot of the problems I'm also seeing at Neon actually with the serverless thing we are doing, uh, comes from, uh, having, you know, what do you set your max connections to?

48:46

How many connections can Postgres deal with? Uh, well, the answer is, you know, not a huge number. Uh, but the, but everyone, the common wisdom is that you need to use a connection pooler. So we also have run a, a connection pooler, for example. But, um, I think with the multithreaded model and all of the things we can do after that, after we switch to that, would make it easier to, to better deal with higher number of connections and better to manage the resources across connections.

49:11

So I think that's like the long-term, you know, five or 10 years from now, where it will help with the connections management. Which is great for serverless stuff and, uh, all that.

49:21

Aaron Francis

That was my next question, is how long, and you said five- ... or 10 years. Do you think it's really that long?

49:28

Heikki Linnakangas

Oh, I mean, yeah, un- until we start to get-

49:31

Aaron Francis

Wow

49:31

Heikki Linnakangas

... really get the benefits. But I've been ar- I've been around for long enough.

49:35

Aaron Francis

Yeah. I mean-

49:35

Heikki Linnakangas

I can, I can imagine that. Uh, the, like, the immediate changes are, we'll probably take a few releases, and we do annual releases, so there will need-

49:44

Aaron Francis

Mm-hmm

49:44

Heikki Linnakangas

... to be a transition period for, for some time. I'd actually like to keep the transition period as short as possible, because, again, we really only start to get the benefits once we can get rid of the process model. Uh, so I'd, I'd like to, you know, make the switch as soon as possible. But realistically, it's probably gonna take at least two or three years. Um, there's also the whole eco- extension ecosystem that needs to-

50:06

Aaron Francis

Yeah

50:06

Heikki Linnakangas

... catch up. Uh, like, all the work we do to p- core Postgres, with the extensions, need to repeat that work. Uh, so-

50:12

Aaron Francis

Yeah

50:12

Heikki Linnakangas

... we'll need to build tools that make it-

50:13

Aaron Francis

Sorry, y'all

50:14

Heikki Linnakangas

... easier for extension developers to do that. I'm actually thinking that many extensions will switch to the thread model before core Postgres, because, uh, it, it might be... Like, if you're working on a new extension now and it was possible to do that in a multithreaded model, like, I think a lot of extensions would actually choose that, uh-

50:32

Aaron Francis

Mm

50:32

Heikki Linnakangas

... rather than the process model. So it will make it easier to use, you know, multithreaded libraries and, uh, uh, tools.

50:40

Aaron Francis

So beyond, beyond this, which has, uh, a lot of history and a lot of lore, what do you see for the next, we'll say, five years of Postgres or, and/or the next five years, or maybe shorter for a company, o- of Neon?

50:57

Heikki Linnakangas

Mm-hmm.

50:57

Aaron Francis

I'm sure that y'all operate on much tighter timelines than 5 to 10 years. So what's your vision for the future on either of those fronts? What is, what are some things you want to see come to fruition?

51:07

Heikki Linnakangas

Oh, gosh. Uh, well, on Postgres, I already mentioned all the, all the nice things that the multithreading will eventually allow us to do, so all that.

51:14

Aaron Francis

Okay.

51:15

Heikki Linnakangas

Uh, like make it more flexible, uh, allow, you know, handling more connections more nicely. Uh, I'm looking forward to all that. I think the, there's been a big switch, uh, to everyone running their databases in the cloud, and cloud providers are having a big, big impact. Like, it doesn't really show up in, uh, day-to-day work, but I think increasingly Postgres will also see features that make it easier to run, uh, it as a service, um-

51:41

Aaron Francis

Mm

51:41

Heikki Linnakangas

... in the cloud, which means, uh, less tuning, like more auto-tuning features, uh-

51:46

Aaron Francis

Mm

51:46

Heikki Linnakangas

... just make it more flexible that way. Um, hoping to get some of the, the Neon stuff we have to change, like the s- the separation of compute and storage, so actually make those changes, uh, get those into upstream. Um, all that. On the Neon side, we are looking at, I think we've r- we struck a stable point, so we are looking at what our customers need. Uh, we talked about, uh, what could we do with schema management, uh-

52:10

Aaron Francis

Mm

52:10

Heikki Linnakangas

... managing large fleets of databases, just make that experience nicer. Also observability and, uh, like our-

52:16

Aaron Francis

Mm

52:16

Heikki Linnakangas

... we don't provide a lot in the, in the sense of, you know, logs and, um, observability to our users, so that's something we're, we're definitely improving. Making migrations easier, I think that's again a problem that we, we are experiencing as a company, but that's actually, like everyone using Postgres and trying to do migrations are surely hitting the same issues, whatever-

52:36

Aaron Francis

Mm-hmm

52:36

Heikki Linnakangas

... the providers are.

52:38

Aaron Francis

Okay. That's a pr- that's a pretty good list. Um, so where... Well, first, is there anything else you wanna, you wanna tell the people before we tell them where to find you? Um, anything else you wanna say about Postgres or Neon or open source work or anything-

52:55

Heikki Linnakangas

Oh, gosh

52:55

Aaron Francis

... like that?

52:56

Heikki Linnakangas

Um, I mean, if you need a database, go to neon.tech. Uh, click a button, you'll get a database. Um, Postgres is a safe choice. Uh, like-

53:06

Aaron Francis

Mm

53:06

Heikki Linnakangas

... it's kind of become the default database nowadays, which is, it, it feels, always feels funny to me 'cause I've been around the project for a long time. Like-

53:13

Aaron Francis

Mm

53:13

Heikki Linnakangas

... I can't put the finger on when that exactly that happened, but, uh, it's a good default choice. Uh, if you need to know, if you have special needs, then sure, I mean, look elsewhere. There's a lot of other great databases out there as well. Um, but it's a good place to start. Um, yeah.

53:29

Aaron Francis

That's an exceedingly reasonable take, and I- ... I very much appreciate exceeding reasonableness, so I like that. That's a very good default, and I will, uh, I'll say more than you did, it also has a huge amount of extensions, so if you need something specialized-

53:44

Heikki Linnakangas

Mm

53:44

Aaron Francis

... there's probably something in the Postgres ecosystem for you. But, um, it is, it is a good default. So tell the people, uh, where they can find you. You mentioned Neon, but tell us one more time, um, and any other final plugs you wanna say as we sign off here.

54:00

Heikki Linnakangas

Uh, if you need a database, go to neon.tech. Uh, if you wanna reach out to me, you can find my email address on their hackers mail list or anywhere else by just Googling. As far as I know, my name is unique, so if you find a Heikki Linnakangas, that's me.

54:13

Aaron Francis

Yep. That's definitely you. Okay. So we'll put a bunch of this down in the show notes, including, uh, this thread on the, uh, PG hackers mailing list, um, links to Neon, um, and then you can find, you can find Heikki's email, uh, through that as well. Thank you so much for doing this. This was, this was a delight and a lot of fun, and thanks for being so open about everything.

54:35

Heikki Linnakangas

Thanks, Aaron.

Databases

More videos on databases

All videos

Get the next one by email

I’ll send you some more. Not too many.

Join 7,500+ other readers.

Read past issues