May 202454:3720.1k views

Distributed SQLite with Litestream and LiteFS

About

Ben and Aaron discuss replication and backups in SQLite, Litestream and LiteFS, and future mad scientist projects Ben is working on.

Transcript

Everything we said

00:00

Aaron Francis

Well, I am here with Ben Johnson, and Ben, I have something to show you that I did not warn you about.

00:06

Ben Johnson

Oh, man.

00:06

Aaron Francis

Do you, do you recognize-

00:08

Ben Johnson

Ah

00:08

Aaron Francis

... any of this?

00:10

Ben Johnson

Yeah.

00:10

Aaron Francis

Do you recognize-

00:11

Ben Johnson

I do

00:11

Aaron Francis

... these headers?

00:12

Ben Johnson

It looks better in color, though, gotta say.

00:14

Aaron Francis

It, it does look better in color. I printed out... So i- in a part, in part of my studying for this course, um, of, uh, of course, the first place I went was the Fly blog to print out all of your, uh, articles over there. And they are-

00:29

Ben Johnson

Oh, thank you

00:30

Aaron Francis

... super good, so thank you so much for writing all of those. Um, and it has that same, like, that's, I don't know if it's you or Fly, but it has that same kind of like irreverent, casual, fun, like conversational tone that I, I really like. So good job on all those.

00:44

Ben Johnson

Well, thank you. Yeah, I appreciate that.

00:46

Aaron Francis

Hey, I hope you're enjoying this. Just as a reminder, you can learn more about SQLite at highperformancesqlite.com. I'll get out of your way. Back to the interview. So tell me, um, by way of introduction, where you're working. I, I just spoiled it, but where you're working, what you do, and how you ended up, how you ended up there.

01:06

Ben Johnson

Uh, yeah. So I'm at Fly.io right now. We do, you know, application hosting and, um, server host- Yeah, we put s- put applications everywhere kind of is our-

01:16

Aaron Francis

Mm-hmm

01:16

Ben Johnson

... our gig. Um, and I ended up there a couple years ago. Um, I did a project called Lightstream-

01:23

Aaron Francis

Mm-hmm

01:23

Ben Johnson

... which is essentially trying to make, like SQLite, um, make it work on basically a single node, so you can have like automatic backups. And like for a lot of applications, that's, it's probably good enough. I mean, unless you need some crazy like HA, high availability thing going on, then, um... Otherwise, I mean, like a simple SQLite can go a long way. Um, and then before that, um, yeah, did a lot of consulting work in Go.

01:46

I've done a lot of work on databases. Um, I did a database called BoltDB, um, that's in like the Go world.

01:52

Aaron Francis

I did not know that was you.

01:54

Ben Johnson

Yeah, I did that maybe 10 years ago.

01:56

Aaron Francis

Wow.

01:57

Ben Johnson

I was actually at Shopify at the time.

01:58

Aaron Francis

Okay.

01:59

Ben Johnson

Um, yeah. We were using LMDB at the time, uh, for like an analytics database. We'd kind of-

02:04

Aaron Francis

Mm-hmm.

02:04

Ben Johnson

I'd actually written an analytics database before that. Um, and that, that's why I kind of ended up at Shopify. We started doing analytics-

02:11

Aaron Francis

Yeah

02:11

Ben Johnson

... and we kind of wrote our own database there. And, uh, LMDB worked great, which is like another key value store.

02:17

Aaron Francis

Mm-hmm.

02:17

Ben Johnson

But we had some issue, and we could not ever track it down, but like every couple months, we'd have like one server that would just fill up the disk, and we had no idea why. And at the time, I had kind of been playing with like doing a port of LMDB to Go-

02:29

Aaron Francis

Okay

02:29

Ben Johnson

... but more just like an educational thing. And then, you know, it eventually got to the place where it was like we couldn't figure out this bug, and we had just spent forever on it. And, uh, we were like, "Hey, why don't we just try this, this little project you did on the side?" Which was, which was Bolt at the time. So-

02:45

Aaron Francis

Mm-hmm

02:46

Ben Johnson

... um, yeah, I d- did that. Uh, before that, um, I'd done a lot of work in like data visualization. Um, I was actually an Adobe Flex developer, if anybody is old enough to remember what the hell that is.

02:57

Aaron Francis

I, I feel like I've been around for a while-

03:00

Ben Johnson

Yeah

03:00

Aaron Francis

... but I don't know what Flex is.

03:01

Ben Johnson

Yeah. It's basically if you took like, um, like React, but like-

03:06

Aaron Francis

Yeah

03:06

Ben Johnson

... 15 years ago, and it was-

03:08

Aaron Francis

Okay

03:08

Ben Johnson

... on the, uh, the Flash platform essentially.

03:11

Aaron Francis

Oh, okay.

03:12

Ben Johnson

So it was back when, like before HTML and like browsers-

03:14

Aaron Francis

Yeah

03:14

Ben Johnson

... could really do a whole lot. So it was actually kind of cool, but yeah. Uh, Adobe kind of-

03:18

Aaron Francis

Yeah

03:18

Ben Johnson

... tanked with that, that kind of stuff in Flash.

03:20

Aaron Francis

Fla- Flash I remember. I was a, I was an ActionScript developer, but I don't-

03:23

Ben Johnson

Oh, nice

03:23

Aaron Francis

... ever know, I didn't ever know Flex. So-

03:26

Ben Johnson

Yeah

03:26

Aaron Francis

... most people, uh, most people would say you should never write your own database, and here you are having written at least two that we know of. And then some sort of virtual file system for other databases, and a little sidecar, and so you're just like, you're doing all the things that you're not supposed to do, and you're doing them very well it seems like.

03:47

Ben Johnson

Uh, I mean, I think the first ones weren't very good. That's kind of the, that's the trick is like-

03:52

Aaron Francis

Yeah

03:52

Ben Johnson

... make sure you get the bad ones out first, and then, uh... No, I mean, like I think that it's kind of one of those things where like it's like, you know, rolling your own crypto, like you shouldn't do that.

03:59

Aaron Francis

Mm-hmm.

03:59

Ben Johnson

But obviously there was somebody that rolled their own crypto first.

04:03

Aaron Francis

Mm-hmm.

04:03

Ben Johnson

Um, and I think you just like kind of, if you find something, some little niche, and you just dig into it really deep and just keep going-

04:09

Aaron Francis

Mm-hmm

04:10

Ben Johnson

... um, you can just find fascinating little, little areas to dive into. So, um, I think I had a, like a little scratch I wanted to itch. I worked at a company that did like behavioral analytics, and I thought they could do it much better. I was actually the data visualization guy at the time at that place, not the database guy. Um, and this is back in like Hadoop, like when Hadoop first came out, and I was like-

04:29

Aaron Francis

Mm-hmm

04:29

Ben Johnson

... "Hey, we should use Hadoop for this thing. It'd be great." 'Cause we were spending forever like trying to actually run these reports. Um, and then I started just playing around with trying to make it faster and faster, and eventually I just wrote my own database. I think that's kind of where everyone ends up, right?

04:42

Aaron Francis

Yeah. Yeah, that is the end state for trying to-

04:45

Ben Johnson

Yeah

04:45

Aaron Francis

... make things faster, for sure. Um-

04:47

Ben Johnson

Yeah

04:47

Aaron Francis

... so I wanna talk to you about Lightstream first. So we got, we got, we have two light products, Lightstream and LightFS.

04:55

Ben Johnson

Mm-hmm.

04:56

Aaron Francis

Um, and we can, we can go super technical, so don't be shy. So I wanna hear-

05:00

Ben Johnson

Sure

05:00

Aaron Francis

... I wanna hear about, um, Lightstream and how you kinda, I guess, came up with the idea, and why you wrote this, and then we can talk about kind of how it works technically.

05:12

Ben Johnson

Yeah, sure. Um, so I think the basis for it was kind of the work I did with Bolt, um, way back in the day. I realized like-

05:19

Aaron Francis

Mm-hmm

05:20

Ben Johnson

... when you have a database right next to the application, it's really fast. Like-

05:23

Aaron Francis

Mm-hmm

05:24

Ben Johnson

... especially when you're used to using Postgres or... I mean, not that there's anything wrong with client-server databases, they're great, but there's just something about not having any overhead, like network overhead-

05:33

Aaron Francis

Mm-hmm

05:33

Ben Johnson

... that just like kinda blows your mind. And, uh, it's really simple too. Like there's no external dependencies. You just all, you bundle it all up, and it's right there.

05:41

Aaron Francis

Mm-hmm.

05:41

Ben Johnson

Um, so I think for me it was more, um... I was trying to make like application development with Bolt try to work. Um, and it was just, there's a lot of nice things you get with, uh, like a SQL database, like schemas and like foreign keys and all that. You know, little things that-

05:56

Aaron Francis

Yeah

05:56

Ben Johnson

... you don't want to build yourself.

05:57

Aaron Francis

Little things like schemas, yeah.

05:58

Ben Johnson

Indexes, you know? Yeah. Um, so I just, eventually I was like, you know what? This is way too hard probably for- Anyone that's not a database developer.

06:05

Aaron Francis

Mm-hmm.

06:06

Ben Johnson

And, uh, I tried to look around for other, um, SQL databases that were embedded, and really it's just SQLite out there that's like the, the big one. Works on almost every language, and yeah, it's fantastic. So, um, I started developing with that, and I w- I kind of got this itch of like, what is... Like, for most applications, I think most developers, right, like, if you wanna deploy it out, it needs to have, you know, pretty good u- uptime, maybe like three nines or something.

06:33

Aaron Francis

Mm-hmm.

06:34

Ben Johnson

But like, you don't need like five nines, you don't need like crazy anything. You just want something that's simple, it's easy to run, it's cheap. Um, and the biggest thing I had an issue with was like the disaster recovery piece of SQLite.

06:46

Aaron Francis

Mm-hmm.

06:46

Ben Johnson

Where you could do like, you could do like a daily backup or even like an hourly backup, which honestly actually works great for a lot of people. We even, even have documentation on Lightstream about alternatives, and one of those is just back it up every hour, and that's-

06:58

Aaron Francis

Hmm

06:58

Ben Johnson

... that's fine.

07:00

Aaron Francis

Mm-hmm.

07:00

Ben Johnson

