1
00:00:00,572 --> 00:00:03,427
Every agentic project wants a database,

2
00:00:03,427 --> 00:00:07,500
for sessions, traces, task state and memory.

3
00:00:07,500 --> 00:00:10,220
So does every app with state to keep.

4
00:00:10,220 --> 00:00:14,617
The usual answer is a Postgres or MySQL server,

5
00:00:14,617 --> 00:00:15,567
and then you're running it:

6
00:00:15,567 --> 00:00:18,382
sizing it, migrating it, upgrading it,

7
00:00:18,382 --> 00:00:22,190
backing it up, and getting paged when its disk fills.

8
00:00:22,190 --> 00:00:25,550
Now give each of a thousand users their own database

9
00:00:25,550 --> 00:00:27,580
server. That isn't tenable.

10
00:00:29,095 --> 00:00:31,120
Meanwhile, you already have a bucket,

11
00:00:31,120 --> 00:00:33,279
which stores data very well.

12
00:00:33,279 --> 00:00:37,112
S3 or Backblaze holds your files at any scale,

13
00:00:37,112 --> 00:00:39,119
and you never run a server for it.

14
00:00:39,119 --> 00:00:42,590
So put the database there too, as more objects.

15
00:00:44,104 --> 00:00:45,568
Here's what that looks like.

16
00:00:45,568 --> 00:00:49,330
One command starts a server, one more creates a database,

17
00:00:49,330 --> 00:00:51,680
and you can store a value right away.

18
00:00:52,020 --> 00:00:55,059
Now make a thousand more, one per user.

19
00:00:55,059 --> 00:00:56,944
That took about five seconds.

20
00:00:56,944 --> 00:01:01,063
Each has its own token, storage quota and request budget,

21
00:01:01,063 --> 00:01:04,580
and a database nobody is using is a single object in the

22
00:01:04,580 --> 00:01:07,810
bucket: a hundred and forty-six bytes.

23
00:01:09,270 --> 00:01:11,563
And agents don't need SQL.

24
00:01:11,563 --> 00:01:13,670
What they need fits on a page:

25
00:01:13,670 --> 00:01:17,190
keys and JSON values, ordered scans,

26
00:01:17,190 --> 00:01:20,720
and transactions. Read some keys, decide,

27
00:01:20,720 --> 00:01:23,773
write. If anything you read changed first,

28
00:01:23,773 --> 00:01:26,787
nothing is written and your code runs again.

29
00:01:26,787 --> 00:01:29,590
Name a transaction with an idempotency key,

30
00:01:29,590 --> 00:01:32,359
and sending it twice applies it once.

31
00:01:32,359 --> 00:01:34,839
The client ships storage for pi-durable,

32
00:01:34,839 --> 00:01:37,460
an agent harness that keeps conversations,

33
00:01:37,460 --> 00:01:39,447
tasks and documents.

34
00:01:39,447 --> 00:01:42,870
It passes pi-durable's complete storage test suite.

35
00:01:44,330 --> 00:01:46,490
It runs as a Kubernetes Deployment,

36
00:01:46,490 --> 00:01:49,231
like your web servers, with two volumes.

37
00:01:49,231 --> 00:01:52,490
One holds the key that signs access tokens.

38
00:01:52,490 --> 00:01:54,285
The other is a cache;

39
00:01:54,285 --> 00:01:57,430
the comment says losing it costs bucket requests,

40
00:01:57,430 --> 00:02:01,880
never data. An autoscaler runs it on two to ten pods.

41
00:02:02,299 --> 00:02:06,540
Every pod serves many databases, and each database has one

42
00:02:06,540 --> 00:02:09,820
owner at a time. The owner is picked by hashing the

43
00:02:09,820 --> 00:02:12,780
database's name over the list of pods.

44
00:02:12,780 --> 00:02:15,580
A request that lands on another pod is passed to the

45
00:02:15,580 --> 00:02:17,900
owner. If the owner doesn't answer,

46
00:02:17,900 --> 00:02:20,220
that pod takes the database over.

