[フレーム]
BT

InfoQ Software Architects' Newsletter

A monthly overview of things you need to know as an architect or aspiring architect.

View an example

We protect your privacy.

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Unlock the full InfoQ experience

Unlock the full InfoQ experience by logging in! Stay updated with your favorite authors and topics, engage with content, and download exclusive resources.

Log In
or

Don't have an InfoQ account?

Register
  • Stay updated on topics and peers that matter to youReceive instant alerts on the latest insights and trends.
  • Quickly access free resources for continuous learningMinibooks, videos with transcripts, and training materials.
  • Save articles and read at anytimeBookmark articles to read whenever youre ready.

Topics

Choose your language

InfoQ Homepage News HC-tree is a High-Concurrency Backend for SQLite Supporting Replication

HC-tree is a High-Concurrency Backend for SQLite Supporting Replication

Jan 25, 2023 2 min read

Write for InfoQ

Feed your curiosity. Help 550k+ global
senior developers
each month stay ahead.
Get in touch

HC-tree is a project aimed to build a new backend for SQLite specifically optimized for high-concurrency and leader-follower style replication. While still experimental, HC-tree can be used as an SQLite drop-in replacement, albeit with limitations.

SQLite is sometimes used as the core of a client/server database system. While it works reliably well in such cases, the database backend module that it uses to store b-tree structures in its database file was not designed with this case in mind and can be improved upon in several ways.

In particular, SQLite does not fully support the possibility of multiple simultaneous writers. Even when using its begin-concurrent extension, which uses page-level locking to allow multiple writers, SQLite may incur in locking conflicts and thus needs to serialize all commit operations.

HC-tree, on the contrary, is designed to support dozens of concurrent writers, say the team behind it, thanks to its optimistic row-level locking.

HC-tree offers similar MVCC based optimistic concurrency to SQLite with the begin-concurrent extension, except that it validates transactions based on the keys and logical ranges of keys accessed instead of the set of pages.

The project's goal is to be at least as fast as SQLite for the single-threaded case so that running concurrent writes can really bring a performance advantage. As the official benchmarks show, HC-tree easily outperforms stock SQLite in a number of different concurrent scenarios and is on par with respect to single-writer cases.

Another goal of HC-tree is improving SQLite support for replication beyond what is permitted by the standard sessions extension, which enables serializing the content of a committed transaction to send it to a different database. To this aim, HC-tree will promote the sessions extension to be part of the backend and add support to manage leader-follower transactions, meaning that changes can be applied more quickly from the leader database to followers because no validation is required.

As a last note regarding improved features, HC-tree aims to replace 32-bit page numbers with 48-bit page numbers in the future to go beyond SQLite limit of 16TiB.

HC-tree is still a work in progress, and while it can be used for experimentation and assessing whether it is a good replacement for an existing SQLite-based solution, it still has a number of limitations, including missing support for BEGIN EXCLUSIVE, reduced efficiency for transactions that do not fit entirely in main memory, and others that you can check out on the project's official page.

About the Author

Sergio De Simone

Show moreShow less

Rate this Article

Adoption
Style

This content is in the Open Source topic

Related Topics:

Related Content

The InfoQ Newsletter

A round-up of last week’s content on InfoQ sent out every Tuesday. Join a community of over 250,000 senior developers. View an example

We protect your privacy.

BT

AltStyle によって変換されたページ (->オリジナル) /