Um, but if you wanna actually like track your changes so that you only have kind of this really small window of down- or of, uh, data loss in the event of like catastrophic, um, events, then, you know, something like Lightstream where you can continuously back up, like incrementally back up each little set of transactions every few seconds, um, you really like, you minimize your actual risk of data loss, and that was kind of the-

07:24

Aaron Francis

Mm-hmm

07:25

Ben Johnson

... the, the end goal. So yeah, I, I wanna make application development super simple. Run, it runs as a separate process, um, so you don't have to like, your application doesn't have to know about it in particular.

07:36

Aaron Francis

Mm-hmm.

07:36

Ben Johnson

Uh, that was kind of a big design goal as well.

07:39

Aaron Francis

Mm-hmm.

07:39

Ben Johnson

Um, anyway, yeah, I'm just kind of rambling now, but that's kind of where it came from.

07:42

Aaron Francis

No, no, no, this is, this is great. And I think one of the things that, uh, was so fascinating to me about kind of the structure of it or the, the, the architecture of it, um, and forgive me if this is, uh, naive and/or wrong, it, it seems like you, um, the final product is you looked at SQLite and were like, "How do I do this without basically touching SQLite internals," right?

08:10

'Cause they're very, they're very like, "We're open s- we're source available, but we don't take PRs. We don't-

08:16

Ben Johnson

Yeah

08:16

Aaron Francis

... take anything. It's us three guys that have been doing it since the early 2000s, we're gonna keep doing it."

08:22

Ben Johnson

Yeah.

08:22

Aaron Francis

And so that kind of puts, um, that kind of puts an interesting constraint on, I wanna do something with SQLite, but I can't really like get inside it. And so I think the, the approach you took was kind of trick it to be this long-running, like it works, you know, it keeps like a transaction open and it hijacks the checkpoints or something like that.

08:46

And that to me is like, oh, that's in- incredibly... Like, that's very clever because then people still get to use like vanilla out of the box SQLite and then put your thing beside it. So can you tell me a little bit about like the, the architecture and the, the structure of it and how that like trickiness works? And I say trickiness-

09:04

Ben Johnson

Yeah

09:04

Aaron Francis

... in a good way 'cause I think it's-

09:05

Ben Johnson

No, yeah

09:06

Aaron Francis

... fascinating.

09:07

Ben Johnson

It, it's all hacks out there. Honestly, we're all, we're moving electrons around. I feel like-

09:10

Aaron Francis

Uh-huh

09:10

Ben Johnson

... everything's a hack, honestly. So, um, yeah, I mean the way that it works is there's b- basically two, um, journaling modes. So a journaling mode in a database, I don't know if you've covered this before, but like essentially it's how you safely like write changes to a database so that they all get written and they're durable and that if it needs to roll back, like everything can roll back. Um, so one is a journal mode where essentially you are copying out the, the previous version of the changes, like the rows, into a separate file called the journal file, and

09:40

then you'll make changes to the actual database, and then you write the changes. Like you, you basically delete the, the journal file after you're done. So at any point you can recover back, like if you need to roll back. So that's the journal mode, and that's like the old, old mode of SQLite. Um, it's, it has a lot of drawbacks. It's not very fast. You don't have like concurrency and all that. And kind of the better mode generally, I mean, there's a couple trade-offs, but by and large, like the WAL mode, which is write-ahead log, uh, that's kind of like the best mode to really run SQLite in.

10:09

You get a lot of concurrency. You can have a bunch of different readers at the same time, one writer, but they can all kind of intermix at the same time.

10:15

Aaron Francis

Mm-hmm.

10:15

Ben Johnson

Um, so what, the way that the, the WAL mode works, uh, W-A-L, is that every transaction you make, you'll make changes to pages. So pages are kind of like blocks in your database. Um, and every time you make a change to a page, it'll kind of tack it onto the end of this file called the, the write-ahead log, and then it can reference those changes.

10:33

Aaron Francis

Can I, can I pause you right there?

10:34

Ben Johnson

Oh, yeah. Please do, yeah.

10:35

Aaron Francis

So the, uh, correct me if I'm wrong, but for the edification of the listener, the two trans- or the two, um, mode, the journal modes are rollback and write-ahead.

10:45

Ben Johnson

Yeah.

10:45

Aaron Francis

And write-ahead we call WAL 'cause it's write-ahead logging, W-A-L. So we've got rollback and write-ahead. Rollback is traditional-

10:53

Ben Johnson

Mm-hmm

10:53

Aaron Francis

... um, and still default because SQLite is super on about backwards compatibility.

11:00

Ben Johnson

Yeah.

11:00

Aaron Francis

They just love it so much.

11:02

Ben Johnson

They love it.

11:02

Aaron Francis

Which is great.

11:02

Ben Johnson

Yeah.

11:03

Aaron Francis

Love it. So we've got these two modes, rollback and WAL. WAL is the, um, WAL is the better one for better, higher concurrency. You can have a bunch of readers, um, still one writer, which is fine, but you can have a bunch of readers working. Um, rollback mode writes to the actual database file, and if you wanna roll back, it grabs the thing that it set aside and it puts it back in if you need to roll back.

11:27

Write-ahead, instead of writing to the actual database, um, file, it creates this new file that's like a dash WAL, and it writes there and leaves the database, uh, untouched until such a time where it takes the WAL, takes the, the second file and basically merges it back into the first file, and then we start all over again.

11:52

Is that fair so far?

11:53

Ben Johnson

Yeah. Yep, that's great.

11:54

Aaron Francis

Okay. Perfect.

11:55

Ben Johnson

Yeah, and then whenever it merges those changes back in, that's called checkpointing. And, uh-

11:59

Aaron Francis

Okay

11:59

Ben Johnson

... and the, the great thing about the WAL is that you essentially, you have every version of a page Until you checkpoint it back in. So you can have different, uh, readers kind of have a different snapshot of the database at every point in time when they started.

12:13

Aaron Francis

Mm.

12:13

Ben Johnson

So it has this nice, that nice property. It's called serializability. Um, so yeah, that's essentially how the WAL works. And the, the issue whenever you have like a, a kind of disaster recovery kind of streaming backup system like, uh, Lightstream, is that you essentially need to track the changes from the last time you, you sent an incremental backup.

12:32

Aaron Francis

Mm-hmm.

12:32

Ben Johnson

And like the checkpoint is where you kind of have a potential to lose that, where like the database could write some changes, and then it checkpoints and clears the whole write-ahead log, and then you never caught that last little transaction at the end before-

12:45

Aaron Francis

Mm-hmm

12:45

Ben Johnson

... it did that. Um, so-

12:46

Aaron Francis

And so at that point, your database has changed, but you don't necessarily know how-

12:52

Ben Johnson

Mm-hmm

12:52

Aaron Francis

... and so you can't send off that increment to, to some other place to store.

12:57

Ben Johnson

Yeah.

12:57

Aaron Francis

It's now become an amorphous blob again that is the database, and now your write-ahead log is empty. Is that right?

13:04

Ben Johnson

Yeah, exactly.

13:04

Aaron Francis

Okay.

13:04

Ben Johnson

And you don't really, you can't detect that necessarily.

13:07

Aaron Francis

Mm.

13:07

Ben Johnson

So you actually just... Even worse than like missing the transaction is like you actually corrupting your database, uh, potentially. So that's bad. You don't want that.

13:15

Aaron Francis

Mm.

13:15

Ben Johnson

Um, so-

13:16

Aaron Francis

That is bad.

13:17

Ben Johnson

Yeah. So the, the one nice trick, um, a little, this is the little hack, is that SQLite doesn't allow you to actually checkpoint if there's any open readers on the database, 'cause they might potentially have changes they're tracking within the WAL. Um, so what Lightstream does is essentially it keeps a, a long-running read open, um, on the transa- on the database, and then whenever it decides it's big enough to tran- like, to actually do the checkpointing, it'll kind of control that process of checkpointing and make sure it has all the data before the process happens, and then it just immediately clicks

13:47

back in and sh- grabs that, um, read again or read transaction again.

13:52

Aaron Francis

Mm-hmm.

13:52

Ben Johnson

So there's like-

13:53

Aaron Francis

Okay. So

13:53

Ben Johnson

Yeah. It's, it's very, yeah.

13:56

Aaron Francis

This is awesome.

13:56

Ben Johnson

Yeah.

13:56

Aaron Francis

I, I love this so much because this is a such a clever solution, uh, working from the outside in. Like, you didn't have to talk to anybody at SQLite.

14:06

Ben Johnson

No, yeah.

14:06

Aaron Francis

You didn't have to make any pull requests.

14:08

Ben Johnson

Yeah.

14:08

Aaron Francis

It's amazing. Um, tell me on a technical level how... So when you deci- who, first of all, who decides, um, in, in a Lightstream setup, who decides that a checkpoint is ready? Because I know in a traditional setup, SQLite decides, "Well, it's gotten big enough, checkpoint ready, let's write it." And a certain commit could take a little bit longer because it's doing the checkpointing as a part of that commit.

14:33

Ben Johnson

Mm.

14:33

Aaron Francis

In a Lightstream setup, who decides, all right, it's time to, it's time to commit, and then how do you... Are you literally plucking it out of the WAL file before you allow SQLite to commit, or how do you handle that, uh, that process there?

14:52

Ben Johnson

Sure, yeah. So what we ended up doing is, um, yeah, we essentially copied the, the same, um, settings as what SQLite defaults to.

15:02

Aaron Francis

Mm-hmm.

15:02

Ben Johnson

I think it's four megabytes, uh-

15:04

Aaron Francis

Mm

15:04

Ben Johnson

... for a WAL. Like, once it exceeds that, then it'll attempt to start, um, copying stuff back over. Uh, we essentially use the same settings and then kind of... We don't even, we don't implement the actual checkpointing process. We actually call-

15:16

Aaron Francis

Mm-hmm

15:16

Ben Johnson

... into the, the functions inside of SQLite to do the checkpointing. Um, so that's not implemen- implemented by us. They do document their whole WAL format.

15:24

Aaron Francis

Mm-hmm.

15:24

Ben Johnson

So it, it's pretty easy to read. It's basically the page data, and then it has some checksums, and like a, an incremental checksum and some salt and little-

15:32