47
00:02:20,220 --> 00:02:23,690
For that to be safe, everything has to live in the bucket.

48
00:02:25,080 --> 00:02:27,950
Here's a pi-durable agent keeping its whole session in a

49
00:02:27,950 --> 00:02:31,630
database: every message, tool call and task,

50
00:02:31,630 --> 00:02:33,154
written as it happens.

51
00:02:33,154 --> 00:02:36,590
We kill the server mid-session, and start a new one.

52
00:02:36,590 --> 00:02:38,589
The agent picks up where it left off,

53
00:02:38,589 --> 00:02:40,300
and nothing is lost.

54
00:02:40,638 --> 00:02:43,598
The new server never touched the old one's disk.

55
00:02:43,598 --> 00:02:46,110
It read the whole session from the bucket.

56
00:02:46,750 --> 00:02:48,860
That's Durable DB.

57
00:02:51,321 --> 00:02:53,664
It's a database for the agentic world:

58
00:02:53,664 --> 00:02:58,680
one static binary that serves transactions over HTTP and

59
00:02:58,680 --> 00:03:01,800
keeps every byte in a bucket on Backblaze or another

60
00:03:01,800 --> 00:03:06,325
S3-compatible store, or in a directory on your laptop.

61
00:03:06,325 --> 00:03:08,320
But a bucket has no locks.

62
00:03:08,320 --> 00:03:11,499
We'll see how it gives you real transactions anyway,

63
00:03:11,499 --> 00:03:13,860
what happens when you break it on purpose,

64
00:03:13,860 --> 00:03:15,400
and how it's fast.

65
00:03:20,080 --> 00:03:22,502
You know the five requests a bucket takes:

66
00:03:22,502 --> 00:03:26,159
put, get, head, list and delete.

67
00:03:26,159 --> 00:03:29,358
durable-db relies on two guarantees.

68
00:03:29,358 --> 00:03:32,800
Read-after-write: once a put or delete returns,

69
00:03:32,800 --> 00:03:35,600
any request that starts afterwards sees it.

70
00:03:35,600 --> 00:03:38,419
And whole objects: you get all of an object,

71
00:03:38,419 --> 00:03:39,550
or none of it.

72
00:03:39,889 --> 00:03:42,146
There's no lock and no lease.

73
00:03:42,146 --> 00:03:46,290
Amazon S3 has conditional writes, a put that only succeeds

74
00:03:46,290 --> 00:03:48,284
if the object hasn't changed.

75
00:03:48,284 --> 00:03:51,170
Backblaze B2 rejects them on objects,

76
00:03:51,170 --> 00:03:53,840
so durable-db never uses them.

77
00:03:55,220 --> 00:03:58,493
Here's the problem every database on a bucket faces.

78
00:03:58,493 --> 00:04:01,780
Server A, in teal, owns a database.

79
00:04:01,780 --> 00:04:04,150
A client sends it a transfer.

80
00:04:04,150 --> 00:04:07,591
And A freezes: a stalled virtual machine,

81
00:04:07,591 --> 00:04:10,375
or a process its host has paused.

82
00:04:10,375 --> 00:04:13,670
A request reaches server B, in violet.

83
00:04:13,670 --> 00:04:18,240
B passes it to A, gets no answer, takes the database over

84
00:04:18,240 --> 00:04:20,145
and reads it from the bucket.

85
00:04:20,145 --> 00:04:22,500
It commits transactions of its own.

86
00:04:22,840 --> 00:04:26,164
Then A wakes up, with the transfer half done.

87
00:04:26,164 --> 00:04:28,762
It writes it to the bucket, and tells its client:

88
00:04:28,762 --> 00:04:32,054
committed. B never reads that write.

89
00:04:32,054 --> 00:04:35,171
The client was told yes, and the transfer is gone.

90
00:04:35,171 --> 00:04:37,270
Neither server saw an error.

91
00:04:39,318 --> 00:04:42,300
durable-db solves this without a lock,

