Purpose-built Ledger Database – AWS QLDB

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?

  1. Unmodifiable record keeping
  2. Manage transactions effortlessly

What are the characteristics of a Ledger?

  1. Immutable change history
  2. Data integrity verification
  3. Easy to query the data

How is it different from Blockchain?

  1. Blockchain work on a consensus basis whereas ledger databases are purpose-built databases.
  2. Unlike the decentralized nature of the blockchain, Ledger databases are centralized and are purely for maintaining the source of truth.
  3. 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.
  4. 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.
  5. Data redundancy and availability are higher in blockchain because of the distributed nature compared to the centralized ledger databases.
NIST – Determine whether to use Blockchain or not

How can the ledger be implemented otherwise using a standard database?

  1. Audit tables
  2. Transaction logs
  3. 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

Key elements in QLDB

Transactions – Cryptographically chained together

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?

  1. System of records
  2. Supply chain
  3. Healthcare
  4. Registrations
  5. Fintech

How much would it cost to use QLDB?

QLDB is priced based on 5 parameters –

1Write I/Os$0.70 – $0.854 Per 1 million request
2Read I/Os$0.136 – $0.166 Per 1 million request
3Journal storage rate$0.03 – $0.037 Per GB-month
4Indexed storage rate$0.25 – $0.305 Per GB-month
5Data transferTransfer IN from the internet – Free
Transfer OUT to internet – $0.09 – $0.05 Per GB
QLDB pricing based on all the available regions

How to choose the region for QLDB?

  1. 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.
  2. 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)?

  1. Use indexes to avoid full table scans
  2. Making transactions idempotent
  3. Manage concurrent sessions
  4. Understanding the transaction timeout of 30 seconds
  5. Optimal query patterns and query patterns to avoid
  6. Managing the performance using other AWS resources

What are the advantages?

  1. Immutable and transparent –
    • Sequence record of every read
    • Append only, no delete
  2. Data is cryptographically verifiable –
    • Uses the same methodology as a blockchain framework
    • Uses SHA-256 to generate the hashed output file
  3. Easy to use –
    • SQL-like query language called PartiQL
    • ACID complaint
  4. Serverless –
    • No need to worry about provisioning
    • Auto scales with application
  5. Faster than blockchain –
    • No consensus since centralized behavior
  6. No gas cost –
    • Guarantee of recording the transaction without gas cost

What are the disadvantages?

  1. 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.
  2. Amazon QLDB does not support a point-in-time restore feature as of now.
  3. QLDB does not support cross-region replication. However, export to S3 and S3 buckets can be configured for cross-region replication.
  4. For encryption, currently, customer-managed CMKs (Customer Master Keys) are not supported. Amazon QLDB uses AWS-owned keys to encrypt customer data.
  5. 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.

Happy learning!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.