SatoshiPortal / cyphernode

Modular Bitcoin full-node microservices API server architecture and utilities toolkit to build scalable, secure and featureful apps and services without trusted third parties
MIT License
364 stars 68 forks source link

Integration of PostgreSQL replacing SQLite3 #239

Closed Kexkey closed 2 years ago

Kexkey commented 2 years ago

Integration of PostgreSQL replacing SQLite3.

Kexkey commented 2 years ago

Trying to add @phillamy as reviewer but you're not showing up in the list of reviewers, why?

jimbojw commented 2 years ago

Curious, what motivated the switch to Postgres?

Kexkey commented 2 years ago

Hi @jimbojw

Main driver was a performance problem we got at Bull Bitcoin with the tx table. By default, sqlite3 locks the whole database when writing and that caused timeout failures on some writes.

Also, we want to be able to implement replicas. Distributed redundancy is something relatively easy with PostgreSQL.

We also wanted to use PostgreSQL with c-lightning to secure our channel states remotely. We tried a lot of alternatives (backup plugin, lsyncd with sshfs, etc.) but we think this setup is more reliable.

Finally, we've been thinking for a while to have a separate container running PostgreSQL that would also be useful for any other container in the Cyphernode ecosystem, instead of duplicating databases for each component.

Of course, all that would be possible with sqlite3, but with a lot of work.