92
00:04:42,300 --> 00:04:46,190
a lease or a consensus group, and it starts with names.

93
00:04:46,190 --> 00:04:48,608
Here's a real listing of one database,

94
00:04:48,608 --> 00:04:52,930
from our run. Frames, under L, each hold a group of

95
00:04:52,930 --> 00:04:54,690
committed transactions.

96
00:04:54,690 --> 00:04:59,330
A manifest, under M, lists the data so far and says which

97
00:04:59,330 --> 00:05:00,770
frames come after it.

98
00:05:00,770 --> 00:05:04,640
And a claim, under C, says who's in charge.

99
00:05:04,980 --> 00:05:07,940
Every key shares this long middle part,

100
00:05:07,940 --> 00:05:12,859
the epoch: a number, then sixteen random hex digits.

101
00:05:12,859 --> 00:05:16,260
Each takeover picks a new epoch, one higher than any it

102
00:05:16,260 --> 00:05:20,260
sees, with fresh random digits, so two servers that pick

103
00:05:20,260 --> 00:05:22,208
the same number still differ.

104
00:05:22,208 --> 00:05:26,260
So only one process ever writes under a given epoch,

105
00:05:26,260 --> 00:05:28,660
two servers never write the same key,

106
00:05:28,660 --> 00:05:31,170
and no write needs to be conditional.

107
00:05:32,595 --> 00:05:34,589
So which writes count?

108
00:05:34,589 --> 00:05:37,910
The claim decides. It's a tiny object named after an

109
00:05:37,910 --> 00:05:42,068
epoch, and it says that epoch may write this database.

110
00:05:42,068 --> 00:05:45,190
To take over, server B puts its own claim,

111
00:05:45,190 --> 00:05:48,630
lists the claims, and deletes every lower one.

112
00:05:48,630 --> 00:05:51,987
Deleting A's claim is how B revokes A.

113
00:05:51,987 --> 00:05:55,940
A isn't told. B revokes before it reads the data.

114
00:05:57,450 --> 00:05:59,384
Here's a commit on server A.

115
00:05:59,384 --> 00:06:02,059
A uploads a frame holding the transaction.

116
00:06:02,059 --> 00:06:05,880
Once that upload returns, A sends one HEAD request for its

117
00:06:05,880 --> 00:06:09,080
own claim. That's the claim check, and it's amber from

118
00:06:09,080 --> 00:06:11,629
here on. If the claim is still there,

119
00:06:11,629 --> 00:06:13,640
A says yes to its client.

120
00:06:13,640 --> 00:06:16,120
If it's gone, A doesn't say yes.

121
00:06:16,120 --> 00:06:19,750
Every yes waits on one upload and one head.

122
00:06:21,232 --> 00:06:25,210
A's requests run along the top, B's along the bottom,

123
00:06:25,210 --> 00:06:26,893
the bucket between.

124
00:06:26,893 --> 00:06:30,242
Each request takes effect in the bucket at one instant:

125
00:06:30,242 --> 00:06:34,810
a dot. A uploads its frame, then checks its claim.

126
00:06:34,810 --> 00:06:39,080
B deletes A's claim, then lists A's frames.

127
00:06:39,420 --> 00:06:42,233
Slide B's delete after A's check.

128
00:06:42,233 --> 00:06:45,660
A's check finds the claim, so A says yes.

129
00:06:45,660 --> 00:06:49,421
In order, the dots are A's frame, A's check,

130
00:06:49,421 --> 00:06:51,820
B's delete and B's listing.

131
00:06:51,820 --> 00:06:55,901
So B's listing includes A's frame, and B replays it.

132
00:06:55,901 --> 00:06:58,170
Nothing acknowledged is lost.

133
00:06:58,518 --> 00:07:01,374
Slide B's delete before A's check.

134
00:07:01,374 --> 00:07:05,234
A's check finds nothing, and A doesn't say yes.

135
00:07:05,234 --> 00:07:07,950
Put it anywhere: one of those two happens.

136
00:07:07,950 --> 00:07:10,478
The argument uses only one guarantee,