Aaron Francis

Mm-hmm

15:33

Ben Johnson

... all those things as well. So-

15:34

Aaron Francis

Mm

15:34

Ben Johnson

... there's a lot of, like, little checks within there just to make sure that you're not, like, getting the wrong data or getting-

15:40

Aaron Francis

Mm

15:40

Ben Johnson

... uh, whatnot. So, um, yeah. So it essentially handles it on its own and just copies the, the settings.

15:47

Aaron Francis

Okay. And so when you reach that point, let's say it's four megabytes, when you reach that point, you have light, you, uh, being Lightstream, you have decided, um, all right, it's time to transfer this into the full on, the full on, um, .sqlite file. So then you presumably have some sort of internal state that says the last whatever checksum or the last page that you have sent off to S3

16:17

or S3 compatible, and so then you investigate the WAL file yourself, find where that is, send anything after that, and then let, uh, SQLite do the rest and put it back into the .sqlite file?

16:33

Ben Johnson

Uh, yeah, pretty much. And we actually have-

16:35

Aaron Francis

Huh

16:35

Ben Johnson

... one little difference is that we ac- have a, it's called, like, a shadow WAL. So essentially, we're copying stuff out to, like, a, a directory next to the database. Um, and that's, it'll store kind of the incremental things to send off, because you might not have connection to S3 or wherever you're sending to for some period of time. So it, it doesn't prevent you from checkpointing, um, without sending off.

16:54

Aaron Francis

Oh, that's interesting.

16:57

Ben Johnson

Yeah.

16:57

Aaron Francis

Okay, say that again. Say that again. Say that again.

16:58

Ben Johnson

Yeah, so-

16:59

Aaron Francis

So you have a shadow WAL-

17:00

Ben Johnson

Mm-hmm

17:00

Aaron Francis

... that when you let SQLite commit, in case you can't reach S3, you have put it aside such that when S3 is reachable again, that'll be sent off?

17:14

Ben Johnson

Yes. Yep.

17:15

Aaron Francis

Oh, that's clever.

17:16

Ben Johnson

And you can track stats of the stuff within, like, it has, like, Prometheus metrics you can attach, um, you know-

17:21

Aaron Francis

That's-

17:22

Ben Johnson

... Grafana or whatnot too

17:23

Aaron Francis

... super clever, because you wanna stay... Man, I'm just learning so much.

17:27

Ben Johnson

Yeah.

17:27

Aaron Francis

That's why I keep repeat, or I keep repeating it back to you, to make sure I have it. So you wanna stay, you need to be safe, 'cause you gotta stay out of the way of the database, and one place that could fall down is you're trying to send off changes and east one is down again. You can't reach it, and now everybody is trying to use this database that you are blocking because S3 is down.

17:52

And so to get around that, you've got a shadow WAL that you can just stash.

17:56

Ben Johnson

Yeah, exactly.

17:57

Aaron Francis

Huh. Did you, did you bake that in from the beginning, or did you have, did you-

18:02

Ben Johnson

Uh, yeah-

18:03

Aaron Francis

... kind of average

18:03

Ben Johnson

... it's pretty early on. I mean, part of it is that you kind of need to know the previous page that you read, um-

18:08

Aaron Francis

Mm

18:08

Ben Johnson

... just to make sure that it lines up, 'cause every page that's written essentially has-

18:12

Aaron Francis

Mm-hmm

18:12

Ben Johnson

... this rolling checksum that goes through the whole- Write a head log.

18:15

Aaron Francis

Mm-hmm.

18:15

Ben Johnson

And then the event that your, you know, Lightstream dies for whatever reason and comes back, it needs to be able to check to make sure that there's not new transactions written or there hasn't been a checkpoint.

18:24

Aaron Francis

Mm-hmm.

18:24

Ben Johnson

Uh, things like that. So it does a bunch of those checks, but it has to have the previous data in that shadow WAL to actually-

18:30

Aaron Francis

Yep

18:30

Ben Johnson

... check it against.

18:32

Aaron Francis

Okay. That makes a ton of sense. Okay. So then-

18:34

Ben Johnson

And then it just kind of worked out that it happened to be a shadow WAL and it, it's disconnected-

18:37

Aaron Francis

Yeah

18:37

Ben Johnson

... from S3.

18:39

Aaron Francis

That makes, that makes a lot of sense. So then you send-

18:41

Ben Johnson

'Cause you really don't want downtime, like, from your your-

18:44

Aaron Francis

No

18:44

Ben Johnson

... disaster recovery solution. That sucks.

18:46

Aaron Francis

No. You don't want... Then you are the disaster.

18:48

Ben Johnson

Exactly. Yeah.

18:49

Aaron Francis

And that's, that's the opposite of what we're looking for. Okay. So you send incremental, uh, backups off to S3 or S3 compatible, right?

18:57

Ben Johnson

Yeah.

18:57

Aaron Francis

Which would include, at this point, uh, Backblaze R2, Cloudflare something something.

19:02

Ben Johnson

Yeah. We also do GCS, uh, sorry, Google-

19:04

Aaron Francis

Okay

19:04

Ben Johnson

... Cloud Storage. We also do Azure. Um, I should know the other ones, but they're... Yeah.

19:09

Aaron Francis

Nah, that's all right.

19:10

Ben Johnson

Most, a lot of them are S3 compatible, so.

19:12

Aaron Francis

Okay. So then in S3, what would you find? Would you find a bunch of little files that are all, like, um, checkpoints, or what do you find in S3?

19:24

Ben Johnson

Sure, yeah. So it has essentially two subdirectories. You have one that is gonna be your snapshots.

19:29

Aaron Francis

Mm-hmm.

19:29

Ben Johnson

So you can configure Lightstream to snapshot every, uh, by default I think it's once a day, and then it'll, um... Next to that it'll have, like, a, a set of WAL files, and those WAL files-

19:39

Aaron Francis

Mm-hmm

19:39

Ben Johnson

... will essentially just keep incrementing up, and they can get replayed in order. Um-

19:44

Aaron Francis

Cool

19:44

Ben Johnson

... and then you basically can reproduce. It's nice 'cause you can actually reproduce the state of your database-

19:49

Aaron Francis

Mm-hmm

19:49

Ben Johnson

... at any point in time between the snapshot and now.

19:52

Aaron Francis

Mm-hmm.

19:53

Ben Johnson

So if you did do this, like, you know, delete table kind of business-

19:56

Aaron Francis

Mm-hmm

19:56

Ben Johnson

... and you need to get back to, like, five minutes ago, you can do that.

20:00

Aaron Francis

Man, that rules. Okay. Yep, that makes a ton of sense. Okay, and then what is the recovery story or, like, the restore story for Lightstream, and how far do you go to aid the developer to do that recovery?

20:16

Ben Johnson

Sure. It's just a restore command within Lightstream. So you say Lightstream space restore, and then you give it, um, yeah, the name of the database kind of or the replica where it's going up to.

20:25

Aaron Francis

Mm-hmm.

20:26

Ben Johnson

It'll pull it down, and then it'll essentially start with a snapshot and then just pull down a bunch of those little incremental changes and keep replaying those. And it actually uses SQLite to actually repro- r- replay them. Uh, that can actually take a little bit of time if you have, like, thousands of them.

20:41

Aaron Francis

Yeah.

20:42

Ben Johnson

So, um, it can be beneficial if you actually snapshot more often if you have a lot of changes, so maybe once an hour, uh, depending on your database size. But the nice thing about, like-

20:50

Aaron Francis

How do you-

20:51

Ben Johnson

Oh, go ahead.

20:51

Aaron Francis

No, no, no. Please.

20:53

Ben Johnson

Uh, the nice thing about, like, B-tree databases, um, which is what-

20:55

Aaron Francis

Mm-hmm

20:55

Ben Johnson

... SQLite is and VoltDB, is that, like, just by default they tend to have a bunch of space in them. Uh, you tend to, like-

21:02

Aaron Francis

Mm

21:02

Ben Johnson

... split trees a bunch-

21:03

Aaron Francis

Mm-hmm

21:03

Ben Johnson

... so you end up having... You never have, like, a, like, really tightly packed, um, database. Um, and that plus it's, like, all text data typically-

21:11

Aaron Francis

Mm-hmm

21:12

Ben Johnson

... is that you can actually just compress the, the crap out of it. So it's like, you know, you might have... Your database is, like, you know, 16% of the size of the actual-

21:20

Aaron Francis

Mm-hmm

21:20

Ben Johnson

... real thing. It's crazy. Uh, so it's not, it's not... We do, I think, uh, LZ4 compression, so we'll do that and send it up.

21:28

Aaron Francis

How do you, um, how do you make, uh, uh, how do you trick SQLite into replaying these, these incremental WALs? Do you just, like... I'm gonna guess and then you tell me why I'm wrong.

21:41

Ben Johnson

No. Go ahead.

21:41

Aaron Francis

Um, so you pull down a snapshot, which is, like, a, you know, .sqlite whatever, then you pull down a WAL file, and then open and close some sort of connection, and SQLite says, "Oh, there's a WAL. I'm gonna commit it."

21:56

Ben Johnson

Yeah.

21:56

Aaron Francis

Is that it?

21:57

Ben Johnson

There you go. There you go. Yeah. I mean, we'll pull down the, the WAL files in parallel behind the scenes.

22:02

Aaron Francis

Uh-huh. Yeah.

22:02

Ben Johnson

And then basically do a bunch of open and closes.

22:05

Aaron Francis

Control what shows up, what-

22:07

Ben Johnson

Yeah

22:07

Aaron Francis

... what's visible to SQLite with naming conventions and stuff, and then open and close.

22:10

Ben Johnson

Yeah. And we can actually improve the, the open time or, like, the, the restore time if we actually did it ourselves. It's not that complicated-

22:16

Aaron Francis

Uh-huh

22:16

Ben Johnson

... to replay the WAL, honestly. Uh, so I might do that in the future, but, um, yeah, it's not, it's not too bad.

22:22

Aaron Francis

But there's just... There's something so, um... I, if I were you, I would feel such great relief to know that you, that's, that's not your job.

22:34

Ben Johnson

Yeah.

22:34

Aaron Francis

Your job is just to, like, put the stuff where it goes and then let the, you know, the 25-year history of SQLite handle, you know, doing the right thing.

