How Durable Objects and D1 Work: A Deep Dive with Cloudflare’s Josh Howard
Josh Howard, Senior Engineering Manager at Cloudflare, joins me to explain how Durable Objects and D1 work under the hood—and why Cloudflare’s approach to stateful serverless infrastructure is so unique. We get into V8 isolates, replication models, routing strategies, and even upcoming support for containers.
Everything we said
Aaron Francis
Hello, my friends. Welcome back to Database School. We've, we've been having a lot of great episodes recently, and this is no exception. Today, I am joined by Josh Howard, senior engineering manager at Cloudflare, and I think we're gonna talk about a lot of things, databases included. But Josh, welcome to the show, and do you want to introduce yourself?
Josh Howard
Yeah. Absolutely. So my name's Josh Howard. I'm a senior engineering manager at Cloudflare. I'm responsible for the Durable Objects and D1 products at Cloudflare, and I've been working at the company for about 18 months now.
Aaron Francis
Oh, nice. Okay. So Josh, I'm gonna hit you with a question right up front, and you know, you'll have to forgive me. What exactly is a durable object? Can we, can we start there, or do we need to back up even further?
Josh Howard
Uh, no, I mean, I... It's a, it's a great place to start, right? Uh, the, the answer is probably gonna cause us to back up further immediately.
Aaron Francis
Perfect.
Josh Howard
But, um-
Aaron Francis
I love it
Josh Howard
... the, the durable objects is a primitive for building stateful serverless applications, right?
Aaron Francis
Okay. Let's slow down. It is a primitive for building stateful-
Josh Howard
Yes
Aaron Francis
... serverless-
Josh Howard
Yes
Aaron Francis
... applications. Okay. I like that. Those are important words. Stateful serverless applications. All right, keep going.
Josh Howard
Yeah. So I think, you know, to kind of unpack why that is important, you kind of have to think about like, you know, what other offerings are available at Cloudflare, right? And so the cloud's been around for a long time. Um, you know, the cloud kind of means that, you know, you're, you're running a server that somebody else is operating. Traditionally, serverless has meant that you're running a container that somebody else is operating.
Cloudflare has a different technique for obtaining a serverless application than any other company that I'm aware of. Um, they use a technology called V8 isolates to actually isolate-
Aaron Francis
Okay
Josh Howard
... customer code from, you know, customers' code from one another. And, um, that provides a much lighter weight serverless application than what any other cloud provider has. And so that's kind of the key differentiator of Cloudflare. And, um, you know, so that's, that's the serverless piece, but, uh, do you have a, a question there?
Aaron Francis
Yeah. So how... Help me understand, um, the difference between a V8 isolate and what I assume everybody else is doing, and is that Firecracker?
Josh Howard
Yeah. Firecracker is a newer VM technology that-
Aaron Francis
Okay
Josh Howard
... supports a lot of the other cloud providers. I think it came out of AWS, but I, I know of other places that are using it now.
Aaron Francis
Mm-hmm.
Josh Howard
Um, V8 isolates are actually the same things that isolate your Chrome tabs from one another, right?
Aaron Francis
Got it.
Josh Howard
Uh, it's, uh, predominantly thread level, or it, it's, the most important thing is it's thread level isolation. So, um, you don't have the overhead of doing a context switch between processes, um, whenever you're actually switching between executing different customers' code. You just have threads. And, um, each of those threads are given their own resources, um, and they're, they're effectively namespace, so they, they can't conflict with one another and can't ac- access state from each other.
So.
Aaron Francis
Okay. And this, uh, did this come out of, did this come out of Chrome, or was this something that, uh, I guess, I don't know who the working body for JavaScript is. Where did this V8 isolate thing come from?
Josh Howard
Yeah. I believe it came from Chrome. Like, this is-
Aaron Francis
Okay
Josh Howard
... uh, I think it, it was around like the early 2010s timeframe.
Aaron Francis
Oh, wow.
Josh Howard
So definitely before I was involved working on this. But, um, I believe it came out of Chrome. It's a bit-
Aaron Francis
Okay
Josh Howard
... of my time though.
Aaron Francis
Okay. Thank you. That's helpful. So that, that is a little bit of the serverless side of it. So there is, there has existed a model which is Firecracker. Uh, in the browser, there has existed a model V8 isolates, and y'all took V8 isolates and took them out of the browser and put them more at the server level, even though it is serverless.
Um-
Josh Howard
Exactly
Aaron Francis
... so what is the, what is the stateful part of stateful serverless, a primitive for building stateful serverless app, uh, applications. What's the stateful part?
Josh Howard
Yeah, exactly. So, um, and, and, you know, Workers is that, you know, stateless, uh, serverless offering that's on Cloudflare, right? And the, the thing that Durable Objects really provides is state. And what you need in order to have local state is you need to be able to consistently route requests to a single place globally. So you can imagine with Workers, they run everywhere.
Um, you can submit requests to Workers. Um, different clients on different sides of the world can submit the same request. They can go to different workers. There's no effective mechanism to access, you know, a, a database or that, that's local to either of them. And so what Durable Objects give you an API to do is allow that worker to forward a request to a durable object, and that forwarding of the request will go to a single place globally, and that durable object can access its local state.
You can do things that make sense to only do once or only do in one part of the world, like access local disk, access, you know, a database, access a local container. Um, Durable Objects is kind of the API for coordination between Workers, and then once you have that coordination, you can do all types of cool things, so.
Aaron Francis
So are durable objects, um, are they kind of like Workers plus plus? Are they built on top of Workers and add in some other things, or is it a fundamentally... You said Workers can route to a durable object. Can you explain that, uh, process a little bit more? 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.
Josh Howard
Yeah, exactly. So, um, they're essentially just all isolates. So Workers run in isolates. Durable Objects run in isolates. Workers differ from Durable Objects in the fact that we expose different APIs because, again, some things only make sense to do from one place, right?
Aaron Francis
Got it.
Josh Howard
So we're not going to expose like, you know, a SQLite interface to a worker directly because it doesn't really make sense if you can't return to the same place, you know, to access that same SQLite database, right?
Aaron Francis
Right
Josh Howard
So, um, that's kind of... They're essentially both isolates, but they have different capabilities. And, um, so that, that's, that's the way that they're different. The routing piece is actually super interesting. Um, so, you know, we can maybe double-click into how routing works.
Aaron Francis
Please.
Josh Howard
Um, but from a user perspective, what this looks like is you basically, you know, will get a durable object ID. You can think of it as like an instance ID or something like that. Durable objects are defined as a JavaScript class. And so you use the API to get an instance ID. You call get on that instance ID, and you get this thing called a stub, and that stub can be used to, you know, invoke methods on that remote object via RPC calls.
So-
Aaron Francis
Okay
Josh Howard
... that's what it looks like for somebody who's actually writing durable object code.
Aaron Francis
Mm-hmm.
Josh Howard
Um, but the way the routing works under the hood is actually really interesting because, you know, that ID is globally unique, and we can get into how we kind of make that globally unique if that's interesting.
Aaron Francis
Mm-hmm.
Josh Howard
But once you have that globally unique ID, you get a stub and the routing for that effectively means that we have to say, where does this ID belong to? What region of the world?
Aaron Francis
Mm.
Josh Howard
Go to that region of the world, um, you know, figure out what individual metal is or server is- ... running that ob- that object, and either if there is one, then route to that metal, otherwise go wake up the object, uh, and then assign it to some metal for it to, to run. So, um, there's a lot of details in there, but, um, you know, that, that's, that's the high level of like how you interact with these objects and how you handle routing.
Aaron Francis
Okay. We need to come back to the globally unique IDs because of course that's interesting. You said if that's interesting. Obviously that one is interesting.
Josh Howard
Yeah.
Aaron Francis
But here's my question first. So with the, with the durable object, um, the part that makes it durable is the state. Is that right? Is that where the naming kind of comes from?
Josh Howard
Yes.
Aaron Francis
That's why it's called durable? Okay.
Josh Howard
Yeah.
Aaron Francis
Um, so the part that makes it durable is the state, and you all decided that instead of letting, uh, workers from anywhere access state in a single point, you decided the durable object's compute is gonna be right next to the state. Is that a fair characterization?
Josh Howard
Yes. Yes.
Aaron Francis
Okay.
Josh Howard
Exactly.
Aaron Francis
So instead of saying, uh, yeah, it's durable because you have some attached storage that's never gonna go away and you can count on it, you said, yeah, it's durable because you have some storage but it's also right next to the compute. So what was the calculus in making that decision? I understand there must have been dozens of trade-offs, but what pushed y'all in that direction?
Josh Howard
Yeah, I mean, it, it is a really great question because, um, th- there's... I, I mean, there, there's a whole lot of things that having... I mean, I, I kind of framed it upfront as like a coordination point, right?
Aaron Francis
Mm-hmm.
Josh Howard
And coordination is kind of a, a core capability that, you know, having state in addition to coordination is, is, is useful. But like you can imagine stateless durable objects that still do really cool things, right? Um, a great example of this is like, uh, if you want to have, you know, a chat room or something like that, and even if messages are ephemeral, right?
You still need to be able to say, you know, open a connection to some chat room, right? And be able to, um, you know, send a message to that chat room and even if you're immediately broadcasting it out and not storing anything, right? Um, being able to coordinate, you know, is, is still a valid, you know, capability. So our perspective is that, you know, you need that coordination point and that unlocks a whole host of cool applications that just are not really approachable, you know, with a
standard three-tier web app, right?
Aaron Francis
Mm-hmm.
Josh Howard
Um, but once, you know, once you have that you can layer in state. Um, it's no longer, uh, uh, an expensive operation to go back and forth to your database, you know, hundreds, thousands of times if you have compute that is local to your database, right? Um, we can get a little bit more into like how we make that incredibly performant because it is, I mean, I think like, you know, we can actually do storage operations on the order of microseconds which is like pretty awesome.
Um, so yeah, I mean like, you know, we, we can go however you want to go here but, uh, you know, there, there's a bit to, to unpack.
Aaron Francis
So, uh, you gotta help me understand a stateless durable object. What, what does that, what does that part mean? There are so many, there are so many things about durable object- objects that I've yet to wrap my head around. All I see is, uh, Sunil posting about them all the time and all the amazing things that they can do and I'm like, I gotta know what these things do.
So stateless durable object, t- tell me more about that. What does that mean?
Josh Howard
Yeah, I mean it's, it's just a, a... You can imagine writing an application, you know, referencing it where a worker references a durable object and that durable object never touches the storage API. Um, maybe that means that, you know, you want to, um, like, you know, the lifetime of a durable object is by default 10 seconds, right?
Aaron Francis
Okay.
Josh Howard
You could imagine that you have all the workers in the world, you wanna make sure that those workers are not individually like bombarding some upstream resource.
Aaron Francis
Mm-hmm.
Josh Howard
You wanna do some sort of like batching of operations. So you could say like all workers have this like, you know, reference to a batcher durable object, right? And every, you know, 10 seconds before it goes out of memory it's gonna say, "Take all those requests I got, dedupe them, do some operations to like, you know, streamline things and then send them to this upstream resource." That, you know, durable object is never going to touch storage in this case.
You know, you could make it touch storage if you wanted to do something else-
Aaron Francis
Sure
Josh Howard
... but like it doesn't have to, right? Um, there are simpler things that you can do where, you know, you don't ever have to touch storage and it can still do useful things, right? So, you know, maybe you want to batch on a longer timeframe, you don't want to rely on that in-memory state and then you save all these requests to local storage and then you, you wake the durable object up at some point in the future, you know, days, weeks, years later I guess and then you-
Aaron Francis
Mm-hmm
Josh Howard
... you know, send all those requests upstream. But you don't necessarily have to touch storage to make use of durable objects.
Aaron Francis
That makes sense. So, uh, in, in a stateless durable object situation, you're basically just keeping all that stuff in memory, and you have one unique point that everyone else can talk to that can coordinate everything.
Josh Howard
Yeah, exactly.
Aaron Francis
Okay.
Josh Howard
You, you can think of it as, like, connection pooling. Like, that, that's the-
Aaron Francis
Uh-huh
Josh Howard
... the common example we get, um, for, for stateless applications.
Aaron Francis
And when these things, when these things go to sleep, do they wake up in the exact same state, uh, that they went to sleep in?
Josh Howard
Yeah, that's a good question. So, so they do not wake up by default in the same state that they fell asleep in, right?
Aaron Francis
Okay.
Josh Howard
Um, whenever they wake up, the, uh, constructor of the object will actually run, right? And so you-
Aaron Francis
Got it
Josh Howard
... can have that constructor reconstruct whatever state you want, right?
Aaron Francis
Okay.
Josh Howard
But by default, you know, it's just you- whenever they, they wake up, they are assigned to an isolate. Um, you know, you can, you know, pre-populate from storage whatever in-memory state you want.
Aaron Francis
Mm.
Josh Howard
Um, but we don't like, uh, it's, it's actually, like, a, a common misconception. We've had several people, like, ask like, "Oh, will you repopulate, like, variables-
Aaron Francis
Mm-hmm
Josh Howard
... in memory?" And it's-
Aaron Francis
Right, yeah
Josh Howard
... we're, we're not, we're not, like, uh, trying to introspect on your code and, like, interpret it differently.
Aaron Francis
Right.
Josh Howard
Like, it, it's just JavaScript. It works the same way you would expect JavaScript to work, right? It's just that, you know, whenever we wake that up, we give you a hook, which is a constructor, to actually-
Aaron Francis
Mm
Josh Howard
... go and reconstruct whatever state you want.
Aaron Francis
Okay. Well, I'm glad, I'm glad I had the same misconception as the people. That means I'm still speaking for the people. That's a good thing.
Josh Howard
Cool.
Aaron Francis
So when it goes to sleep-
Josh Howard
Yeah
Aaron Francis
... does it have a hook for you can serialize all your important state into some storage, and then you can use it again in the constructor?
Josh Howard
Yeah, so that's, that's a good question. Uh, we do not have a destructor hook, right?
Aaron Francis
Okay.
Josh Howard
And the reason being is that it's very hard to guarantee in all cases that a destructor will run.
Aaron Francis
Hmm.
Josh Howard
Um, you know, you have things like runtime crashes.
Aaron Francis
Mm-hmm.
Josh Howard
Customer code can crash. Um, you know, it's just we cannot guarantee, uh, invariably that that destructor will always run, right? And so for that reason, we've avoided adding a, you know, destructor hook. Even if we can have, you know, if, if even if we think we have 12 nines of reliability for that destructor hook running, there's always gonna be some edge case where it didn't-
Aaron Francis
Yeah
Josh Howard
... run, right? And so we're very, you know, conservative on, like, the tools that we give our customers, especially with DO, because we wanna make sure that people can write code that they can reason about, uh, invariably. And so, um, you know, there are ways to write applications, though, to where, like, you know, for every in-memory state, you can do a write to local storage. As I mentioned, writes to storage are incredibly fast, right?
So, um, I would honestly, uh, a- avoid, uh, keeping things in memory and not syncing to local storage unless it becomes cost-prohibitive, like, which it can in some, some cases.
Aaron Francis
Okay, that makes sense. Uh, and I agree with you on the if we can't do it perfectly, let's not do it, 'cause somebody's gonna rely on it, and it's gonna go sideways, and y'all are gonna get y'all are gonna get in trouble for it.
Josh Howard
Th- there's some metric of like, uh, and I, I haven't... This isn't, like, fully, uh, well-defined, but, like, there's some metric of, like, preventing regrettable debugging experience.
Aaron Francis
Mm.
Josh Howard
And, and I think that's the actual thing that you wanna optimize as a developer platform. It's, you know, there's, there's a lot of things you can add to increase development velocity and things like that, but it's like the thing that just is going to completely railroad your day is whenever there's some concurrency bug that, you know-
Aaron Francis
Mm
Josh Howard
... is confusing and, like, you know, you spend 12 hours fixing this one thing because, you know, it, it just doesn't work the way you expect. I think those experiences are the things that you really want to prevent. Um-
Aaron Francis
Yeah.
Josh Howard
Yeah.
Aaron Francis
And, and doubly so when it's outside of my control as the developer. When the platform doesn't call my destructor, then I'm, I'm totally in the dark, and that's really frustrating.
Josh Howard
Exactly. Yeah.
Aaron Francis
So you said, uh, you said there for a second, uh, you would recommend writing to local storage. So local storage is both, uh, a term of art and a just generic descriptor. So in what, what way are you using it? Are you saying storage that is local? Because local storage is, like, a, a browser thing, so can you differentiate-
Josh Howard
Oh, yeah, yeah
Aaron Francis
... this for me?
Josh Howard
Yeah. Yeah, so in this case, I'm talking about the, the Durable Object storage, right?
Aaron Francis
Okay.
Josh Howard
So, um, we have two APIs for interacting with Durable Object storage.
Aaron Francis
Mm.
Josh Howard
And that's either through a KV API or a SQLite API, right? And so, you know, historically, we only had a KV API. We released a SQLite API last fall. Um, and, um, but that's, you know, you, you can interact with local storage. It's persistent. Uh, it's durable. It's replicated. Uh, we can get into how we do that efficiently, but, um, you know, that's, that's the, you know, way to actually make sure that, you know, whatever in-memory state you have, as long as you're flushing that to storage,
it's gonna be durable, and it's going to be available, you know, upon, like, after the Durable Object sleeps, and then you don't have to have complicated logic in your constructor.
Aaron Francis
Mm-hmm. So, uh, KV and, uh, D1 are both available as standalone offerings. Is that correct?
Josh Howard
Um, so Workers KV and Workers D1 are different products than Durable Objects. Um-
Aaron Francis
Okay
Josh Howard
... naming is hard. Um-
Aaron Francis
I'm glad you're, I'm glad you're laughing 'cause I'm like, wait, what? Okay.
Josh Howard
Yeah, yeah.
Aaron Francis
That makes me feel better.
Josh Howard
No, no, great, great question because we get this all the time, right? Like, naming is hard. Um, so, so Durable Objects have a KV and SQLite interface to their local storage. We have a separate product called Workers KV and D1-
Aaron Francis
Mm
Josh Howard
... which give a worker, uh, access to a distributed KV store or-
Aaron Francis
Mm-hmm
Josh Howard
... a, uh, SQLite database. So-
Aaron Francis
Okay
Josh Howard
... both of those, like, I would say both of those things predate Durable Objects in their own ways. I mean, it's, it's ... The actual sequencing here is that Workers KV came out in, I believe, 2019.
Aaron Francis
Mm.
Josh Howard
Um, D1 came out, or Durable Objects came out in '21. D1, which was the first SQLite backed product that we had, came out-
Aaron Francis
Mm-hmm
Josh Howard
... shortly after that, and then we brought SQLite storage to durable objects, um, you know, after, after D1. So, uh-
Aaron Francis
Okay
Josh Howard
... there's been a little bit of a confusing history. Um, you know, it, it is hard to parse what product you should use when.
Aaron Francis
Okay. Okay, that's helpful. So, um, when we're talking about durable objects and we're talking about SQLite storage, or I guess you called it as a SQL interface and a KV interface-
Josh Howard
Mm-hmm
Aaron Francis
... those are fundamentally local to the specific durable object, and therefore not reachable from, uh, workers KV. Like, they're completely, they're completely-
Josh Howard
Yeah
Aaron Francis
... separated.
Josh Howard
Completely separate. Yeah.
Aaron Francis
Okay. Perfect.
Josh Howard
Yeah.
Aaron Francis
Okay. That makes sense. So then your two storage options over in durable objects land are, um, a SQLite backed, I think you called it SQL, SQL interface, and a KV store.
Josh Howard
Mm-hmm.
Aaron Francis
Is that correct? Those are your two options?
Josh Howard
Yeah, so those are the two like APIs that we offer up. It's actually-
Aaron Francis
Mm-hmm
Josh Howard
... all of it's SQLite backed, right? So our, our KV-
Aaron Francis
Hmm
Josh Howard
... our KV interface, you can actually go and show tables on the, the SQLite instance that is backed or is backing the DO.
Aaron Francis
Mm-hmm.
Josh Howard
And you'll see a table that's like _CF_KV.
Aaron Francis
Mm-hmm.
Josh Howard
Um, that, that's the KV storage, right? So it, it's just-
Aaron Francis
Ah, SQLite. Just use it for everything. I love that.
Josh Howard
Well, it's, you know, we, we have this problem because, you know, we had a, a, a previous storage back end that was only KV-based, and it had a, a bunch of problems, right? And so we've essentially shifted to using this new back end, um, and encour- we're encouraging all new customers to use the SQLite back end. But in order to make that transition easier, we wanted to have API compatibility, right?
Aaron Francis
Hmm.
Josh Howard
So you can actually just deploy the same code using the SQLite back end, and it will run just fine. Um, it, it's backward compatible. Um, we just, you know, needed to maintain that interface, um, because, you know, believe it or not, some people like key value interfaces more than SQL. It's shocking, but-
Aaron Francis
The nerve. The nerve on these people. Okay.
Josh Howard
Yeah.
Aaron Francis
Um, how do you get these writes to be, or this communication, I guess, reads and writes, to be so lightning fast between this, this local storage for your durable objects?
Josh Howard
Um, yeah. So I, I think like one of, one of the things that's interesting is like people assume that, you know, writes need to be, you know, asynchronous because they're necessarily slow. The operating s- op- operating systems are great. They do a lot of stuff for us. Um, so if you're doing, you know, writes to storage, uh, most likely that write is going to be cache in memory, and it's going to, you know, work on the order of microseconds, right?
Like, so, so if I'm writing to disk without flushing, that write is going to succeed in, you know, in, in microseconds. Um, the issue becomes like it's not flush to disk, it's not confirmed durable, right? And so what we have to do there is we essentially replicate that write out to a set of followers, uh, through this service that we call, uh, the storage relay service.
So, um, whenever a durable object writes, and again, this is nothing that anybody, you know, has to worry about, but like-
Aaron Francis
Mm-hmm
Josh Howard
... it's fun.
Aaron Francis
But it's super interesting.
Josh Howard
Yeah, exactly, right? Like, y- you know, if you, if you, you know, i- if you, you know, don't care how this works and you just wanna use it, you don't have to listen to this, but like this is the cool part in my opinion. So, um, you know, basically we have this storage relay service where we have on the same metal that a durable object is running, we have this leader, which is going to be looking for writes to SQLite.
Aaron Francis
Okay.
Josh Howard
And whenever a write comes in, that leader is going to say, um, "I'm going to, you know, take that write. I'm gonna replicate it to followers." Okay? And then it will be confirmed durable whenever the followers accept that write. Okay? Um, and then so the application can go on and write, you know, do whatever it needs to do, and then, um, once all of those writes are confirmed durable, then it will be allowed to return, right?
We call this feature output gates. So it, it, it's kind of interesting. We get a lot of questions about it, b- but we don't have to wait for every individual write to be confirmed for the durable object to proceed.
Aaron Francis
Right.
Josh Howard
This is another benefit of having, you know, compute tied to storage. We just have to make sure that all writes are confirmed durable by the time the durable object has some side effect which is observable to the outside world. So you can think about that maybe from the perspective of if you're a worker requesting to that DO, everything is synchronously replicated.
You don't get a response back from that DO until everything has been confirmed durable.
Aaron Francis
Hmm.
Josh Howard
The DO itself can go ahead and optimistically write and do other things as long as it's not communicating externally, and that- ... replication from the DO's perspective is purely asynchronous, and you never have any side effects because we control all input and output to that durable object.
And so you can do, you can do things to where you have like, literally, you know, microsecond level writes and, you know, you can do other computation around that. As long as you're not causing side effects to the outside world, um, you know, there, there's no harm in going ahead and optimistically doing things without, without, uh, having those writes confirmed durable.
Aaron Francis
All right. Here we go. I'm gonna say it back.
Josh Howard
Okay.
Aaron Francis
And you're gonna be gentle with me. Okay? Um, all right. So what you're telling me is that a request can come in from the outside world, we'll say it's from workers, into a durable object.
Josh Howard
Mm-hmm.
Aaron Francis
And that crosses some sort of boundary, right? In-
Josh Howard
Yes
Aaron Francis
... we're inside the durable object now. Now, when, when we're inside the durable object, we can bounce around as much as we want, doing as many writes as we want, without waiting for confirmation that all writes have been replicated. But the moment that we try to go back across that boundary, back to, uh, what is the outside world from the perspective of the durable object, once we try to cross back out, then we're halted at the door until
all of that, all of those writes have been replicated and proved durable.
Josh Howard
Yes, exactly.
Aaron Francis
All right.
Josh Howard
Yeah.
Aaron Francis
Just a straight yes. That was great.
Josh Howard
It was easy.
Aaron Francis
No notes.
Josh Howard
It was-
Aaron Francis
No notes.
Josh Howard
The, the only caveat I would-
Aaron Francis
Ah, there's a note.
Josh Howard
It's, that was-
Aaron Francis
That was a note.
Josh Howard
No, no, no. Well, uh, uh, it doesn't really, uh, it, it's, uh, I did not cover this case, but, like, it's not just returning back to the worker, it's any side effect. So we will actually-
Aaron Francis
Any side effect
Josh Howard
... we will actually, like let's say that you, uh, read some data, write some data, um, and then you want to make a fetch request from that durable object. We'll actually gate that fetch request until the write is confirmed durable, right? Because it-
Aaron Francis
Got it
Josh Howard
... it's no side effects are allowed, right?
Aaron Francis
Got it. Okay. And what is the mechanism by which you're observing SQLite listening for those, listening for those writes? Is it some sort of virtual file system? Is it some sort of, you know, WAL thing? Like, what are y'all doing down there?
Josh Howard
Yeah. So, uh, we do hook into, um, we, we do hook into the WAL at, at the VFS layer, right?
Aaron Francis
Okay.
Josh Howard
So we're, we're replicating the WAL, um, and then, uh, we, we hook into SQLite at the VFS layer, which is, I guess, for, for your listeners, like it's the original interface for interacting with different operating systems, which has been, uh, used for far more than that, I guess. Uh-
Aaron Francis
Yeah
Josh Howard
It's, yeah.
Aaron Francis
It's like, it's like one of the only ways into SQLite, and so everybody takes over and does some wonky stuff down there.
Josh Howard
Yeah.
Aaron Francis
Okay.
Josh Howard
Yep, exactly. It's, it's one of the few ways that you can, um, you know, contribute, uh, or make, make meaningful changes to SQLite.
Aaron Francis
Mm-hmm.
Josh Howard
Yeah.
Aaron Francis
Unless you wanna fundamentally rewrite the whole thing, which people are doing, so this feels-
Josh Howard
They're doing, yeah
Aaron Francis
... this feels a lot easier to me. Um-
Josh Howard
Yep
Aaron Francis
... okay. So at that point, after, um, you know, the, the request comes in, bounces around, and then it's confirmed durable, how, like, what is the, um, what's the durability look like? So you're on a single, you're on a single machine with your compute and your storage, and then where are we replicating that out to?
Josh Howard
Mm-hmm. Yep. Um, so we do, uh, five-way replication to the five nearest data centers, uh, for any, every single durable object. And so, you know, if you're in, I, I'm in Austin, right? So we would just pick, you know, the five closest data centers, which are probably like Dallas, Houston, probably Denver, uh, and, and some other cities.
Um, you know, we'd pick the five closest data centers and replicate across those. And so that is for, you know, the, the standard like leader-follower loop. There's a second path here which we have for long-term durability, which is basically that, you know, all of these things are stored at, you know, Cloudflare's edge, right?
Aaron Francis
Mm-hmm.
Josh Howard
Um, the edge is just more expensive than large hyperscaler data centers, right? So I think like our cost for storing things, though they are incredibly cheap, um, it's, it's still like an order of magnitude higher than like blob storage, right? So, um, eventually, like the followers, uh, you know, they don't retain that data forever. Either the followers or the leader will eventually upload that data to cold storage for, for safekeeping.
Um, so-
Aaron Francis
Mm
Josh Howard
... that's, that's eventually where it ends up for durability. But, you know, we don't rely on, uh, cold storage confirming that for us to consider it durable. That, that's, the followers are actually ensuring that it's durable.
Aaron Francis
That makes sense. So you write it to the primary, then five other places get it.
Josh Howard
Mm-hmm.
Aaron Francis
And then does that, is that cold storage, uh, eventually R2?
Josh Howard
Um, ish. I would love for it to be R2. It, it would be great- ... if it could be R2. Uh, I hope that it is R2 one day. We have this problem today because R2 depends on durable objects.
Aaron Francis
Yikes.
Josh Howard
So, uh, yeah. Like, we, we can't depend on-
Aaron Francis
No
Josh Howard
... R2 for this because R2 depends on us. So we actually, we actually use Google Cloud Storage.
Aaron Francis
Okay.
Josh Howard
Um, but, you know, the reason for that is just to avoid the circular dependency. Um, there is a plan, you know, in the limit to have R2, uh, stop depending on durable objects-
Aaron Francis
Mm-hmm
Josh Howard
... so we can, you know, actually use R2 instead of, instead of GCS. Um, but for the time being, yeah, GCS is what we depend on for ultimate durability.
Aaron Francis
Yeah, that makes sense.
Josh Howard
Yeah.
Aaron Francis
That's like the time ... I, I forget what happened at Facebook, but Facebook crashed so hard that they couldn't badge in 'cause everything else required on everything else or depended on everything else, and it was like, "Oh, shoot, didn't really see this one coming."
Josh Howard
Yeah. Yeah.
Aaron Francis
So yeah, that makes sense to me.
Josh Howard
Yeah.
Aaron Francis
Um, okay. So what are, uh, what are the trade-offs of having durable objects tied to a single ... Do you call them locations or, or regions or data centers? What, what do y'all call them?
Josh Howard
Um, it, we call them colos internally, but, like data centers-
Aaron Francis
Oh, wow
Josh Howard
... is, is the-
Aaron Francis
Data centers.
Josh Howard
Yeah. Data center is the-
Aaron Francis
Since I'm external, I'll call it a data center.
Josh Howard
Yeah.
Aaron Francis
So y'all, y'all have this big, you know, um, most of your products are, you know, region Earth, and it's like, oh, that's kinda cool.
Josh Howard
Yeah.
Aaron Francis
And then durable objects are tied to a specific data center. So one, what are the trade-offs? And then two, what are, uh, what are the ways that people can reason about choosing the right one, given that they may have customers everywhere?
Josh Howard
Yeah. So, um, this is, uh, like durable objects w- would like to, uh, have our customers just think everything is region Earth.
Aaron Francis
Mm-hmm.
Josh Howard
Like, we, we don't want people to have to worry about individual data centers, and so we will try to make that as much of a reality as we can, um, you know, with varying degrees of success, right? So, um, durable objects are tied to a particular colo at any point in time. We can move durable objects Right. Um-
Aaron Francis
Oh
Josh Howard
... we can do that in the case of, like, colos going offline. That happens all the time, right? And so what we generally have is that durable objects belong to a certain region, and then if any colo within that region is experiencing difficulties, then we, it will automatically be adopted from another, from another-
Aaron Francis
Hmm
Josh Howard
... colo in the region, and users don't have to worry about that. It's just, you know-
Aaron Francis
That's good
Josh Howard
... they're, they're inherently regional, and they can bounce around within that region to, to deal with, you know, issues or maintenance or whatever, right? Um-
Aaron Francis
And sorry, when we, when we build a, when we declare a durable object, what are we declaring? Region level? Surely not colo level from the customer's point of view.
Josh Howard
You don't have to declare anything. By default-
Aaron Francis
Oof. Okay
Josh Howard
... it will be placed near where it is first requested, right?
Aaron Francis
Huh. Interesting.
Josh Howard
If that's not a good, if, if that's not good enough for you, right, uh, a lot of people will pre-create durable objects for certain reasons. I, I-
Aaron Francis
Okay
Josh Howard
... like, you know, maybe... I actually don't have a great example of why that, why you'd need to do that. But it, it has got-
Aaron Francis
But people are doing it.
Josh Howard
Pe- people have done it, right? Um, I, I think mostly, like, just because they thought they had to. But-
Aaron Francis
Yeah
Josh Howard
... uh, you know, it, you don't have to, but, but people do it. And so we do support, like, region hints to where you can say, like-
Aaron Francis
Got it
Josh Howard
... "I think this durable object is going to be best placed, you know, in, in APAC or in North America or, you know, wherever." Um, but so you, you can pre-create them and place them around the world, you know, however you like, but you don't have to, right? Um, and so, you know, what we want to actually focus on in the future is, like, improving our placement algorithms because-
Aaron Francis
Mm
Josh Howard
... um, you know, it, it's, like, right now, like, literally we place them where the first requester was or as close to that as we can get, and remarkably few people have complained about that. Like, that was my, like-
Aaron Francis
That's pretty reasonable.
Josh Howard
I mean, that was my first thing. Like, whenever I came in, it was like, "So how does this placement stuff work?" And somebody told me that, I was like, "No way. Like, we've gotta have like a million complaints about that. Like, that, like people have to be berating us on that." And, um, like it's maybe come up once or twice in like a year now.
Aaron Francis
Wow.
Josh Howard
Like, y- yeah. Like, and I don't know if it's, like, people just don't know to ask or what.
Aaron Francis
Mm.
Josh Howard
But like, you know, it, it is genuinely, like, just it seems good enough for everybody, surprisingly. So, you know.
Aaron Francis
Mm-hmm.
Josh Howard
Anyway, would love to improve that in the future, but, you know, uh, we'll wait until people, uh, complain. I'm hoping that, you know, please complain. Um-
Aaron Francis
Yeah. You want it changed.
Josh Howard
Yeah. I, I want, I want to go solve this problem, right? Um, so but yeah. So, so generally, like, you don't have to do anything. Um, placement should work, you know, for, for most use cases or has historically worked for most use cases. And um, you know, there are other things you can do. You can also specify jurisdictions if there are compliance reasons why-
Aaron Francis
Mm
Josh Howard
... you can't locate durable objects some places. Um, you can say that, like, "I need a durable object which stays, you know, within, you know, uh, the US for, like, FedRAMP or, like, within the EU for, you know, other compliance reasons." But, um, you know, so, so there are some controls, but, um, yeah, it, it's generally handled by default.
Aaron Francis
Um, can we as customers, can we move them? Is there an affordance for that? Can we say, "Whoops, it's in DFW, I actually wanna move it to, you know, Europe or something"?
Josh Howard
Um, there's not, like, a straightforward mechanism for that. Um, you know, you can effectively just, like, delete it, move the state somewhere else, create a new durable object in those re- regions, and move them. They're meant to be implicitly declared. Um, so-
Aaron Francis
Mm
Josh Howard
... so, like, you, you just, you know, by referencing a durable object and doing some operations and storing some state there, it is created. Um, as long as you delete your stored data, then it's effectively cleaned up for you, right? So you don't have to, like, ever delete durable objects, but, you know, if you want to make sure you're not charged for the, the bytes stored, then yeah, you, you will need to actually, like, you know, delete all your data in, in those durable objects.
So but once, once they're deleted, you can, like, you know, you can copy that data elsewhere. You can, you know, do whatever you want. It's just code at that point.
Aaron Francis
So is it that the, uh, extremely sophisticated algorithm is so good, or is it that everybody that's talking to durable objects are mostly talking over Cloudflare's presumably fat pipes, and so it's fast enough that nobody ever really complains that, like, the durable object is potentially far away?
Josh Howard
I think the people that are most successful actually have so many durable objects that the placement algorithm works for them, right?
Aaron Francis
I see.
Josh Howard
So if you, if you have your application which is supported by many durable objects, and so, like, we, we actually encourage people to shard their applications to where, like, every single user gets their own durable object, right? That means that user, y- you know, like, you know, Aaron's durable object or the, the durable object that's backing your user data in an application you use, it will be located always, you know, near where you are, right?
Aaron Francis
Then that algorithm is absolutely perfect. I hate to tell you that there's no improving on that algorithm then. If e- every user gets their own, it's gonna be close to them.
Josh Howard
Ex- exactly. And so I think that's kind of why it's not been a problem.
Aaron Francis
Mm-hmm.
Josh Howard
And that also solves the issues with scaling, right? Because durable-
Aaron Francis
Sure
Josh Howard
... objects are inherently a single, single thing, right? It's not like workers where, you know, if you overload a worker on a single metal, you can just, like, run, you know, run-
Aaron Francis
Mm-hmm
Josh Howard
... the same isolate somewhere else and so on and so on. I mean, like, you, you literally cannot overload Cloudflare workers. You can overload a durable object, like a single durable object. And you know, so by actually sharding your application, it makes the placement algorithm work quite well. It also makes sure that you're not gonna overload a single durable object.
Aaron Francis
What are people... Like, what are the, what are the common use cases that you're seeing people use durable objects for? Specifically, if you can, people doing a durable object per user, which sounds kinda crazy and kinda awesome.
Josh Howard
Yeah. Um, so there's, th- there are a lot of cases. I think there's a few different verticals that we're targeting, right? So I think agents has been, like, the one that-
Aaron Francis
Mm
Josh Howard
... we've been most vocal on Twitter about Um, where every single agent is an individual durable object. If you're using the agents framework, right?
Aaron Francis
Mm-hmm.
Josh Howard
Um, we've made the joke internally that, like, importing a- agents from, like, import agents is the same as, like, you know, import durable objects as agents. Um-
Aaron Francis
Hmm
Josh Howard
... so, uh, that's one use case.
Aaron Francis
I bet that one kills internally, doesn't it?
Josh Howard
Oh, what do you mean? Like-
Aaron Francis
I bet that joke, I bet that people just love that joke internally.
Josh Howard
I mean, maybe. Yeah. I, it like, it is kind of, we're very aware that, like, durable objects are abstract, and people-
Aaron Francis
Uh-huh
Josh Howard
... do love frameworks that, like, solve the exact problem they wanna solve, right? Um, so there is definitely a place for both. Um, and so, you know, durable objects is, like, meant to provide a, you know, abstract framework for building things, but, um, you know, special purpose, you know, libraries are always, always helpful.
Aaron Francis
Mm-hmm.
Josh Howard
So, um, you know, that's one. Multiplayer games is another. So, you know-
Aaron Francis
Hmm
Josh Howard
... if you're trying to, uh, coordinate between multiple players on different sides of the world, a durable object can be created in between those two players and, you know, can, you know, kind of, you know, manage game state and things like that.
Aaron Francis
Hmm.
Josh Howard
Um, we have, uh, chat rooms, uh, real-time applications. Uh, you know, w- any, any application that's built using WebSockets is probably using durable objects as a back end. Um, so built with WebSockets on Cloudflare, right? Sure.
Aaron Francis
Mm-hmm.
Josh Howard
You can use WebSockets elsewhere, you know. It just, um, but yeah. A, a great example is, like, we ha- we have a chat app which we published forever ago, which is, is, you know, pretty ful- fully fledged and, you know, works end to end. Um, we have a lot of people kind of experimenting with, like, local-first development and durable objects. That's, like, another-
Aaron Francis
Hmm
Josh Howard
... area that's, like, kind of, um, materializing. But, um, generally, like, you know, real-time multiplayer types of applications, um, those are the things that are really unique for durable objects. It's, it is the case that you can just, like, you know, build your, you know, standard three-tier web app with durable objects as a back end, and you can have more isolation, you can have lower latency.
It's gonna make it a better application. Um, but I think the things that you couldn't build, you know, with a basic three-tier web app setup are the things that are more interesting, right? It's like, you know, it, sure, you know, if Postgres works, just use Postgres. Like, you don't-
Aaron Francis
Mm-hmm
Josh Howard
... necessarily have to use durable objects for everything. But, like, you know, if you're building a, you know, document editing, uh, application and you're having to have every keystroke be an insert into Postgres, then, like, you know, your, your database is gonna fall over.
Aaron Francis
Mm-hmm.
Josh Howard
You can't build that type of application with just, you know, your basic three-tier web app setup.
Aaron Francis
Yeah. The example you gave about the, um, chat rooms was helpful, but I think the multiplayer game is, is more, that made it click for me a little bit more. So you've got a durable object per, like, a ongoing game, like per match, I guess.
Josh Howard
Yep.
Aaron Francis
And so-
Josh Howard
Exactly
Aaron Francis
... that's the place where the users, maybe two or more, are connecting, and that's the place where all the, the state is living. And then for each ongoing match or existing match, you've got a separate durable object.
Josh Howard
Mm-hmm.
Aaron Francis
And that is, like, you know, from the point of view of the durable object, it's, it's not a lot of compute. It's, like, two people doing a thing.
Josh Howard
Yeah.
Aaron Francis
But you could have thousands of them.
Josh Howard
Yeah.
Aaron Francis
And at that level, well, that's pretty, that's, that's a lot. But again, from the single point of view, it's barely anything.
Josh Howard
Yeah.
Aaron Francis
So that, that part makes a lot of sense.
Josh Howard
I mean, durable objects are like a row in our database, right? Like that-
Aaron Francis
Mm.
Josh Howard
That's, that's, like, people do not understand how cheap they are for us. And so, like, whenever we say, like, you can create millions-
Aaron Francis
Yeah, gosh
Josh Howard
... like, you can actually create millions. It's fine. Like, i- it's like the, the ramp-up is, like, you know, you can't create millions a second. Like, we will tell you to back off.
Aaron Francis
Mm-hmm.
Josh Howard
Right? But, like, you know, you can try and create them as fast as you want, and like, you know, we'll, we'll tell you if, like, you're, you're creating them too fast. But, like, you know, scaling up thousands per second is not a problem.
Aaron Francis
Okay. So you've got a bunch of customers. You, you being Cloudflare. You've got a bunch of customers. They're all creating thousands of durable objects a second, and you are, with 100% confidence, generating IDs that don't collide.
Josh Howard
We are, yes.
Aaron Francis
Tell me, what are we using to do that?
Josh Howard
Well, so you can think about, like, th- there's nothing, like, particularly creative here, right? Like, if you just assume that, like, the IDs are, you know, prefixed with the client, like, you know, the, the, the client, you know, uh, data center and, and, you know, server number, right?
Aaron Francis
Mm-hmm.
Josh Howard
Then, you know, and like, you know, you can have, like, the isolate ID or whatever, right? Like, y- you can ensure that the, the isolate which is requesting this and saying, "Give me a new unique ID," is, you know, never going to overlap with another one, right? Um, so that's, that's the simple case of like, you know, generating unique numbers because you've just, like, prefixed them in such a way that they, they don't collide is, like, that's the straightforward.
Um, the harder part is whenever you're trying to generate a named durable object. So, like-
Aaron Francis
Hmm
Josh Howard
... this is the one that, like, makes more sense of, like, you know, you're, you're not gonna like, you know, name a variable in your code like ABC123, you know?
Aaron Francis
Mm-hmm.
Josh Howard
Some long hex string, right? You're gonna have, like, a durable object named Foo or whatever, right?
Aaron Francis
Right.
Josh Howard
And so the way that that works is we actually have to go to a singular region in the world. And without loss of generality, like, you know, we, we've basically just picked North America because-
Aaron Francis
Mm-hmm
Josh Howard
... latencies are gonna be better for people in North America. You know, the alternative is, like, randomly picking a region and latency, latencies are, you know, randomly bad, right?
Aaron Francis
Mm-hmm.
Josh Howard
Um, another feature I'd love to build is actually making that configurable, 'cause, like, you can do that and it would work. But, um, again, nobody's requested this. Um- You know, a- anyway, um, so but, but we pick a region that we use for, for, uh, coordination and, uh, we, you know, we'll submit that request to that region.
And then the requester which wins, right? So imagine you've got two, you know, clients on either side of the world, but you're trying to create a durable object named Foo. Um, the client that wins is essentially going to have, uh, we call this, this strategy relocate on create. It's going to insert a record into our database and say, "This durable object is created.
It has, you know, XYZ ID, and it's being relocated to live next to, you know, the client that won," right? And so the, uh, the second requester that loses is going to, instead of creating that new durable object, it's just going to be told, "It's actually moved over here. Go make that request." And then this is actually scalable because subsequent requests for newly named objects or frequently requested objects, those ...
the locations get cached, right? So, um, if you have a durable object which is requested all over the world, um, you know, we will have in local cache in every, you know, client, uh, or every like, you know, every, like, edge data center in Cloudflare's network is gonna have a cache relocation record that that durable object lives here, so go request it there.
Aaron Francis
Okay. So two requests are in flight to create a durable object named Foo. Obviously, one wins, and the North America region that's doing the coordination says, "Okay. Foo is now in," we'll say, "DFW."
Josh Howard
Mm-hmm.
Aaron Francis
So the first one comes in, gets the lock or whatever on create. Foo is created, and it's put in DFW, and this coordinator keeps a record of Foo is now in DFW. The second request that was in flight reaches the coordinator, and it says, "Whoops, you're too late. Go to DFW," and it redirects it down to DFW.
Josh Howard
Mm-hmm.
Aaron Francis
Is that right so far?
Josh Howard
Yes.
Aaron Francis
And then more requests, uh, that were not in flight for Foo don't ever go to the central coordinator because at some point, that information is propagated to all of your edges that says, "Hey, Foo's in DFW. Don't even go try to create it because it already exists in DFW."
Josh Howard
Yeah. E- exactly. So let's say that, like, you know, the original, like, losing request came from, like, LAX.
Aaron Francis
Mm-hmm.
Josh Howard
You got subsequent requests that go through LAX. They're going to actually just see the fact, the cache result that this DO is actually, you know, in DFW.
Aaron Francis
Mm-hmm.
Josh Howard
And then they'll, uh, they'll know to go directly to DFW instead of, you know, uh, wherever the, the coordination point was previously.
Aaron Francis
Hmm. Okay.
Josh Howard
And if they can't find it there, then they can fall back to the same database, right? And, and then, like, you know, they, they can see where we've ... like, what, what the actual, you know, record is of, you know, what is the, uh, the data center which, you know, is authoritative for where that durable object lives. Um, you can, you know, track that down if, you know, the cache is for some reason invalid.
Aaron Francis
Okay. Yeah. Yeah. That makes a lot of sense to me. Um, so outside of, outside of durable objects, you've got ... I'm sorry. You'll have to tell me again. Is it Workers D1, or is it just D1 with no prefix?
Josh Howard
Um, D1 with no prefix.
Aaron Francis
D1 with no prefix. And that is the one, correct me if I'm wrong, that's the one that is, like, globally replicated everywhere?
Josh Howard
Um, no, no. So Workers KV is globally replicated everywhere. It-
Aaron Francis
Okay
Josh Howard
... it's, it's essentially like we have products that are, offer strong consistency and products that offer eventual, eventual consistency.
Aaron Francis
Okay.
Josh Howard
KV is eventually consistent but globally replicated.
Aaron Francis
Okay.
Josh Howard
Um, D1 is actually, it's strongly consistent, and, uh, it's effectively a durable object. So, um, that's- ... that's the thing. Um, so you know, the, the TLDR for D1 is that if this is confusing for you, you can use D1. Um, and it looks like a database. It, it-
Aaron Francis
Yeah
Josh Howard
... looks and feels like that database that you know and love, and, uh, it's easy to use, and you don't have to, uh, you know, worry about doing anything different. It just fits into your application. Um.
Aaron Francis
Okay. And is it accessible? So I, I played with it a while back, and it was accessible over, uh, HTTP API.
Josh Howard
Mm-hmm.
Aaron Francis
Is that still the way to access it from the outside world, not from-
Josh Howard
Yeah
Aaron Francis
... you know, Workers or something?
Josh Howard
Yeah, you can access it through an HTTP API as well as Workers. So, um, you do have to manage tokens where you don't have to do that through Workers. But yeah.
Aaron Francis
Mm-hmm.
Josh Howard
I mean, it's basically just like a database which is accessible over HTTP.
Aaron Francis
Cool. And you all, uh, I believe recently acquired the Outerbase crew. Is that right?
Josh Howard
Mm-hmm. Yeah, yeah. We did.
Aaron Francis
And so, so which they are, you know, I don't know what their team makeup is or whatever, but they have somebody on their team that has good taste because everything they do looks beautiful. So what is ... Now that they're in-house. Well, first, explain Outerbase, and now that they're in-house, how are they augmenting Cloudflare's offerings?
Josh Howard
Yeah. So, um, w- I, I would say, like, I, I think the entire team has good taste. It, it's-
Aaron Francis
Yeah. Somebody. I-
Josh Howard
Yeah
Aaron Francis
... I'm not surprised because they do beautiful work.
Josh Howard
Yeah. It, it's one of the things I, I realized whenever we were talking to them was like everybody kind of works on their own thing, and it's remarkably cohesive for that. Like, I mean, it, it's like there's, there's a shared design aesthetic. Like, you know, it's, um ... And that's, you know, across like Starbase and, um, you know, their actual like, you know, uh, like Outerbase application, I guess.
Um, Outerbase proper, not Starbase. Um, yeah, it all, it all looks great. Um, so they're essentially working across all, all of Cloudflare's storage products to-
Aaron Francis
Yeah
Josh Howard
... improve kind of the developer experience around those. And so they've started with D1. Um, you know, the, the UI got quite a glow up already. Um, that's kind of the, the first order of business And the, the goal is to actually bring that to all the other, um, storage products at Cloudflare. So, um, you know, including Durable Objects, but, you know, KV, uh, HyperDrive, all these other products that we have, um, we want them to, you know, be able to have, like, kind of a unified querying experience.
And that's basically what they did for Outerbase, where, I mean, they were effectively building a, a catalog for interacting with data stores. Um-
Aaron Francis
Mm-hmm
Josh Howard
... so.
Aaron Francis
So they, uh, they brought ... Is it the, the, uh, like, the table view or the browser, the GUI, um, into the Cloudflare dashboard so you can poke around with your D1? And can you also poke around with your Durable Objects D1?
Josh Howard
Yeah. So, um, so the goal will be to bring that to Durable Objects.
Aaron Francis
Okay.
Josh Howard
Um, the issue is, it, I mean, it, it's kind of interesting of, you know, the way D1 is architected is we basically have a worker. Like, Cloudflare builds, uh, we, we dogfood our own products quite heavily.
Aaron Francis
Mm-hmm.
Josh Howard
Right? So D1 is built using Workers and Durable Objects. And so we have our worker, which is effectively serving requests from our dashboard, right, to support that UI.
Aaron Francis
Hmm.
Josh Howard
Um, the problem with Durable Objects and why it does not have the same seamless experience is because it runs in the customer's account, right? So-
Aaron Francis
Mm
Josh Howard
... you know, D1 is a Durable Object running in our account, which is proxied by a worker running in our account. Um, we have built a lot of stuff, um, so that, that, you know, like, there, there's a more kind of interactive, better experience. Um, we don't have a way to, you know, kind of deploy a worker for our customers to sit in front of their Durable Object-
Aaron Francis
I see. Mm
Josh Howard
... um, and do that securely, and do that-
Aaron Francis
Sure
Josh Howard
... without incurring costs on behalf of users, and all the other, like, kind of finer details to get right before we, we did something like that. So, um, you know, it, it's, that, that's kind of the, the thing. We have some ideas of what we could build so that we actually, like, can bring as good of a querying experience to Durable Objects. But, you know, D1 is, you know, the thing that's, like, definitely, uh, easy to do out of the box with the architecture we have.
Aaron Francis
Hmm. That makes sense.
Josh Howard
Not easy. I mean, like, you know, it's just a small matter of code, building nice UIs. Um, you know.
Aaron Francis
Yeah.
Josh Howard
But yeah.
Aaron Francis
If it, if it was easy, everyone would do it. Um-
Josh Howard
Yeah.
Aaron Francis
Yeah. So, okay. Y'all just had your massive, uh, I don't know what you call it, launch week, developer week, you know, release everything week. Um, no lulls. Normally, there's a lull on these launch weeks where it's like, end of the week, we're just really scraping the bottom of the barrel, but y'all powered through all the way. So tell us, uh, here at the end, tell us the big things your team just released, and, like, in the next 12 to 18 months, what are you, like, what are you hoping to see, and what are you looking forward to on
kind of your side of the, the company there?
Josh Howard
Yeah. Um, great question. So, uh, the, the, the largest thing that we released was actually read replication for D1. Um-
Aaron Francis
Hmm
Josh Howard
... so D1 read replication essentially allows for you to, I mean, I mentioned, like, it's a, it's a Durable Object behind the scenes. Um, and so what this allows you to do is actually read from replicas of that database. Um, we have a sessions API which sits in front of, um, you know, that, that, uh, the, the Durable Object API, which allows you to basically say, you know, whenever I do a write to the database, get back a session which wraps a bookmark, and, um, as long as I, you know, have that session object present
for subsequent reads, my reads are sequentially consistent. Um, everything kind of corresponds to a total order, and, uh, you can always, you know, read your, your previous writes. So-
Aaron Francis
Cool
Josh Howard
... um, that's, that's, that's one piece, um, that will be coming to Durable Objects soon. Uh, the reason why we started with D- D1 is just because it is a more constrained API. There's a lot of surface area, and we wanna make sure that we get that right. Um, and so, uh, you know, the, it's working in Durable Objects today. We've used it with some other cool stuff. Um, but, uh, you know, there's, there's a lot of, of surface area to get right before we release it for DO.
Um-
Aaron Francis
So this is, like, this is, like, um, not only read replicas but also sticky sessions, read your own writes, all kind of as, like, a first party-
Josh Howard
Right
Aaron Francis
... uh, implementation.
Josh Howard
Exactly. Yeah, yeah.
Aaron Francis
That's nice. I like that.
Josh Howard
So, um, yeah. So that, that's what, uh, we released. Um, also a free tier for Durable Objects was announced. Um, and another thing that was teased and is kind of, uh, something that we'll be working on very soon, or w- we're, we're currently working on it, we'll be releasing very soon, is containers. So-
Aaron Francis
Hmm
Josh Howard
... you know, one of the things about the Workers platform is that, you know, it is all JavaScript and Wasm based because of the, the V8 isolate dependency, right? And so, um, you know, containers allow you to run, you know, code in whatever programming language you want. Um, it's just a container, right? Uh, as I mentioned, you know, Durable Objects are the way to reference in- individual resources.
And so the goal will be to actually be able to use Durable Objects to interface directly to containers. So instead of just, like, referencing a Durable Object, you can have an attached container, and that can be continually routable using the same Durable Objects API. So that's-
Aaron Francis
Okay. This is-
Josh Howard
Yeah
Aaron Francis
... this is supposed to be the wrap-up, but that's big. Hang on. So containers are, have to be fundamentally discreet from anything that currently exists because unless you've figured out a way to run them in V8 isolates, which is beyond me. So is this containers thing an entirely new, uh, engineering effort, or is it built on top of something that exists?
Josh Howard
Um, it's an entirely separate engineering effort, right?
Aaron Francis
Okay.
Josh Howard
We've got a dedicated team that is doing this, right? But, um, the question becomes, like, how do you route to containers from within the Workers platform, right?
Aaron Francis
Hmm.
Josh Howard
Um, and so because Durable Objects solves routing, right?
Aaron Francis
Mm-hmm.
Josh Howard
Um, what we can do is we can actually, um, route to a Durable Object and then have a container spun up locally so that it's, you know, they're co-located, so that you can, uh, request from a Durable Object into that container.
Aaron Francis
So the durable object acts as a sort of proxy in front of the container?
Josh Howard
Yes. And that means that you have kind of two layers of proxying for doing whatever type of, like, authentication checks or whatever. You have your, your workers proxy, which can do, like, request validation, that type of stuff.
Aaron Francis
Mm-hmm.
Josh Howard
Um, you have your durable object, uh, layer, which can do whatever you wanna do in JavaScript or just, you know, immediately delegate to the container. Uh, and then you have whatever's running in the container.
Aaron Francis
Fascinating.
Josh Howard
Yeah.
Aaron Francis
Okay.
Josh Howard
So yeah, I mean, like, you know, I- it's kind of like the thing of, like, if you wanna build something on AWS you have to understand, like, you know, IM and EC2.
Aaron Francis
Yeah.
Josh Howard
And it's like, you know, even if you're using higher order, like, services like SageMaker or something like that, you've, you've gotta know basic EC2 instance types, right? For, or they're gonna continually be referred to. I think workers and durable objects are, like, the kind of primitives that you just kind of have-
Aaron Francis
Mm-hmm
Josh Howard
... to know in order to make sense of the Cloudflare developer platform. Um, and so, you know, but containers are, they were teased for developer week. They'll be released this summer, uh, hopefully early summer. Um, and yeah, so that'll be kind of another thing. And then the, the follow-up is, um, really just making, um, you know, uh, removing asterisks from the things that I said.
So, like, one of the details that I kind of glossed over is, like, we don't run durable objects everywhere. Um, infrastructure-
Aaron Francis
Mm
Josh Howard
... for running durable objects is a little heavy, and so it's hard to run them in the global south. So you'll never notice this if you're running in Asia, Europe, or North America, but, like, if you're in Sub-Saharan Africa, like, yeah, you're still gonna see pretty bad latencies when using durable objects, and that's just because of, you know, uh, network connectivities is, is, you know, bad in some parts of the planet.
So-
Aaron Francis
Mm-hmm
Josh Howard
... um, we are, you know, with our new storage backend, we're able to work around that. Uh, it's a lot lighter weight, and so we'll be deploying in more regions. Um, but that's a rollout that will be happening over, like, the next year.
Aaron Francis
Okay. Cool. Well, is there anything else you wanna leave, uh, leave the people with? If not, tell them where they can find you.
Josh Howard
Yeah. Um, so one thing I would say is, like, we are actively hiring, so, like, you know, I mean, and I am the manager of the team. So, um, you know, if this is interesting to you, um, you know, feel free to reach out. Um, we have a job posting. And also just feel free to DM me. Um, would love to talk to you. You know, maybe you're not looking for a job, but just find this interesting. I enjoy talking to engineers. So, um, you know, definitely-
Aaron Francis
What kinds of roles?
Josh Howard
Uh, mostly systems level roles. Um-
Aaron Francis
Okay
Josh Howard
... but, you know, um, I would say if, you know, w- w- if you are, you know, able to make it through a 45-minute database podcast, you're probably an interesting person, and I'd you know, uh, would love to, to talk to you. So, uh, you know just kidding. But, you know.
Aaron Francis
Oh.
Josh Howard
Um-
Aaron Francis
That's okay. I'm taking it as a compliment for some reason. I think, yeah, that's perfect.
Josh Howard
Oh, no. I mean, like, I, I-
Aaron Francis
These are my people
Josh Howard
... I love databases. Like, I mean, like, I, I'm- ... definitely, like, you know, in the database nerd camp myself. So, like, you know, it's, you know, probably-
Aaron Francis
Listen, if y'all, if y'all want a manager who is clearly very technical, you know where to go. So that's a good sign already. He knows, he knows the inner workings, so he's probably pretty good at his job.
Josh Howard
I, you know, I, I try to be, but yeah. And, like, you know, the other thing that I would say is, like, I, you know, to that note, I do support a large team, right? So I mean, there are plenty of people who are working on this. Um, you know, I mean, I kind of wanted to speak to it because it covers durable objects and D1, but, like-
Aaron Francis
Mm-hmm
Josh Howard
... you know, um, there's a, a large group of people that are contributing to this, um, both immediately on the team and then other people across Cloudflare that just think that this is cool and want to-
Aaron Francis
Mm-hmm
Josh Howard
... you know, want, want to contribute to it. So, um, yeah, definitely, uh, you know, reach out if you're interested. Um, but yeah. And then in terms of getting in touch, um, you can find me on Twitter. Um, my Twitter handle's @ajoshhoward, um, 'cause there are many of us. And, um, yeah, uh, also I guess my email is probably... I'm, I'm not very, like, social on the internet.
Like, you know, it's like I respond to DMs and, you know, talk to people, but, like, I don't, like, you know, broadcast stuff. So, um, but yeah, definitely happy to chat. Um, my email's jayhoward@cloudflare.com.
Aaron Francis
Okay. Perfect. We will leave those, uh, those links down in the show notes below. Um, thanks for doing this, Josh. This was, uh, a fascinating deep dive into some of, uh, how Cloudflare works, which I've always wondered. So thanks for doing this.
Josh Howard
Yeah. Yeah. Anytime.
Aaron Francis
All right. We will talk soon. Until the next time. See ya.
Josh Howard
Yep. Bye.