137
00:07:10,478 --> 00:07:12,140
read-after-write.

138
00:07:13,520 --> 00:07:16,711
Stretch A's pause to a minute, or an hour.

139
00:07:16,711 --> 00:07:19,040
The order of the dots doesn't change.

140
00:07:19,040 --> 00:07:21,038
A lease works the other way round:

141
00:07:21,038 --> 00:07:24,970
check, then write, and a pause in between breaks it.

142
00:07:24,970 --> 00:07:28,000
The claim check is write, then check.

143
00:07:28,000 --> 00:07:31,206
By the time A checks, its frame is already in the bucket,

144
00:07:31,206 --> 00:07:33,390
so none of this needs a clock.

145
00:07:35,522 --> 00:07:39,130
If A's check fails, A can't confirm the commit:

146
00:07:39,130 --> 00:07:41,638
its frame may or may not count.

147
00:07:41,638 --> 00:07:44,782
So it's retried with the same idempotency key,

148
00:07:44,782 --> 00:07:48,012
by the client or by the server on its behalf.

149
00:07:48,012 --> 00:07:52,090
Every keyed commit also stores a receipt under its key.

150
00:07:52,090 --> 00:07:56,090
If B already replayed A's frame, B finds that receipt and

151
00:07:56,090 --> 00:08:00,170
writes nothing. If not, the retry is a fresh commit.

152
00:08:00,170 --> 00:08:03,000
Either way, the transfer happens once.

153
00:08:07,477 --> 00:08:11,219
Here are three servers on one MinIO bucket,

154
00:08:11,219 --> 00:08:14,260
a ledger of two hundred and fifty-six accounts in eight

155
00:08:14,260 --> 00:08:18,100
databases, and sixteen clients moving money between them,

156
00:08:18,100 --> 00:08:20,581
about four hundred transfers a second.

157
00:08:20,581 --> 00:08:23,620
Transfers only move money, so the total should never

158
00:08:23,620 --> 00:08:24,770
change.

159
00:08:25,158 --> 00:08:27,884
We kill one server mid-transaction.

160
00:08:27,884 --> 00:08:30,790
Its databases answer again from the other two within half

161
00:08:30,790 --> 00:08:33,700
a second. Now we kill all three.

162
00:08:34,084 --> 00:08:37,800
We start a fresh server process with nothing on its disk,

163
00:08:37,800 --> 00:08:39,560
and the transfers come back.

164
00:08:39,560 --> 00:08:42,760
At the end, the balances still add up to their starting

165
00:08:42,760 --> 00:08:45,880
total, and every transfer that a client was told had

166
00:08:45,880 --> 00:08:47,990
succeeded is in the bucket.

167
00:08:49,375 --> 00:08:51,990
The same kind of test runs on Kubernetes:

168
00:08:51,990 --> 00:08:54,491
a three-node cluster on one desktop,

169
00:08:54,491 --> 00:08:56,410
backed by a B2 bucket.

170
00:08:56,410 --> 00:08:59,450
A ledger of sixteen clients runs through the Service while

171
00:08:59,450 --> 00:09:03,450
the autoscaler adds pods, one pod is force-deleted,

172
00:09:03,450 --> 00:09:05,856
and the autoscaler scales back down.

173
00:09:05,856 --> 00:09:09,640
It ran eighteen times, and every ledger balanced.

174
00:09:11,100 --> 00:09:15,100
And on one desktop, a server was stopped every ten seconds

175
00:09:15,100 --> 00:09:18,219
for half an hour: a hundred and fifty-seven stops,

176
00:09:18,219 --> 00:09:21,978
most of them kills, and nearly two million transfers,

177
00:09:21,978 --> 00:09:23,450
all verified.

178
00:09:24,910 --> 00:09:27,574
The protocol itself is also written as a model,

179
00:09:27,574 --> 00:09:32,350
in TLA+, and a model checker tries every order of every

180
00:09:32,350 --> 00:09:35,710
step: for two servers and two transactions,