22:44

Ben Johnson

Yeah.

22:44

Aaron Francis

Which feels kinda like, yeah, I don't have to worry about that. That's a whole set of problems you don't have to develop for, test for, future-proof. That just feels, like, that feels kinda nice.

22:54

Ben Johnson

Yeah. I mean, there's definitely that benefit as well. Yeah. We got into a lot more of the, the nitty, greed- gritty details of, um, SQLite behavior when we did, like, LightFS next.

23:04

Aaron Francis

Mm-hmm.

23:04

Ben Johnson

And we can talk about that as well, but, um-

23:06

Aaron Francis

Mm-hmm

23:06

Ben Johnson

... so yeah, it's, that part's not too scary at this point.

23:09

Aaron Francis

Mm-hmm.

23:09

Ben Johnson

We actually had to do replays of WALs and things like that.

23:11

Aaron Francis

Mm-hmm.

23:11

Ben Johnson

Um, but yeah, no, I, I agree with you. It's, it's nice. Just not, it's not my problem kind of thing. It's nice.

23:15

Aaron Francis

Yeah, it's not your problem. Ah, I love not having problems. Okay. So let's talk, um, unless there's anything else about Lightstream, I feel like the level of complexity, you were like, "That was too easy. Let's double up- ... and write something else." So unless you have anything else on Lightstream, I wanna talk about LightFS.

23:32

Ben Johnson

Sure, yeah. No. Sounds good.

23:33

Aaron Francis

Okay. So my, um, my understanding of LightFS is another it's like... This is so great.

23:43

Ben Johnson

Yeah.

23:43

Aaron Francis

I feel like I love your style. It's, it's, um- ... another approach of making SQLite do something without telling SQLite that it's doing anything. So-

23:54

Ben Johnson

Yeah

23:54

Aaron Francis

... so my, my take on LightFS is, um, SQLite has this layer that, like, integrates or, or talks to the operating system. Is it, like, uh, VFS? Is, is that what they, that the layer they call it?

24:09

Ben Johnson

So the, so you can h- do a VFS within, uh, SQLite, which is called a virtual-

24:12

Aaron Francis

Okay

24:12

Ben Johnson

... file system.

24:13

Aaron Francis

Uh-huh.

24:13

Ben Johnson

And it has its own API within SQLite. Um-

24:16

Aaron Francis

Mm-hmm

24:16

Ben Johnson

... but the problem with that is you actually have to Like SQLite has to know about your underlying-

24:20

Aaron Francis

Mm

24:21

Ben Johnson

... system.

24:22

Aaron Francis

Yeah.

24:22

Ben Johnson

Has to be loaded in manually and all that stuff.

24:24

Aaron Francis

Okay.

24:24

Ben Johnson

Um, and we really wanted to make it very invisible. Um, so we actually use FUSE, uh, which is like a file... Oh, God, I should know the name of-

24:32

Aaron Francis

Yeah.

24:32

Ben Johnson

... or what that stands for. It's a user-

24:33

Aaron Francis

Yeah

24:33

Ben Johnson

... level file system within Linux-

24:34

Aaron Francis

Okay

24:34

Ben Johnson

... basically.

24:35

Aaron Francis

Okay. And so I thought where this was going was instead of, um, you know, using the, the Windows or the Linux or the OSX, like VFS, it uses Lightstream or LiteFS. That's wrong. So tell me how, how LiteFS works because clearly I, I had- ... the wrong idea on this.

24:56

Ben Johnson

Sure, yeah. I mean, and this actually stemmed out of Lightstream. So Light, Lightstream, um, one of the versions... Like, one, two of the requests we got more than probably anything else was that people wanted to be able to have something to roll over to, like switch basically the primary node.

25:12

Aaron Francis

Mm-hmm.

25:12

Ben Johnson

Like have a failover when they do deployments-

25:14

Aaron Francis

Okay

25:14

Ben Johnson

... 'cause you can get down- downtime otherwise. Um, and there's things you can control with that or, like, get around with that. Uh, so people wanted to fix, you know, the downtime when you switch over, and they also-

25:23

Aaron Francis

Mm-hmm

25:23

Ben Johnson

... wanna read replicas.

25:24

Aaron Francis

Mm-hmm.

25:24

Ben Johnson

So you might have, like, your main server in Virginia, but you might, you know, it's 100 milliseconds to Europe or-

25:30

Aaron Francis

Mm-hmm

25:30

Ben Johnson

... 250 milliseconds over to Asia. So, like, you might wanna put read replicas over there and make them super fast for everyone in the world.

25:38

Aaron Francis

Mm-hmm.

25:38

Ben Johnson

And I originally tried to do that in Lightstream.

25:41

Aaron Francis

Mm-hmm.

25:42

Ben Johnson

And it, I kind of got something working. But there's just, like, since you don't have control over SQLite and, like, the actual-

25:50

Aaron Francis

Mm-hmm

25:50

Ben Johnson

... uh, the write calls and the reads and everything-

25:52

Aaron Francis

Mm-hmm

25:52

Ben Johnson

... you just have, you don't have quite enough control to really guarantee that you're not gonna get corruption or that you're not gonna send wrong files or whatnot. It's just, it's a really touchy thing, uh, when you get down to that level. Uh, so the idea was basically to kind of take over some control over that, so we made this essentially pass through, um, file system called LiteFS.

26:12

Aaron Francis

Okay. Mm-hmm.

26:12

Ben Johnson

And what it does is when SQLite does a write to, to the file system-

26:17

Aaron Francis

Mm-hmm

26:17

Ben Johnson

... it'll go through our file system, and so it can-

26:19

Aaron Francis

Mm-hmm

26:19

Ben Johnson

... detect it, and we basically pass-

26:21

Aaron Francis

Mm

26:21

Ben Johnson

... it off again to the underlying, the real file system. So we can track every single write call that goes through and-

26:26

Aaron Francis

Mm-hmm

26:26

Ben Johnson

... um, that gives us... Also, we can track our, the locks on the actual database too when they-

26:31

Aaron Francis

Right

26:31

Ben Johnson

... 'cause there's, like, a bunch of locks that they, they use.

26:34

Aaron Francis

Right.

26:34

Ben Johnson

So we can detect when a, a write starts, when it ends, and all kinds of things, just a lot, a lot of it's from the locks themselves. Uh, so we essentially can demarcate the start and end of all transactions, and then we can track all the writes that occur in between them, and then we can kind of read out those changes for each write-

26:51

Aaron Francis

Uh-huh

26:51

Ben Johnson

... um, and then stuff them into what we call an LTX, uh, LiteFS transaction file.

26:56

Aaron Francis

Okay.

26:56

Ben Johnson

And that's essentially like a little package of, like a change set for a transaction-

27:01

Aaron Francis

Mm-hmm

27:01

Ben Johnson

... uh, that we can ship off to other replicas. So they can replay that same transaction, and it's again just like page changes.

27:08

Aaron Francis

Mm-hmm.

27:08

Ben Johnson

Um, so we can have essentially a primary, and that gets all the changes, and then it can ship them off to the other, uh, replicas.

27:15

Aaron Francis

So help me understand, and this is, this is my low-level systems knowledge, or rather my lack of-

27:24

Ben Johnson

Yeah

27:24

Aaron Francis

... um, low-level systems knowledge showing. How do you sneak in? I, I'll be honest, I don't know what a FUSE is. I know it's all caps-

27:32

Ben Johnson

Oh, yeah

27:32

Aaron Francis

... and, and I know that neither of us know- ... what it stands for. But how do you sneak in in between SQLite and the actual file system? What, what, what does that even mean?

27:41

Ben Johnson

Sure, yeah. So it's, so I did actually remember what it is. It's, it's file-

27:44

Aaron Francis

Okay

27:44

Ben Johnson

... system and user space. So you're essentially-

27:46

Aaron Francis

Okay

27:46

Ben Johnson

... writing an actual file system.

27:48

Aaron Francis

Okay.

27:48

Ben Johnson

Um, and it has calls for writes and, you know, make directory and all that stuff.

27:52

Aaron Francis

Mm-hmm.

27:52

Ben Johnson

Um, and they're, they're actually kind of fun to build, honestly. I've, I built one- ... a long time ago where you get, like, you get, like-

27:57

Aaron Francis

Says the guy that builds databases for giggles.

27:59

Ben Johnson

Yeah.

27:59

Aaron Francis

So take that with a grain of salt, everyone.

28:01

Ben Johnson

Yeah. No, I made one, like, a long time ago where it was like I wanted to be able to see my GitHub, like look through GitHub, and, like, you can, like, basically look at GitHub as a directory tree. So you can, like, look at repos and users and, like-

28:10

Aaron Francis

Oh

28:10

Ben Johnson

... it's-

28:10

Aaron Francis

Sounds pretty cool, yeah.

28:11

Ben Johnson

Yeah, just a little throwaway kind of fun little project.

28:12

Aaron Francis

I agree. You got me. That's pretty cool.

28:14

Ben Johnson

Yeah. I think I was, like, mentoring some, some students one time on, like, some stuff, and we were like, "Ah, let's make a project," and that's just what we came up with, so.

28:22

Aaron Francis

Yep.

28:22

Ben Johnson

It was a random... Anyway.

28:23

Aaron Francis

Those, those... Yeah, those students are gonna be just fine if that was-

28:26

Ben Johnson

Those-

28:26

Aaron Francis

... their little, little project.

28:28

Ben Johnson

Poor-

28:28

Aaron Francis

They'll be okay

28:28

Ben Johnson

... poor students. Um, so we ended up, uh... Oh, yeah, so yeah. File system. So essentially, like, load it up as a file system, as you would-

28:36

Aaron Francis

Mm-hmm

28:37

Ben Johnson

... um, like another file system. I mean, there's a, there's a mount command within FUSE, so essentially, like, it's literally a file system.

28:43

Aaron Francis

Okay.

28:44

Ben Johnson

Um, and then you also give it the, a target for where you want it to write its data, which is on the-

28:49

Aaron Francis

Mm-hmm

28:49

Ben Johnson

... the normal file system that you're already using.

28:52

Aaron Francis

Mm-hmm.

28:52

Ben Johnson

Um, so it kind of has its, its own data directory and whatnot behind the scenes on your file system.

