Cloud vendors not only provide infrastructure to easily develop applications, but they also come with new tools and resources that redefine how rapid applications development is even made faster. Selection of the database plays a major role in the application development. Cloud vendors are coming with purpose-built databases for specific use cases. One of the latest offerings is the ledger database. This is different from distributed ledger or blockchain. Quantum Ledger DB (QLDB) is the ledger database offered by amazon web services.
What is it?
The most common databases like SQL or NoSQL allow update and delete operations. However, some use cases demand not to have the update or delete operation. This can be achieved on the existing databases with additional care. The application development team uses different techniques to ensure the data lineage. These require lots of custom development and efforts from the team. Hence QLDB, which is purpose-built to build ledger-based applications.
Why need a ledger database?
- Unmodifiable record keeping
- Manage transactions effortlessly
What are the characteristics of a Ledger?
- Immutable change history
- Data integrity verification
- Easy to query the data
How is it different from Blockchain?
- Blockchain work on a consensus basis whereas ledger databases are purpose-built databases.
- Unlike the decentralized nature of the blockchain, Ledger databases are centralized and are purely for maintaining the source of truth.
- In the case of blockchain, no single entity owns the application but in a ledger database, there is a single entity that owns and controls all the data.
- There is no gas cost involved in recording a transaction like a blockchain. Also, the guarantee of a transaction going through is higher than the blockchain.
- Data redundancy and availability are higher in blockchain because of the distributed nature compared to the centralized ledger databases.
How can the ledger be implemented otherwise using a standard database?
- Audit tables
- Transaction logs
- Trust in permissions and policies
When to use QLDB?
AWS QLDB comes in handy when we have to record transactions as it happens. Also, manage to show the total balance and history whenever needed without having to worry about setting up the infrastructure or scaling it as the demand grows.
How does it work?
A) Journal – Immutable transaction log with blocks of data. Data are chained together in hashes to provide cryptographically verifiable outputs
B) Current – This is like a table that we would query to get the current balance or state of the account
C) History – This is like a table we would query to see the history of the account over a certain period
Other general info –
Durability – Multi-AZ with one copy per AZ and ensures full recovery in case of AZ failures.
High availability – Multi-AZ within the region and in case of one zone failure we can continue to operate QLDB.
Security – By default, all data in transit and at rest is encrypted.
What are the different use cases?
- System of records
- Supply chain
How much would it cost to use QLDB?
QLDB is priced based on 5 parameters –
|1||Write I/Os||$0.70 – $0.854 Per 1 million request|
|2||Read I/Os||$0.136 – $0.166 Per 1 million request|
|3||Journal storage rate||$0.03 – $0.037 Per GB-month|
|4||Indexed storage rate||$0.25 – $0.305 Per GB-month|
|5||Data transfer||Transfer IN from the internet – Free|
Transfer OUT to internet – $0.09 – $0.05 Per GB
How to choose the region for QLDB?
- Currently, QLDB is available in 3 regions within the US. All of them are priced at the same rate. However, US East (Northern Virginia) Region has the higher availability zones. As QLDB currently does not support backup and recovery, choosing the region with higher AZ would be a good option.
- Outside of the US, QLDB is currently available in 4 Asia Pacific, 3 Europe, and 1 Canada regions. All these regions are priced a bit higher compared to the US. So depending on the customer base, other regions can be used.
How to optimize the query performance in QLDB (AWS recommended best practices)?
- Use indexes to avoid full table scans
- Making transactions idempotent
- Manage concurrent sessions
- Understanding the transaction timeout of 30 seconds
- Optimal query patterns and query patterns to avoid
- Managing the performance using other AWS resources
What are the advantages?
- Immutable and transparent –
- Sequence record of every read
- Append only, no delete
- Data is cryptographically verifiable –
- Uses the same methodology as a blockchain framework
- Uses SHA-256 to generate the hashed output file
- Easy to use –
- SQL-like query language called PartiQL
- ACID complaint
- Serverless –
- No need to worry about provisioning
- Auto scales with application
- Faster than blockchain –
- No consensus since centralized behavior
- No gas cost –
- Guarantee of recording the transaction without gas cost
What are the disadvantages?
- QLDB currently does not support a backup or restore feature as of now. Export to S3 can be done periodically to maintain a backup. S3 lifecycle can help in archiving the old data depending on the need.
- Amazon QLDB does not support a point-in-time restore feature as of now.
- QLDB does not support cross-region replication. However, export to S3 and S3 buckets can be configured for cross-region replication.
- For encryption, currently, customer-managed CMKs (Customer Master Keys) are not supported. Amazon QLDB uses AWS-owned keys to encrypt customer data.
- Designing the database with proper index and query patterns at an earlier stage is important to avoid significant performance problems, including query latency, transaction timeouts, and concurrency conflicts in the future.
Share your thoughts on the ledger database and your implementation of it.