Hyperledger Fabric is an open-source, permissioned blockchain framework that is used for developing enterprise blockchain solutions and applications. The Hyperledger Fabric project is one of the major blockchain projects within Hyperledger, a multi-project collaborative effort started in 2015 by the Linux Foundation to advance cross-industry blockchain technologies. Today, Hyperledger Fabric now has over 120,000 contributing organizations and over 15,000 engineer contributors working together to advance the project.
Hyperledger Fabric has a modular (plug-and-play) architecture and can reach transactions of over 1,000 transactions per second (TPS), which can be upgraded to reach 20,000 TPS. Hyperledger Fabric also provides a particular set of features that differentiates it from other blockchain technologies and allows for easier adoption by enterprises. These features are:
Hyperledger Fabric has seen a lot of implementation and is used widely in industries like banking and finance, international trade, and the Internet of Things. Hyperledger Fabric comprises a lot of components, such as endorsers, committers, and databases.
To interact in a Hyperledger Fabric network, chain codes (also known as smart contracts) are used. These smart contracts can be written in different programming languages, including Go, Node.js, and Java.
Hyperledger Fabric stores the state of transactions carried out by chain codes in databases. There are two main types of records stored by an Hyperledger Fabric network:
In this article, we are going to discuss how to choose between CouchDB and LevelDB databases as your world state database, covering the following topics:
Hyperledger Fabric only provides support for LevelDB and CouchDB and does not provide support for databases like PostgreSQL, MongoDB, or MySQL. A discussion in this Hyperledger forum states that, in order to provide support for pluggable databases, many changes would have to be made to the network and database itself. The project has been removed from Hyperledger’s development pipeline for the time being.
However, there are still ways to set up a database like PostgreSQL as your state database. You can fork the Fabric project and plugin a database like PostgreSQL, MySQL, or MongoDB by following these instructions. This example from IBM also shows a method you can use to set up PostgreSQL in your Hyperledger Fabric project.
The LevelDB database is a fast database that allows you to store key-value pairs. The LevelDB database was written at Google by Sanjay Ghemawat and Jeff Dean, and is currently the only database used by Hyperledger Fabric for storing transaction logs. As previously mentioned, it is also the default database used for storing the world state in Hyperledger Fabric.
LevelDB key-value pairs are stored in arbitrary byte arrays. LevelDB provides support for only
Key range, and composite key queries, i.e.,
GET(key, value), and
There is no support for SQL queries, indexes, or relational data models, as LevelDB is not a SQL database.
GET(Key, Value), and
Delete(Key), which makes LevelDB less complex to use
GET(key, value), and Delete(key)
The CouchDB database is an open-source, document-oriented database implemented in Erlang that collects and stores data in JSON format. Hyperledger Fabric users can replace their default LevelDB world state database with a CouchDB database, which is also the only available alternative.
CouchDB supports indices and pagination. You can also make queries based on keys, as with the LevelDB database.
POST) against your data
Before you choose a state database, you should know that you must decide on a database because Hyperledger Fabric doesn’t allow you to change the database after the Hyperledger Fabric network has been launched.
If you are running a simple Hyperledger Fabric project with a low volume of transactions, LevelDB’s ease of use and speed makes it very preferable to use.
However, for more complex projects, it is preferable to use a CouchDB database. CouchDB has all the features of the LevelDB database, such as getting and setting data based on keys, but also provides access to additional features, like storing data in a JSON format, indices, issuing queries, pagination, etc., all of which make working with data easier.
The features provided by CouchDB make it easier to manage a Hyperledger Fabric network with high volumes of transactions. CouchDB also makes it easier to complete the auditing and reporting requirements required in a modern organization running a Hyperledger Fabric network.
In this article, we talked about the world state database options available in Hyperledger Fabric, CouchDB and LevelDB. We explained the advantages and limitations of each database and we discussed how to pick a database for your next Hyperledger Fabric project.
LogRocket is like a DVR for web and mobile apps, recording everything that happens in your web app or site. Instead of guessing why problems happen, you can aggregate and report on key frontend performance metrics, replay user sessions along with application state, log network requests, and automatically surface all errors.
Modernize how you debug web and mobile apps — Start monitoring for free.
ElectricSQL is a cool piece of software with immense potential. It gives developers the ability to build a true local-first application.
Leptos is an amazing Rust web frontend framework that makes it easier to build scalable, performant apps with beautiful, declarative UIs.
We spoke with Dom about his approach to balancing innovation with handling tech debt and to learn how he stays current with technology.