Serverless Postgres, with storage separated from compute"
(Which is a very good idea, btw!)
Observation: All future databases should be written like this, that is, with a clear separation of whatever block (aka storage "bucket") based engine actually loads and stores the data on the back-end (sub-observation: this observation is relevant to future OS'es as well!) from the data structures and code and processing that goes on in the compute (aka CPU, aka running code) component in the main engine.
Code should always be written such that the block storage back-end (whether its local in the form of local hard disk space or whether its remote, in the form of Internet accessible block-based storage) is either #ifdef'd around (or the programming language's equivalent of #ifdef, i.e., "conditional compilation", "conditionally compiled", for example, in Rust it's '#[cfg(...)]', in Go it's '//go:build ...', in Zig it's 'if (@import("builtin")....)' or 'comptime', in Delphi/Pascal/FreePascal it's '{$IFDEF}..{$ENDIF}', etc., etc.
Or, optionally, the code could use plug-ins. Plug-ins for each of the separate database back ends supported.
If a database is to run on a local disk, then with conditional compilation you retain the ability to have a single fast local database executable that "does it all" and you have the ability to "compile the local back-end out" (i.e., switch to a plug-in or different code) simply by toggling the macro/directive that governs those #ifdefs on or off, i.e., present or absent during compile...
If you're into OOP, you could also do all of the above with Objects (different objects represent different back-end types, instantiate what you need at runtime) instead of #ifdefs and/or plug-ins...
Anyway, we welcome Peat to the storage separated from compute database arena!
> Code should always be written such that the block storage back-end (whether its local in the form of local hard disk space or whether its remote, in the form of Internet accessible block-based storage) is either #ifdef'd around (or the programming language's equivalent of #ifdef, i.e., "conditional compilation", "conditionally compiled", for example, in Rust it's '#[cfg(...)]', in Go it's '//go:build ...', in Zig it's 'if (@import("builtin")....)' or 'comptime', in Delphi/Pascal/FreePascal it's '{$IFDEF}..{$ENDIF}', etc., etc.
I don’t think the main issue is the actual fread() calls. Virtualizing file access and having a pluggable interface for storage is nothing new.
The real complexity is keeping that storage in sync when the server itself is distributed. In core PostgreSQL there’s a shared memory buffer pool. It’s accessed and serialized by all readers and writers. Offloading the physical writes is the easy part.
>The real complexity is keeping that storage in sync when the server itself is distributed. In core PostgreSQL there’s a shared memory buffer pool. It’s accessed and serialized by all readers and writers. Offloading the physical writes is the easy part.
An excellent point!
Yes, there is the distributed aspect to things, and yes, keeping storage in sync if the server itself is distributed would be the greater complexity!
(Random observation: There's a distinct difference here between databases with distributed servers here along the lines of "is a given distributed server going instance going to be used read only or must it also write? I.e., Read-Only distributed server instances, vs. Read-Write. If each instance has to be both, then yes, that's a lot of additional complexity! Another observation: If we permit write only instances, then write transactions are typically of two types: 1) Must lock all relevant records during update from all other writers (i.e. bank or financial transactions) and 2) Timestamped, locking unneeded, eventually consistent across all nodes (i.e., posts, status updates, likes, etc.)... if any instance has to do all of that (read and write) across the data shared by all nodes, then yes, that's quite complex! (Also, you haven't told me if instances are permitted to communicate to one another directly, or if all of their communication must be block-based, i.e., from the back-end, because then it needs to be determined how the communication for updates propagates! i.e., are multiple back-end blocks re-read at a specific interval?) etc., etc.)
Separating compute and storage is fine and all but you have to make sure the scaling curve makes sense. Cloud native designs are great but until recently ram was extremely cheap and you can go very, very far with just a single node. Anything less than 10TB, until fairly recently, was cheaper to run on local hardware, especially if you have a server class Xeon (or nowadays, a high end M series Mac chip).
Products like DuckDB came about because of what I like to call Big Data Fatigue where you don't really have Big Data (unless you actually have a viral scale product which most medium size SaaS companies do not).
Not to knock on S3 though, it's an amazing product and I have loved what it spawned. Here's a shout out to the logging products I have been enjoying:
Serverless Postgres, with storage separated from compute"
(Which is a very good idea, btw!)
Observation: All future databases should be written like this, that is, with a clear separation of whatever block (aka storage "bucket") based engine actually loads and stores the data on the back-end (sub-observation: this observation is relevant to future OS'es as well!) from the data structures and code and processing that goes on in the compute (aka CPU, aka running code) component in the main engine.
Code should always be written such that the block storage back-end (whether its local in the form of local hard disk space or whether its remote, in the form of Internet accessible block-based storage) is either #ifdef'd around (or the programming language's equivalent of #ifdef, i.e., "conditional compilation", "conditionally compiled", for example, in Rust it's '#[cfg(...)]', in Go it's '//go:build ...', in Zig it's 'if (@import("builtin")....)' or 'comptime', in Delphi/Pascal/FreePascal it's '{$IFDEF}..{$ENDIF}', etc., etc.
(Most languages have some form of #ifdef, or their own version, for conditional compilation: https://en.wikipedia.org/wiki/Conditional_compilation)
Or, optionally, the code could use plug-ins. Plug-ins for each of the separate database back ends supported.
If a database is to run on a local disk, then with conditional compilation you retain the ability to have a single fast local database executable that "does it all" and you have the ability to "compile the local back-end out" (i.e., switch to a plug-in or different code) simply by toggling the macro/directive that governs those #ifdefs on or off, i.e., present or absent during compile...
If you're into OOP, you could also do all of the above with Objects (different objects represent different back-end types, instantiate what you need at runtime) instead of #ifdefs and/or plug-ins...
Anyway, we welcome Peat to the storage separated from compute database arena!
Related:
https://en.wikipedia.org/wiki/Separation_of_concerns
https://en.wikipedia.org/wiki/Modular_programming
https://en.wikipedia.org/wiki/Encapsulation_(computer_progra...
Replies (3)
I don’t think the main issue is the actual fread() calls. Virtualizing file access and having a pluggable interface for storage is nothing new.
The real complexity is keeping that storage in sync when the server itself is distributed. In core PostgreSQL there’s a shared memory buffer pool. It’s accessed and serialized by all readers and writers. Offloading the physical writes is the easy part.
Replies (1)
An excellent point!
Yes, there is the distributed aspect to things, and yes, keeping storage in sync if the server itself is distributed would be the greater complexity!
(Random observation: There's a distinct difference here between databases with distributed servers here along the lines of "is a given distributed server going instance going to be used read only or must it also write? I.e., Read-Only distributed server instances, vs. Read-Write. If each instance has to be both, then yes, that's a lot of additional complexity! Another observation: If we permit write only instances, then write transactions are typically of two types: 1) Must lock all relevant records during update from all other writers (i.e. bank or financial transactions) and 2) Timestamped, locking unneeded, eventually consistent across all nodes (i.e., posts, status updates, likes, etc.)... if any instance has to do all of that (read and write) across the data shared by all nodes, then yes, that's quite complex! (Also, you haven't told me if instances are permitted to communicate to one another directly, or if all of their communication must be block-based, i.e., from the back-end, because then it needs to be determined how the communication for updates propagates! i.e., are multiple back-end blocks re-read at a specific interval?) etc., etc.)
But yes, completely agreed!
Related:
CAP theorem:
https://en.wikipedia.org/wiki/CAP_theorem
Errors in Database Systems, Eventual Consistency, and the CAP Theorem (Michael Stonebraker):
https://dsf.berkeley.edu/cs286/papers/errors-cacmblog2010.pd...
Byzantine fault:
https://en.wikipedia.org/wiki/Byzantine_fault
GitHub: Awesome distributed databases:
https://github.com/awelist/awesome-distributed-databases
GitHub: Awesome distributed systems:
https://github.com/FedericoPonzi/awesome-distributed-systems
Products like DuckDB came about because of what I like to call Big Data Fatigue where you don't really have Big Data (unless you actually have a viral scale product which most medium size SaaS companies do not).
Not to knock on S3 though, it's an amazing product and I have loved what it spawned. Here's a shout out to the logging products I have been enjoying:
-https://github.com/VictoriaMetrics/VictoriaLogs
- https://github.com/quickwit-oss/quickwit
- https://github.com/rootprint/rootprint
- https://github.com/openobserve/openobserve
And for your #ifdefs, I raise you OpenDAL
https://opendal.apache.org/blog/opendal-access-data-freely/
I have found that SQLite, Litestream, and Honker have gotten me very, very far in production.
- https://honker.dev/
- https://litestream.io/