Earlier quoted context omitted.
A pattern where you check for and then execute any necessary migrations on initialization of a Durable Object would actually work pretty well I think - presumably you can update the code for these things without erasing the existing database?
Ah yes, that would work pretty well! You'd have to be able to guarantee any migrations can run within the timeouts, but at a per-tenant level that should be very doable for most cases. Not sure why I didn't think of that approach - great idea. I might have to try this out now.
Zero-latency SQLite storage in every Durable Object
101–108 of 108 posts
Re: Zero-latency SQLite storage in every Durable Object
#102Durable objects seem so cool but the pricing always scares me. (Specifically, having to worry about getting hibernation right.) They’d be a great fit for our yjs document based strategy, but while everything in prod still works on plain ol redis and Postgres, it’s hard to justify an exploration.
What scares me is it is super specific to Cloudflare What is your option if you want to eject to another cloud?
Re: Zero-latency SQLite storage in every Durable Object
#103Earlier quoted context omitted.
E.g. if you have many websocket connections and they each have a snapshot at a point in time (that spans over many different await function calls/ws messages). SQLite can have many readers and a single writer with WAL, so a many read transactions can exist whilst the writers move the db state forward.
We (Cloudflare) have considered adding an API to create multiple "database connections" , especially to be able to stream a response from a long-running cursor while representing a consistent snapshot of the data. It's a bit tricky since if you hold open that old connection, the WAL could grow without bound and cannot be checkpointed back into the main database. What do we do when the WAL gets unreasonably large (e.g…
Re: Zero-latency SQLite storage in every Durable Object
#104Earlier quoted context omitted.
E.g. if you have many websocket connections and they each have a snapshot at a point in time (that spans over many different await function calls/ws messages). SQLite can have many readers and a single writer with WAL, so a many read transactions can exist whilst the writers move the db state forward.
We (Cloudflare) have considered adding an API to create multiple "database connections" , especially to be able to stream a response from a long-running cursor while representing a consistent snapshot of the data. It's a bit tricky since if you hold open that old connection, the WAL could grow without bound and cannot be checkpointed back into the main database. What do we do when the WAL gets unreasonably large (e.g…
To be honest this is an edge case. But I often start a read transaction on a SQLite connection just so I know multiple queries are reading from the same state (and to ensure state has not been changed between queries).
Re: Zero-latency SQLite storage in every Durable Object
#105> ..each DO constantly streams a sequence of WAL entries to object storage - batched every 16MB or every ten seconds. Which also means it may take 10 seconds before you can (reliably) read the write globally. I keep failing to see how this can replace regionally placed database clusters which can serve a continent in milliseconds. Edit: I know it uses streams, but those are only to 5 followers and CF have hundreds of…
Re: Zero-latency SQLite storage in every Durable Object
#106What is the difference between a "durable object" and a file?
You can read the full article for an answer to that: https://blog.cloudflare.com/sqlite-in-durable-objects/ Short version: it's replicated to five data centers on every transaction, and backed up as a stream to object storage as well.
Re: Zero-latency SQLite storage in every Durable Object
#107Earlier quoted context omitted.
You can read the full article for an answer to that: https://blog.cloudflare.com/sqlite-in-durable-objects/ Short version: it's replicated to five data centers on every transaction, and backed up as a stream to object storage as well.
So it's a file that gets backed up like dropbox
Re: Zero-latency SQLite storage in every Durable Object
#108I really love the Durable Object design, particularly because it's easy to understand how it works on the inside. Unlike lots of other solutions designed for realtime data stuff, Durable Objects have a simplicity to them, much like Redis and Italian food. You can see all the ingredients. Given enough time and resources (and datacenters :) ), a competent programmer could read the DO docs and reimplement something simi…