181
00:09:35,710 --> 00:09:39,137
with crashes anywhere and uploads landing late.

182
00:09:39,137 --> 00:09:42,349
That's about three and a half million distinct states,

183
00:09:42,349 --> 00:09:45,020
and none of them loses an acknowledged write.

184
00:09:46,520 --> 00:09:49,920
Each of the protocol's thirteen rules is a switch in that

185
00:09:49,920 --> 00:09:53,360
model. Turn any one off, and the checker finds a way to

186
00:09:53,360 --> 00:09:54,790
break the database.

187
00:09:54,790 --> 00:09:58,479
All thirteen do, each within eleven to thirty steps:

188
00:09:58,479 --> 00:10:00,190
every rule is needed.

189
00:10:01,650 --> 00:10:04,528
The Rust code itself gets a chaos test.

190
00:10:04,528 --> 00:10:07,970
Three servers share a store that delays every request,

191
00:10:07,970 --> 00:10:11,490
drops four in a hundred, applies four more while reporting

192
00:10:11,490 --> 00:10:14,690
that they failed, and applies three more up to a second

193
00:10:14,690 --> 00:10:17,890
and a half late. Servers crash without warning,

194
00:10:17,890 --> 00:10:19,890
and stale owners keep running.

195
00:10:19,890 --> 00:10:23,968
After each run, the test checks every acknowledged write.

196
00:10:23,968 --> 00:10:26,640
Two hundred random runs pass.

197
00:10:26,980 --> 00:10:29,116
We took the claim check out of the code,

198
00:10:29,116 --> 00:10:32,038
and the chaos test failed on its first run,

199
00:10:32,038 --> 00:10:34,290
in under a third of a second.

200
00:10:38,750 --> 00:10:42,216
Every commit costs one upload and one head.

201
00:10:42,216 --> 00:10:46,590
On a local NVMe directory, the upload is a file and its

202
00:10:46,590 --> 00:10:49,389
directory entry, each flushed to disk:

203
00:10:49,389 --> 00:10:51,722
about six milliseconds a commit.

204
00:10:51,722 --> 00:10:55,230
On Backblaze, from a desktop twenty-two milliseconds away

205
00:10:55,230 --> 00:10:57,980
over Wi-Fi, it's seventy-seven.

206
00:10:58,320 --> 00:11:01,040
One client, one commit after another,

207
00:11:01,040 --> 00:11:02,957
made twelve a second.

208
00:11:02,957 --> 00:11:06,240
Yet one database on that bucket reaches nearly nineteen

209
00:11:06,240 --> 00:11:07,230
hundred.

210
00:11:08,610 --> 00:11:12,290
It uses group commit, as Postgres does for its write-ahead

211
00:11:12,290 --> 00:11:15,568
log. Two frames can be in flight at once.

212
00:11:15,568 --> 00:11:18,124
While they are, new commits wait.

213
00:11:18,124 --> 00:11:21,890
When one lands, everything waiting rides the next frame,

214
00:11:21,890 --> 00:11:24,531
and one head checks the claim for all of them.

215
00:11:24,531 --> 00:11:26,400
They're acknowledged in order.

216
00:11:28,375 --> 00:11:31,020
Clients run along the bottom, commits a second up the

217
00:11:31,020 --> 00:11:34,060
side, and each commit's wait below.

218
00:11:34,060 --> 00:11:35,900
Backblaze is in orange.

219
00:11:35,900 --> 00:11:38,780
Each client waits for its answer before sending the next

220
00:11:38,780 --> 00:11:39,870
commit.

221
00:11:39,870 --> 00:11:42,589
If every commit waited for its own upload,

222
00:11:42,589 --> 00:11:44,110
the clients would queue:

223
00:11:44,110 --> 00:11:46,750
two hundred and fifty-six times seventy-seven

224
00:11:46,750 --> 00:11:49,963
milliseconds, about twenty seconds each.

225
00:11:49,963 --> 00:11:54,270
On B2, one database goes from twelve commits a second with

