r/programming • • Sep 10 '26

The Physics of Database Speed: from 300 to 1M transactions per second

https://www.youtube.com/watch?v=vOEL_pHFYK0

A 19 minute animated explainer video on database speed. I explain low-level database concepts, identify bottlenecks, run benchmarks and optimize write throughput to hit 1 million TPS.

130 Upvotes

18 comments sorted by

60

u/rThoro Sep 10 '26

except, that's not doing a million transactions, it's doing a million batched transactions, which are actually just 25...

11

u/tanayvk Sep 10 '26

true, and that's the point. without group commits, hitting a 1M write throughput is impossible (ensuring disk durability).

while i don't mention SAVEPOINTs in the video (to keep things simple), with SAVEPOINTs you can still have transaction level rollbacks if some transaction in the middle fails (with some application code). so you still isolate each transaction logically. of course since SQLite is pretty barebones, all this becomes an application level concern as opposed to the database itself supporting a pipelined WAL (like TigerBeetle or Postgres).

4

u/Armadillo2191 Sep 11 '26

Once you group the incoming requests into a single transaction, don't they lose their individual identity and become a single transaction (and thus have a single savepoint)?

2

u/rThoro Sep 11 '26

exactly, and the savepoints don't even work like that, because they are serial you can't batch anything relevant

0

u/Excellent_Gas3686 Sep 12 '26

you can have multiple savepoints in a single transaction, Oracle one such example

23

u/NoLegJoe Sep 10 '26

Doesn't batching like this completely undermine the Durability part of ACID? Your frontend application is now sat with all of the transactions until batch is full. What happens if the frontend goes down? You lose everything in a batch.

All you've done is handed off Durability from the database, and given it to your app, then not bothered to implement it at all!

11

u/tanayvk Sep 10 '26

not really. durability is more about guaranteeing something is durable only AFTER the transaction is confirmed by the server. with batched writes, the database/server returns a success only after the entire batch is written. if an fsync fails, durability is not violated because the server never confirmed the transactions for the complete batch.

if an application is really sustaining 1M TPS, yes a small failure would cause you lose lots of data that was never confirmed. but that is unavoidable (similar to the CAP theorem).

(also btw batching is happening on the server not the frontend, in the video we are only talking about a single node server)

6

u/gladfelter Sep 10 '26

clients are still waiting for the transaction to complete. The real risk is what happens if an update in the batch is rejected or two updates conflict? The end result is that clients that did nothing wrong get a retriable error. You may lose some isolation guarantees in other ways too, but I haven't thought it through.

2

u/dharmesh1608 Sep 23 '26

Hey Tanay, could you please get back to us. We have an interesting problem to solve.

1

u/tanayvk Sep 23 '26

what platform did you try reaching out on? can you send me a dm here

-6

u/coderemover Sep 11 '26

Or just use Cassandra and you get 1M req/sec without any special magic (just a powerful enough server).

-9

u/[deleted] Sep 10 '26

[removed] — view removed comment

6

u/programming-ModTeam Sep 10 '26

No content written mostly by an LLM. If you don't want to write it, we don't want to read it.

0

u/[deleted] Sep 11 '26

[deleted] — view deleted comment

6

u/programming-ModTeam Sep 12 '26

No content written mostly by an LLM. If you don't want to write it, we don't want to read it.