3 ms·
Ask HN: Which database would you choose for a blockchain?
OK, OK, I said the cursed "B" word. Feel free to mock me for being in the crypto space.
That said, I am in the process of building a blockchain (funded and all, not a hobby project) and I am exploring the various database options.
The only requirements (just lol) are:
- Must be completely local
- Must be very performant especially in concurrent reads and writes
I am using sqlite3 as a dummy but of course it is not suitable and not scalable enough.
I was wondering if PostgreSQL might be an idea but I am very basic in my knowledge of databases.
In your opinion, given the high throughput and concurrency, where should I start looking?
Bonus points if it is open source of course
- MatthiasPortzel 2y agoUse sqlite3 until you actually cannot. It sounds like you're assuming it's bad, but it sounds ideal for your use-case since it is designed to be a fully-local database.
- tcsenpai 2y agoI actually cannot, I have severe performance degradation when I scale the blockchain over two nodes and I traced that back to sqlite 3 unfortunately
- MatthiasPortzel 2y agoIf each node has its own local database, then: * you shouldn’t need a database that can handle concurrent writes * and increasing the number of nodes shouldn’t increase the database load
- sfmz 2y agoWhat blockchain attributes are you looking for? ... your local requirement has removed decentralization, distributed-ledger, and transparency. What's left? immutability?
- tcsenpai 2y agoMy blockchain uses the database to store also registries containing pending requests, mempool statuses and GLS which is a global status layer that is frequently accessed and wrote.
- dtagames 2y agoThe method of storage isn't a factor in something becoming a blockchain, only the fact that new records contain a hash of previous records, which themselves contain a hash of previous records, and so on. This is the "chain." How you store or retrieve it is up you. Any data storage method you like can be equally "blockchain-y."
- tcsenpai 2y agocopypasted from below just because is the very same answer: My blockchain uses the database to store also registries containing pending requests, mempool statuses and GLS which is a global status layer that is frequently accessed and wrote.
- meiraleal 2y agoIt is amusing that you got funded while being clueless about what to do. The B word works, after all. Why are you using a SQL-based database? Blockchain data is so simple you could use Redis.
- tcsenpai 2y agoYeah the B word works very well, the AI term improves that by a lot too Looking into Redis, thanks a lot :)
- tromp 2y agoOne option is LMDB [1], which is used succesfully in several blockchains. [1] https://en.wikipedia.org/wiki/Lightning_Memory-Mapped_Data https://en.wikipedia.org/wiki/Lightning_Memory-Mapped_Data
- tcsenpai 2y agoGreat, reading and learning about it. Thanks a lot!