28:57

Aaron Francis

Mm-hmm.

28:57

Ben Johnson

It's just it kind of makes a, a little shim in between the two, essentially.

29:01

Aaron Francis

And then for the user, uh, for the developer, how do they make SQLite aware of LiteFS?

29:11

Ben Johnson

Sure. So they just have to point it at the directory that comes up from that file system, and they can start making databases just in the way they normally write them. Like, you just open a connection, write your database. All the changes are happen invisibly-

29:25

Aaron Francis

Uh-huh

29:25

Ben Johnson

... and they get kind of shuttled off behind the scenes. So it looks exactly like a regular SQLite database-

29:30

Aaron Francis

Mm-hmm

29:31

Ben Johnson

... um, just on a different file system.

29:34

Aaron Francis

Man, that is super clever. Okay. So you have, uh, LiteFS is a custom file system that is basically like a, like a decorator or a proxy or something.

29:49

Ben Johnson

Mm-hmm.

29:49

Aaron Francis

And so you're listening, uh... You're not listening. They're ac- SQLite is actually writing to you.

29:57

Ben Johnson

Mm-hmm.

29:57

Aaron Francis

And then you're passing that through and setting it aside, and then when you reach a certain point, maybe the transaction closed or you've gathered a few transactions, I don't know. When you reach a certain point, you fire this, this custom packet off somewhere, and LiteFS is waiting on the other side to receive this, this unified tran- like, this file format that you both speak.

30:23

Ben Johnson

Mm-hmm.

30:23

Aaron Francis

And then you turn that- Back into SQLite on the other side and pass it through to the underlying file system over there?

30:34

Ben Johnson

Yeah, essentially it's, I mean, yeah, more or less. So we, we package up every transaction separately.

30:40

Aaron Francis

Mm-hmm.

30:40

Ben Johnson

And then it stores-

30:41

Aaron Francis

Okay

30:41

Ben Johnson

... on the primary node for some period of time, and then the other nodes actually connect up to the primary, and they'll just continuously stream down anything that comes in. So-

30:50

Aaron Francis

Oh, I see

30:51

Ben Johnson

... from the time you actually write the transaction, you know, it takes less than a millisecond to actually replicate-

30:57

Aaron Francis

Mm-hmm

30:57

Ben Johnson

... plus any latency, like physical latency.

30:59

Aaron Francis

Ph- yeah.

31:00

Ben Johnson

Um-

31:00

Aaron Francis

Plus the speed of light. Okay.

31:01

Ben Johnson

Yeah, that dang speed of light, yeah.

31:03

Aaron Francis

I know. We'll get it one day. So you have these other, you have these replicas, um, these other, these other servers have LightFS on it, and the other servers are aware of where the primary is, or rather I guess what the primary is.

31:19

Ben Johnson

Mm-hmm.

31:19

Aaron Francis

And it has some process there that is constantly polling or there's some- something fancier to watch for new transactions it needs to pull. Is that right?

31:29

Ben Johnson

Yeah, it's just a constant connection that's-

31:31

Aaron Francis

Okay.

31:31

Ben Johnson

Yep.

31:32

Aaron Francis

Okay.

31:33

Ben Johnson

Stream, yeah, streams them down, and then, um, yeah, it has a bunch of checksumming and all that stuff in there to make sure it's, uh, everything ends up in the appropriate state. We actually do, like, a, a rolling checksum, which I don't, I'm sure other databases have done this.

31:46

Aaron Francis

Mm-hmm.

31:46

Ben Johnson

I don't think we're novel by any means, but, like, it's interesting that we actually, we'll take the pages that are changed, and we'll essentially do an XOR checksum to remove the old version of the page from the checksum-

31:57

Aaron Francis

Mm-hmm

31:57

Ben Johnson

... and then put in the new version of the page as a checksum. So it can actually compute, like, a, a rolling, like an actual checksum for every single transaction in the database.

32:05

Aaron Francis

Mm-hmm.

32:05

Ben Johnson

Uh, so we actually can really clearly see if we have any corruption anywhere in the process, um, which has been nice. And we can actually, yeah, there's some-

32:12

Aaron Francis

Yeah.

32:13

Ben Johnson

Oh, go ahead. Yeah.

32:14

Aaron Francis

Uh, no, I was gonna say that seems like rule number one is-

32:18

Ben Johnson

Yeah

32:18

Aaron Francis

... you've gotta make sure that everything that's supposed to get there gets there, and nothing that's not supposed to be there gets there. 'Cause if you end up with, you know, a corrupted replica down in Australia, you're hosed. Like-

32:31

Ben Johnson

Yeah

32:31

Aaron Francis

... that's, that's a, that's the pur- that was what you were trying to solve here.

32:34

Ben Johnson

Yeah. And people, some people also wanted the failover piece, where, like-

32:37

Aaron Francis

Mm-hmm

32:37

Ben Johnson

... you could have multiple primary, or not primaries. You can have multiple candidates essentially, so you might have two that are in, um-

32:43

Aaron Francis

Hmm

32:44

Ben Johnson

... one region, and they can just flip-flop when you do a deployment. Um, we actually use Consul, like HashiCorp's Consul-

32:50

Aaron Francis

Mm-hmm

32:50

Ben Johnson

... uh, is one of the, the things we use for that. So it's optional. You can either have, like, a fixed primary, which one-

32:54

Aaron Francis

Mm-hmm

32:54

Ben Johnson

... machine is always a primary, or we can actually have it where it does a le- leader election, and then it can flip-flop over. Um-

33:00

Aaron Francis

Hmm

33:00

Ben Johnson

... but so we have some looser guarantees when you use something like Consul about who can actually, like, w- when a transaction's actually persisted and these actually get to the other candidate.

33:10

Aaron Francis

Mm-hmm.

33:10

Ben Johnson

Um, but you can have a, a scenario where you get a write that's actually written down and not replicated to the, uh, the candidate yet. So when it does flip, like, you could lose that, you know, little sliver of time.

33:20

Aaron Francis

Mm-hmm.

33:20

Ben Johnson

Uh, we need to be able to check to make sure that the checksums, you know, if they do change between different nodes, um, that we can re-snapshot and send those down to the replicas.

33:29

Aaron Francis

Hmm. Okay. So talk to me about, um, how do you do... So you've got, uh, somebody, you got a primary in Dallas and a replica in Australia. Somebody in Australia does a write.

33:45

Ben Johnson

Mm-hmm.

33:45

Aaron Francis

How do you do write forwarding, um, inside of, of fly.io? 'Cause I understand this is, like, kinda y'all's, y'all's bread and butters. Put, put stuff on the edge, and we'll figure out the rest. And then is it possible outside of fly.io?

34:01

Ben Johnson

Sure, yeah. So, uh, like SQL, or sorry, LightFS isn't specific to, to Fly. We, we certainly-

34:07

Aaron Francis

Okay

34:07

Ben Johnson

... want people to use it on there. Um, but it's open source. It's all Apache 2, uh, so you can go do whatever you'd like with it. Um, and it'll work on any system really. Uh, there is some stuff we do in there. Um, so one, one issue we ran into after we got, you know, stuff working, was that, uh, we originally had, like, w- probably the best way to do it is to have the application send the write, like send all writes to the primary, and then you can read all your reads from the replica.

34:35

Um, but again, that speed of light thing where you might send a write-

34:39

Aaron Francis

Mm-hmm

34:39

Ben Johnson

... to the primary, but then you read from the replica before the write actually gets down to the replica. Uh, so you can get this out of order kind of appearance in the application. Um, and we spent quite a while trying to figure out the best way to, to manage that. And essentially, like, you know, we don't, we don't want everyone to have to, like, check for, like, a, a transaction ID on every single read they do, and do a bunch of, you know, playing around to make sure they have, like, a consistent view of the data.

35:06

Uh, so we actually have a, an optional, like, HTTP proxy you can run in front of your, um, application, so it'll actually check for the, um, essentially the, the write transaction when it went in and make sure that your reads are caught up before the next read transaction comes in, and does that kind of invisibly to the application itself.

35:25

Aaron Francis

Right.

35:25

Ben Johnson

So we kinda, like, sandwich, like your application's here, and there's like a proxy-

35:29

Aaron Francis

Mm-hmm

35:29

Ben Johnson

... here and, like, a file system-

35:30

Aaron Francis

Mm-hmm

35:30

Ben Johnson

... here, like s- you know, lovingly hugging your application

35:33

Aaron Francis

Yeah

35:33

Ben Johnson

... um, to give it consistency-

35:35

Aaron Francis

I like that

35:35

Ben Johnson

... and all that. So, uh, yeah, so right now it's, it's mainly on the application side we typically recommend. We did some-

35:41

Aaron Francis

Mm-hmm

35:41

Ben Johnson

... work with write forwarding within SQLite, um, but it was just, it was more of a pain than I would say it's worth typically.

35:49

Aaron Francis

Yeah. That sounds, that sounds pretty complicated. Um, so what's the, what's the story on, like, if somebody, somebody did wanna spin up LightFS, what is the, like, uh... How do you, how do you get it? How easy is it? It sounds-

36:05

Ben Johnson

Okay

36:05

Aaron Francis

... sounds like you've got it pretty nailed, but tell me. What would-

36:07

Ben Johnson

Sure, yeah

36:07

Aaron Francis

... what would one do?

36:08

Ben Johnson

Yeah. We have some, some docs on, on Fly, uh, you can check out as well. Uh, I think it's fly.io/docs/lightfs.

36:15

Aaron Francis

Mm-hmm.

36:15

Ben Johnson

Um, you can go on there and essentially you, we have it all bundled up as a, as a Docker container or-

36:21

Aaron Francis

Mm-hmm

36:21

Ben Johnson

... Docker image. Uh, the funny thing is we actually don't use Docker as, like, the thing, 'cause you actually need to pull the binary in to your-

36:27

Aaron Francis

Mm-hmm

36:27

Ben Johnson

... your own Docker image. Um, so we just actually copy it out, which is... It's, like, a really convenient way to use Docker to, like, copy binaries if you're using Go, 'cause it's all static binaries. Um, and yeah, so essentially you can copy it down to your, your development or your, uh, your Docker image, and you run it, and then it kind of runs your application as a, a supervisor.