226
00:11:54,270 --> 00:11:57,470
one client to eighteen hundred and eighty-one with two

227
00:11:57,470 --> 00:11:59,149
hundred and fifty-six.

228
00:11:59,149 --> 00:12:02,510
The median wait went from seventy-seven milliseconds to a

229
00:12:02,510 --> 00:12:04,791
hundred and twenty-eight, and stayed there.

230
00:12:04,791 --> 00:12:07,898
Two hundred and fifty-six clients each waiting about an

231
00:12:07,898 --> 00:12:11,302
eighth of a second makes about two thousand a second.

232
00:12:11,302 --> 00:12:14,780
The measurement stopped there, so that isn't a ceiling.

233
00:12:15,120 --> 00:12:17,680
On a local directory, in blue-grey,

234
00:12:17,680 --> 00:12:21,040
the same shape, up to sixteen and a half thousand commits

235
00:12:21,040 --> 00:12:24,223
a second. More clients make bigger frames,

236
00:12:24,223 --> 00:12:25,790
not more uploads.

237
00:12:27,250 --> 00:12:29,236
Reads come in two kinds.

238
00:12:29,236 --> 00:12:31,638
A strong read waits for a claim check,

239
00:12:31,638 --> 00:12:34,450
so it never misses a write acknowledged before it:

240
00:12:34,450 --> 00:12:38,364
on B2, six thousand four hundred and eighty a second,

241
00:12:38,364 --> 00:12:40,930
at thirty-seven milliseconds each.

242
00:12:40,930 --> 00:12:44,130
A session read skips the check and answers from memory,

243
00:12:44,130 --> 00:12:46,212
and never goes back in time for you:

244
00:12:46,212 --> 00:12:48,764
two hundred and seventy-six thousand a second,

245
00:12:48,764 --> 00:12:50,640
at a tenth of a millisecond.

246
00:12:52,100 --> 00:12:55,940
On Backblaze, each upload lands on one of many storage

247
00:12:55,940 --> 00:12:58,100
servers, and they differ.

248
00:12:58,100 --> 00:13:00,891
The same small upload, at the same moment,

249
00:13:00,891 --> 00:13:04,180
had medians from sixty-seven milliseconds to over nine

250
00:13:04,180 --> 00:13:08,420
hundred. So durable-db sends each upload to the fastest

251
00:13:08,420 --> 00:13:12,020
free one, and races an identical upload on a second when

252
00:13:12,020 --> 00:13:15,219
it can spare one. Same bytes, same key,

253
00:13:15,219 --> 00:13:16,530
so that's safe.

254
00:13:18,069 --> 00:13:20,311
Memory doesn't grow with the database:

255
00:13:20,311 --> 00:13:23,590
servers held to one gig used at most five hundred and

256
00:13:23,590 --> 00:13:27,866
thirty-four megs, for databases up to sixteen gigs.

257
00:13:27,866 --> 00:13:31,830
And after a kill, a sixteen-gig database reopened in fifty

258
00:13:31,830 --> 00:13:34,500
milliseconds, on a local directory.

259
00:13:38,960 --> 00:13:41,785
So it's built for many small databases,

260
00:13:41,785 --> 00:13:44,480
each written by one server at a time.

261
00:13:44,480 --> 00:13:47,120
Transactions don't cross databases,

262
00:13:47,120 --> 00:13:49,439
and there's no point-in-time restore.

263
00:13:49,439 --> 00:13:52,826
Of cloud stores, it's only been run on Backblaze;

264
00:13:52,826 --> 00:13:55,930
Amazon S3 and the others share the code.

265
00:13:55,930 --> 00:13:58,510
And it hasn't been reviewed outside the project.

266
00:14:00,050 --> 00:14:03,586
You get a database for every user and every agent,

267
00:14:03,586 --> 00:14:06,931
as many as you like, in a bucket you already have.

268
00:14:06,931 --> 00:14:09,570
You can kill the servers, every one of them,

269
00:14:09,570 --> 00:14:12,960
at any moment, because the database is in the bucket.