36:50

Aaron Francis

Mm.

36:50

Ben Johnson

Um, and then beyond that, there's... If you have an application where your, your writes all go through, like, POST and PATCH and all those kind of standard HTTP verbs-

37:00

Aaron Francis

Mm

37:00

Ben Johnson

... and then your reads all go through GETs, then it kind of just works more or less.

37:04

Aaron Francis

That's awesome.

37:04

Ben Johnson

Uh, you simply just point your, your application. You can actually do it with, like, uh, WordPress. I think we've done that before.

37:09

Aaron Francis

That is so awesome.

37:10

Ben Johnson

We just spin up WordPress, and, like, point it at LightFS, and it just magically does the right things, which is kind of cool.

37:16

Aaron Francis

I bet that felt pretty cool.

37:17

Ben Johnson

Yeah. Yeah, that was, that was a good one.

37:20

Aaron Francis

If you, if you can do it, if you can just make it work with WordPress, that's how you know- ... you've got it, you've got it sorted.

37:26

Ben Johnson

Oh, yeah.

37:27

Aaron Francis

That's pretty amazing. So what do you see for, um, what do you see for the, like, uh, philosophical demarcation between Lightstream and LightFS, and where do you wanna take both of them moving forward? 'Cause is this what-

37:43

Ben Johnson

Mm

37:43

Aaron Francis

... you do at Fly? Is this your full-time... You just, you just write SQLite stuff and talk about SQLite and build Lightstream and LightFS. Is that all you do?

37:52

Ben Johnson

Uh, no, no, it's not all the, it's not the only thing I do. I do that.

37:54

Aaron Francis

Oh, okay.

37:54

Ben Johnson

But I also do, we do a, a bunch of, like, back-end work, reliability stuff. We do a lot of, um-

37:59

Aaron Francis

You, you do that?

38:00

Ben Johnson

Mm-hmm, yeah.

38:01

Aaron Francis

Oh, okay.

38:02

Ben Johnson

So just kind of write a couple tests.

38:02

Aaron Francis

I thought you got to just, just play in the lab all day.

38:06

Ben Johnson

Sometimes, yeah. Sometimes I do.

38:07

Aaron Francis

Yeah.

38:08

Ben Johnson

Um, yeah, I mean... Sorry, what was the question again?

38:10

Aaron Francis

The philosophical demarcation-

38:11

Ben Johnson

Oh, yeah, yeah

38:12

Aaron Francis

... between the two things, and then what your vision for the future of them is.

38:17

Ben Johnson

Sure. So Lightstream was... I kind of realized, like, adding all the replication stuff and all that just made a lot of pieces a lot more complicated or a lot more-

38:25

Aaron Francis

Mm

38:25

Ben Johnson

... complex. And essentially, Lightstream is kind of a disaster recovery only solution. Like, that's all-

38:30

Aaron Francis

Okay

38:30

Ben Johnson

... it does. Uh, so if you have a single node and you wanna stream up, do a streaming backup somewhere to S3-

38:36

Aaron Francis

Mm-hmm

38:36

Ben Johnson

... it's great for that. Like, you can do that-

38:37

Aaron Francis

Yeah

38:37

Ben Johnson

... all day long. Uh, and then Lightstream's never gonna be more than that. Um-

38:41

Aaron Francis

Great

38:41

Ben Johnson

... that's kind of its, its goal. And then LightFS is kind of the distributed systems, like you need replicas, or you want replicas, and you need, you know, low latency and all that stuff-

38:50

Aaron Francis

Mm

38:50

Ben Johnson

... around the world. Uh, or you want failovers. All kinds of stuff like that. It's, has a lot more complexity. We also have a thing called LightFS Cloud, where you can stream your backups up to, to Fly, and we'll save them, give you, like, point in time, uh, recovery as well.

39:03

Aaron Francis

Cool. So, um, would it be reasonable to say that you could use LightFS to get embedded replicas everywhere, and also use Lightstream to stash all that away on S3?

39:19

Ben Johnson

Uh, you can. It gets a little more complicated, um, but it is possible. You can run it. 'Cause you might have multiple primaries. That's kind of where the issue comes in.

39:26

Aaron Francis

Oh, I see.

39:26

Ben Johnson

And you'd essentially have to replicate each separate primary.

39:29

Aaron Francis

Oh, okay.

39:30

Ben Johnson

Um, so it's not as much fun doing both.

39:32

Aaron Francis

Yeah.

39:32

Ben Johnson

But, uh, but LightFS Cloud is kind of the disaster recovery side of the-

39:36

Aaron Francis

That. Okay

39:37

Ben Johnson

... LightFS piece.

39:38

Aaron Francis

Okay. Okay. That makes sense. And what do you see, um, beyond or maybe inclusive of building out LightFS Cloud? What do you see for the future of LightFS?

39:49

Ben Johnson

Sure. I mean, I think we might... I mean, LightFS Cloud is a paid service. Five bucks a month, you can get backups up there. Um, and I think, you know, we have some work we wanna do around moving some of that stuff into, like, a simpler version into LightFS itself.

40:03

Aaron Francis

Mm.

40:03

Ben Johnson

So you can do streaming backups to S3. Um, it gets a little more complicated when you don't have, like, a single service that can kind of manage, um-

40:11

Aaron Francis

Mm-hmm

40:11

Ben Johnson

... like, leadership and things like that. Uh, so there's some of the little hairy problems to get in there. Um, but I would say as far as LightFS, I mean, a lot of it is, you know, I think improving performance is always a good thing. Um, optimizing and just squashing bugs, but-

40:24

Aaron Francis

Mm-hmm

40:24

Ben Johnson

... um, you know, I don't, I don't have, like... I wouldn't say I have, like, grand features. I mean, we have some things that people have requested, like having a, an HTTP query API, so you can actually query LightFS over HTTP, which I know Turso-

40:36

Aaron Francis

That's interesting

40:36

Ben Johnson

... actually, we, I think we talked to Turso actually to see what their format was for that to try to use the same one.

40:41

Aaron Francis

Mm-hmm.

40:42

Ben Johnson

So it's, um... Yeah. There's, there's been a handful of requests like that.

40:46

Aaron Francis

Yeah. That's, that's super interesting.

40:48

Ben Johnson

Yeah.

40:48

Aaron Francis

Um-

40:48

Ben Johnson

But I'd like to keep it mostly simple, though. I mean, I, I think a lot of database companies just tack on features all the time. I used to be an Oracle DBA, like, 20 years ago.

40:56

Aaron Francis

Oh, yeah.

40:57

Ben Johnson

And, like-

40:57

Aaron Francis

You come by it-

40:57

Ben Johnson

... the number of-

40:58

Aaron Francis

... honestly. I see.

40:59

Ben Johnson

Yeah.

40:59

Aaron Francis

Okay.

40:59

Ben Johnson

The number of books that you have to, like, read just to, like-

41:02

Aaron Francis

Mm-hmm

41:02

Ben Johnson

... understand the basics of Oracle is crazy.

41:05

Aaron Francis

These are just, these are just my SQL right here.

41:07

Ben Johnson

No. Yeah.

41:07

Aaron Francis

I mean, that's, you know, they just keep going. You gotta know a lot to-

41:10

Ben Johnson

Yeah

41:11

Aaron Francis

... run these things. Um, okay. I like that. It feels to me like, um, this is, uh, like Lightstream and LightFS are, um, spiritual cousins of SQLite in that way, that it's, like, small, fast, reliable, and kind of done. Like, there's, you know, SQLite will continue to add things as we invent-

41:33

Ben Johnson

Yeah

41:33

Aaron Francis

... you know, CTEs and window functions and all that stuff. They, they continue to push forward. But in terms of, like, hey, the, you know, LightFS is good at what it does. We'll make it faster, we'll make it more reliable, but we're not gonna just continue to bolt nonsense on there. It feels like, ah, it has a home with SQLite. Y'all are, y'all are-

41:51

Ben Johnson

Yeah

41:51

Aaron Francis

... twins.

41:52

Ben Johnson

Yeah. I really love projects that have a scope, and like-

41:54

Aaron Francis

Mm-hmm

41:55

Ben Johnson

... like, Bolt was kind of like that. At one point I just, I marked it as 1.0, and I was like, "This is done." And I mean, obviously, you know, bug thing, bugs can come up-

42:03

Aaron Francis

Sure

42:03

Ben Johnson

... and whatnot. Um, but essentially, like, I wasn't adding any more features. Like, it's a key value store. Like, you get keys and values.

42:09

Aaron Francis

Mm-hmm.

42:09

Ben Johnson

Like, there's not a lot more than that.

42:11

Aaron Francis

Yeah. It's pretty, pretty straightforward.

42:13

Ben Johnson

Yeah.

42:13

Aaron Francis

Yeah.

42:13

Ben Johnson

Um, so yeah, that's kind of where that... I, I like projects that are like that. I feel like-

42:18

Aaron Francis

Mm-hmm

42:18

Ben Johnson

... there's too many projects that just go way too deep and, like-

42:21

Aaron Francis

Mm-hmm

42:21

Ben Johnson

... add too many things, and... I feel like whenever-

42:24

Aaron Francis

Well-

42:24

Ben Johnson

... people talk about their favorite projects, it's never like, "Oh, I love this grandiose, complex thing." They're like, "Oh, I like rsync," or like, what?

42:30

Aaron Francis

Uh-huh.

42:30

Ben Johnson

Like, some, like, simple tool, does one job, it does it great.

42:34

Aaron Francis

Yeah.

42:35

Ben Johnson

So.

42:35

Aaron Francis

The same with, like, their favorite little Mac apps or whatever. It's like this random little thing you've never heard- ... that solves this one problem perfectly, and everybody's in love with it.

42:44

Ben Johnson

Oh, yeah. Yeah.

42:44

Aaron Francis

You know.

42:44

Ben Johnson

Monodraw. Have you ever used Monodraw?

42:46

Aaron Francis

No. What is that?

42:47

Ben Johnson

It's like a, uh, an ASCII art editor. Um, so you can draw-

42:50

Aaron Francis

That's cool

42:50

Ben Johnson

... diagrams in ASCII art. It's like, I mean, it's a good product. And-

42:54

Aaron Francis

Mm-hmm

42:54

Ben Johnson

... honestly, but they're not, like, adding crazy features. There's no, like, sharing to Twitter, I don't think, or like, you know, whatever-

43:00

Aaron Francis

Mm-hmm

43:00

Ben Johnson

... like every product seems to add.

43:02

Aaron Francis

Mm-hmm.

43:02

Ben Johnson

It's great though.

43:04

Aaron Francis

There's no AI in there?

43:05

Ben Johnson

Not, not yet.

43:06

Aaron Francis

Not yet. Yeah.

43:08

Ben Johnson

Yeah. No, God forbid.

43:09

Aaron Francis

Knock on wood. Yeah. Um, okay, I kind of want to finish by talking about, uh, this, like, SQLite renaissance, and like what is your... Uh, which I think you have helped drive with these tools. So what is your perspective on why now? You know, it's been around since the year 2000.

43:30

Um, but-

43:31

Ben Johnson

Hmm

43:31

Aaron Francis

... why now? What, what, what is driving it, and what, where do you think, like, its best and highest use case is?

43:41

Ben Johnson

Sure, yeah. Um, I think that, I think the renaissance is driven by a couple things. Um, I would say complexity is a big thing.

43:48

Aaron Francis

Mm-hmm.

43:48

Ben Johnson

Where it just seems like there's so many dependencies you need to add to a project just to do a Hello World at this point.

43:54

Aaron Francis

Mm-hmm.

43:54

Ben Johnson

And it's just, it's a little absurd for certain things. I mean, not for every- I mean, everything has its place, obviously.

43:59

Aaron Francis

Sure.

43:59

Ben Johnson

There are tools that are written for a reason, but you don't need to do some Google scale project when you just need it to do it.

44:05

Aaron Francis

Mm-hmm.

44:06

Ben Johnson

Um, so I think complexity is a big piece. Um, just having one file.

44:09

Aaron Francis

And by that you mean, like, the, uh, the rage against current complexity, and you feel like this is part of swinging it back?

44:17

Ben Johnson

Yeah. Yeah, for sure.

44:18

Aaron Francis

Okay.

44:18

Ben Johnson

Uh, especially for certain projects where you don't need all that stuff. Like-

44:21

Aaron Francis

Mm-hmm

44:22

Ben Johnson

... when you have SQLite, you don't really need a cache, like Redis or something, or Memcache. Like, everything's right there, right next to you-

44:28

Aaron Francis

Mm-hmm

44:28

Ben Johnson

... in memory half the time.

44:29

Aaron Francis

Mm-hmm.

44:29

Ben Johnson

And like, um, adding a cache would be ridiculous most of the time. So I think that there's, um, a lot of pushback around that. I mean, also other tools like, you know, people use Elasticsearch, but you may not need that based on the full text st- search that's built-

44:42

Aaron Francis

Mm-hmm

44:42

Ben Johnson

... into SQLite. Or like you have JSON support within SQLite.

44:46

Aaron Francis

Mm-hmm.

44:46

Ben Johnson

And like, there's all kinds of little great tools within there that do a lot of the job. It's kind of like-

44:50

Aaron Francis

Mm-hmm

44:50

Ben Johnson

... I write in Go mostly, and like the Go standard library has, like, 90% of what I need for, like, most applications, surprisingly.

44:57

Aaron Francis

I, I've never used Go, but that is the thing that I keep seeing on Twitter. It's like, "Oh yeah, Go, Go has that. Oh yeah-

45:02

Ben Johnson

Yeah

45:02

Aaron Francis

... Go has that."

45:03

Ben Johnson

Yeah.

45:03

Aaron Francis

It's like, that seems cool.

45:04

Ben Johnson

It's, yeah, that's great. It's, yeah. So, um, yeah, I think there's a lot, I think there's a lot you can do with just a basic, uh, SQLite app, which is great.

45:12

Aaron Francis

Mm-hmm.

45:13

Ben Johnson

And I think the other thing, too, is just the, the speed of our machines is just-

45:18

Aaron Francis

Mm

45:18

Ben Johnson

... wild at this point, where, like, you can really... I mean, you can serve, I mean, again, I write Go, but, like, Go and SQLite, I can serve hundreds or thousands of requests per second with a, a fairly minimal setup-

45:30

Aaron Francis

Mm-hmm

45:30

Ben Johnson

... which is wild. Um, and you know, most people are getting maybe less than one request per second on their app. Like, you don't need some crazy deployment, um-

45:40

Aaron Francis

Yeah

45:41

Ben Johnson

... or at least not to start.

45:41

Aaron Francis

We are.

45:42

Ben Johnson

You know, you can always... What's that?

45:43

Aaron Francis

We are getting less than, yeah. It's like-

45:45

Ben Johnson

Yeah

45:45

Aaron Francis

... we get thousands of requests per month, and you're like-

45:48

Ben Johnson

Yeah

45:48

Aaron Francis

... "Oh, okay, you'll be just fine."

45:50

Ben Johnson

Yeah. Even per day, I mean, there's like eight- ... 86,000 seconds per day. I mean, like-

45:55

Aaron Francis

Yeah.

45:56

Ben Johnson

Um, yeah. So I think that there's, there's a place, I think, for SQLite, um, for, I would say the vast majority of a- applications. Um, and once you start to scale, there's reasons to scale, there's reasons to break things apart.

46:07

Aaron Francis

Mm-hmm.

46:07

Ben Johnson

Especially once you get to, like, a bigger organization. But a lot of times you're writing, you know, either, like, an internal app for somebody, or you're-

46:13

Aaron Francis

Mm

46:13

Ben Johnson

... starting a startup or those things, and those don't need to be crazy, I don't think.

46:18

Aaron Francis

Yeah.

46:19

Ben Johnson

I'm also a big believer that, like, whenever... I mean, I think it's been said where, like, every time you scale up, uh, like, an order of magnitude, you have to rewrite your application. Maybe that's not, like-

46:28

Aaron Francis

Hmm

46:28

Ben Johnson

... quite the exact, um-

46:29

Aaron Francis

I, I like it though. We'll go with it. Yeah.

46:31

Ben Johnson

Yeah. It's not the exact-

46:32

Aaron Francis

That's good to me. Yeah

46:32

Ben Johnson

... um, idea. Maybe every, you know, two orders of magnitude you gotta restart. But, um, yeah, I think it's, you eventually have to rewrite anyway, I would say, to some degree, and that may be that you move to a different database down the road-

46:46

Aaron Francis

Mm-hmm

46:46

Ben Johnson

... if you need to. But you don't need to plan for that at the moment.

46:49

Aaron Francis

Yeah. And I think one of the, one of the selling points of SQLite is that it's, you know, it's very powerful, but it's relatively constrained, and if you need to move onto Postgres or MySQL, you're gonna have a pretty easy time doing that. Like, you'll have to set up a bunch of stuff, but your actual queries and stuff most likely are gonna work, especially if you move towards Postgres.

47:12

I feel like they took a lot of inspiration from Postgres versus MySQL. Whereas going from Postgres to SQLite is gonna be a lot-

47:18

Ben Johnson

Yeah, that's a-

47:18

Aaron Francis

... harder.

47:19

Ben Johnson

Yeah.

47:19

Aaron Francis

That, you don't want it to go that way.

47:21

Ben Johnson

Yeah.

47:21

Aaron Francis

So it does seem like the graduation story, should you need to get there, is, is pretty good. It's pretty straightforward.

47:27

Ben Johnson

Yeah, no. Yeah, I think 100%. Uh, and there's a lot of cool stuff in Postgres. By all means, like, I don't mean to-

47:32

Aaron Francis

Mm-hmm

47:32

Ben Johnson

... knock any other database. You can use Mongo-

47:34

Aaron Francis

Me either, yeah

47:34

Ben Johnson

... if you want to. Like-

47:35

Aaron Francis

Mm

47:35

Ben Johnson

... there's a place for everything. Um, but yeah. Uh, yeah, the graduation stories. The, what's, what's the opposite of the, on graduation stories? Yeah.

47:43

Aaron Francis

Yeah.

47:43

Ben Johnson

It's, it's gonna be rough probably.

47:44

Aaron Francis

It's demotion-

47:44

Ben Johnson

Yeah

47:44

Aaron Francis

... or, yeah, getting held back, something like that.

47:46

Ben Johnson

Yeah. There's cool stuff like lateral joins in, um, Postgres. You know, that's cool.

47:50

Aaron Francis

Mm-hmm.

47:50

Ben Johnson

But you don't have that in SQLite.

47:52

Aaron Francis

Mm-hmm.

47:52

Ben Johnson

Although I would add, like, a lot of things you don't actually need when you actually have a database right next to you in memory.

47:58

Aaron Francis

Mm-hmm.

47:59

Ben Johnson

Um, like, I, I feel like a lot of, like, complex, big, huge queries you could break up into small queries if you don't have any, you know, qu- per query overhead, like latency.

48:07

Aaron Francis

Right. If there's no 25-millisecond penalty to get, even get to the database, you're not having to do everything in one shot.

48:16

Ben Johnson

Yeah.

48:16

Aaron Francis

Yeah.

48:17

Ben Johnson

Yeah. You can do, like, hundreds of queries in a, a page, and that's not a big deal in S- in SQLite, which is nice.

48:23

Aaron Francis

I think, I think the SQLite docs show how many queries are run on a single-

48:28

Ben Johnson

Yeah.

48:29

Aaron Francis

... page. And there's-

48:29

Ben Johnson

It's like 200 queries or something

48:30

Aaron Francis

... it's like, yes. It's like 220 queries.

48:33

Ben Johnson

Yeah.

48:33

Aaron Francis

And then it says, you know, page generated in point, you know, 0.001 seconds, and you're like-

48:38

Ben Johnson

Yeah

48:38

Aaron Francis

... "Ah, okay." "That's kind of cool. I get it. I get it." So I like, I like that. Um, okay, so is there anything else you wanna cover about SQLite? This, I'll tell you what, this has been... I've learned so much, and this has been such a blast, and I'm very grateful for your time to, to educate me.

49:00

So is there anything else you wanna cover about SQLite, LiteFS, LiteStream, or Fly.io?

49:05

Ben Johnson

Uh, no, I think it was great. I mean, I think that there's still a lot of potential out there, like of things people can build on SQLite and tooling.

49:12

Aaron Francis

Mm-hmm.

49:12

Ben Johnson

And, you know, there's always, um... Actually, one, one thing I really wanna, like, make, and I kinda like half made it, um-

49:18

Aaron Francis

Here we go

49:18

Ben Johnson

... I just didn't actually, like-

49:19

Aaron Francis

This is what I'm talking about. Give it to me

49:21

Ben Johnson

... uh, so, like, I did, like, a proof of concept of this, and it works.

49:24

Aaron Francis

Okay.

49:24

Ben Johnson

I just didn't actually build it out, and it kind of needs to be written in something more low level, like Rust or Zig or C or something like that.

49:30

Aaron Francis

Mm-hmm.

49:30

Ben Johnson

Um, is that I wanted to make basically a, like a, a driver for SQLite that will run... How do I explain this? So, like, it connects over SSH-

49:43

Aaron Francis

Okay

49:43

Ben Johnson

... and then communicates with the SQLite 3 binary on the other side-

49:47

Aaron Francis

Mm-hmm

49:48

Ben Johnson

... to perform queries. So you actually get... It actually works, like, as a, um this is such a crazy idea. It's essentially-

49:55

Aaron Francis

Yeah

49:55

Ben Johnson

... like a, a remote connection for SQLite.

49:58

Aaron Francis

This is client server SQLite.

49:59

Ben Johnson

It's cli- Yeah, 100% client server SQL. So I actually called it, I think it was, like, Sheqlite. It was like a mix of like SSH and SQLite. And, um, but the idea is not-

50:09

Aaron Francis

Oh.

50:09

Ben Johnson

I mean, you could use this in something, you know, production. Like, if you have, like... A lot of times if you have, like, workers, they might be in separate nodes.

50:14

Aaron Francis

Mm-hmm. Yeah, totally.

50:15

Ben Johnson

And might, might need to connect up-

50:16

Aaron Francis

Mm-hmm

50:16

Ben Johnson

... to the database. But it was mainly for, like... I find the biggest hurdle people have is for, like, GUIs. Like, they need to ha- Like, they wanna have a GUI for SQLite, and it's hard-

50:24

Aaron Francis

Mm-hmm

50:24

Ben Johnson

... to do that when you have a remote SQLite database.

50:26

Aaron Francis

It is. Yeah, that is definitely hard. Um-

50:29

Ben Johnson

Yeah

50:29

Aaron Francis

... this is insane. And you should absolutely do it.

50:34

Ben Johnson

Okay.

50:34

Aaron Francis

This is a great idea.

50:35

Ben Johnson

Yeah. Oh, I think-

50:36

Aaron Francis

So-

50:36

Ben Johnson

There's potential

50:37

Aaron Francis

... go, go tell Kurt, go tell whoever you need to tell that some random person on the internet said you need to do this.

50:42

Ben Johnson

You need to do that. Okay.

50:42

Aaron Francis

And you should, you should devote all your time-

50:44

Ben Johnson

Okay

50:44

Aaron Francis

... to this now-

50:44

Ben Johnson

Dedicate now.

50:45

Aaron Francis

... 'cause that sounds, that sounds amazing. This is, like, this is that kind of, like, um, this is that kind of crazy where you're like, "Yeah, this is-" "... this is crazy. I'm gonna do it." I like it. That sounds-

50:57

Ben Johnson

Yeah

50:57

Aaron Francis

... that sounds awesome. You did a-

50:58

Ben Johnson

Yeah

50:58

Aaron Francis

... proof of concept. How far did you get?

51:01

Ben Johnson

Uh, I got it working. I mean, where it actually... So it does some stuff. Um, I, I actually made a request to, to SQLite to see if they'd make a binary format.

51:09

Aaron Francis

Uh-huh.

51:09

Ben Johnson

'Cause the biggest issue is actually connecting, and then you have to, like, um... You know how it'll say, like, SQLite and then do, like, a, a greater than sign-

51:15

Aaron Francis

Mm-hmm

51:15

Ben Johnson

... for the, uh, the prompt?

51:18

Aaron Francis

Mm-hmm.

51:18

Ben Johnson

Like, essentially for results and, like, for parsing out errors and stuff like that.

51:21

Aaron Francis

Mm-hmm.

51:21

Ben Johnson

I need to, like, remove all the prompting it does, and it has some, like, weird prompting rules. So it's actually not that-

51:27

Aaron Francis

Interesting

51:27

Ben Johnson

... not that hard.

51:28

Aaron Francis

Yeah.

51:29

Ben Johnson

It was really more just a bunch of weird-

51:30

Aaron Francis

It got pretty far.

51:30

Ben Johnson

... little things. Uh, yeah. But it actually does work. It'll actually communicate over and run a query and get the results back and yeah. So anyway.

51:39

Aaron Francis

This- Every, every now and then, there's a guy like this in the Laravel ecosystem, of which I'm a part, where it's like, you're a mad scientist.

51:47

Ben Johnson

It's just-

51:47

Aaron Francis

Like, the stuff, the stuff that you do, you know, this guy, the stuff that he does with PHP, it's like nobody should ever do that, but this-

51:53

Ben Johnson

No

51:53

Aaron Francis

... is awesome.

51:54

Ben Johnson

Yeah.

51:54

Aaron Francis

And I feel like you're the, you're the SQLite mad scientist. This is crazy, and I love it.

51:58

Ben Johnson

I mean, there's some cool people doing cool work as well, like, uh, Alex Garcia does, um... He's done a bunch of extensions. I think he did, like, a vector with database within-

52:05

Aaron Francis

Okay

52:06

Ben Johnson

... uh, SQLite. Um, Philip O'Toole did RQLite, which is basically-

52:11

Aaron Francis

I saw that one, yeah

52:11

Ben Johnson

... SQLite over... Yeah. Um, we used to work together, actually. It's funny, 'cause-

52:14

Aaron Francis

Oh, cool

52:15

Ben Johnson

... we didn't work on SQLite at all at the same time, but we separately just did our own paths.

52:18

Aaron Francis

That's-

52:19

Ben Johnson

And we're like, "Oh, hey, we're both doing this stuff." Um, but yeah, he does it as, like, a distributed system-

52:24

Aaron Francis

Mm-hmm

52:24

Ben Johnson

... over Raft, and, um, which is a consensus protocol.

52:28

Aaron Francis

Mm-hmm.

52:28

Ben Johnson

So yeah, there's a lot of cool stuff out there. And then I know that, like, Turso-

52:30

Aaron Francis

And somebody just wrote, uh... Yeah, there's, of course, Turso, and then somebody just wrote, uh, a, like... I don't know if it's Wire compatible, but somebody just wrote a reda- a Redis clone in SQLite.

52:41

Ben Johnson

Oh, I did see that. That's, uh-

52:42

Aaron Francis

Yeah

52:43

Ben Johnson

... Red- Redca or something? No, Re-

52:44

Aaron Francis

Redca, I think.

52:45

Ben Johnson

Yeah.

52:45

Aaron Francis

Yeah.

52:45

Ben Johnson

Yeah, I saw that.

52:46

Aaron Francis

I think, I think that's right. Um-

52:48

Ben Johnson

Yeah

52:48

Aaron Francis

... and-

52:48

Ben Johnson

I think Cloudflare does D1, and it's-

52:50

Aaron Francis

Uh-huh

52:50

Ben Johnson

... like, it's, it's nice. I like communities that are still pretty small, and I feel like-

52:54

Aaron Francis

Mm-hmm

52:54

Ben Johnson

... it's still kind of early days, where, like, everyone's not super competitive. So, like-

52:57

Aaron Francis

Mm-hmm

52:57

Ben Johnson

... some people will borrow ideas from other people, and, like-

53:00

Aaron Francis

Mm-hmm

53:00

Ben Johnson

... I borrowed some stuff from Turso for their HTTP API, and-

53:03

Aaron Francis

Mm-hmm

53:04

Ben Johnson

... um, yeah, I think their local replicas use some of the stuff from LiteFS, and so that's fun.

53:09

Aaron Francis

Yeah, it's fun. I, I, I do like the proliferation of, like, good options in this space. And funny, funny enough, like, one of the, I feel like one of the drawbacks that everyone is always talking about, at least on Hacker News, is like, "SQLite doesn't have types." And you're like, "Well-"

53:26

Ben Johnson

Yeah.

53:27

Aaron Francis

"... it's a long story." But-

53:29

Ben Johnson

Yeah

53:29

Aaron Francis

... if you're using it for a key value store, that suddenly is a great benefit.

53:32

Ben Johnson

Yeah.

53:32

Aaron Francis

'Cause you can put anything as the-

53:34

Ben Johnson

Anything you want.

53:34

Aaron Francis

... key for the value.

53:36

Ben Johnson

Yeah.

53:36

Aaron Francis

And so it's kind of fun to see people, like, do a, you know, a Redis reimplementation because it's like, well, you can just throw anything in there, and we'll hang on to it for you.

53:44

Ben Johnson

Yeah. Yeah. I used to work a lot in, like, key value stores, and really it's like-

53:47

Aaron Francis

Mm-hmm

53:47

Ben Johnson

... it seems like it has lots of types compared to that.

53:49

Aaron Francis

Mm-hmm. Yeah.

53:50

Ben Johnson

So yeah.

53:51

Aaron Francis

Yeah. I guess that's true.

53:52

Ben Johnson

Yeah. It's kind of fun.

53:53

Aaron Francis

Um, okay. Well, I really appreciate you doing this. Like I, like I said at the beginning, I've read all your work. I'm very, um... I'm a big fan, and so this is a delight for me. Where can people, uh, keep up with the stuff that you're doing? Um, and I guess, where can they follow you?

54:10

Ben Johnson

Uh, sure. Yeah. Uh, I'm on Twitter. I haven't been as active lately, but, um, I have some other work I'm gonna be doing soon, so I'll probably be a bit more active there. Um, yeah, the Fly blog is usually a good spot for, for content as well. Um, or just open an issue on GitHub or, yeah, just reach out. I'll say hi.

54:28

Aaron Francis

Okay. Well, thank you so much. This has been wonderful.

54:31

Ben Johnson

Yeah. Thanks for having me. Appreciate it.

54:32

Aaron Francis

Yep. See ya.

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