본문 바로가기

AWS Database/AWS Other Database

Keyspaces (Cassandra)

Amazon Keyspaces - overview

 

  • A scalable, highly available, and fully-managed database service
  • Lets you run. your Cassandra workloads on AWS
  • Cassandra is an open-source, wide-column, NoSQL data store
  • Is serverless, so you pay for what you use + autoscaling
  • Supports thousands of requests per second with virtually unlimted throughput and storage
  • Compatible with the CQL (Cassandra Query Language) API
  • Security through IAM, VPC and KMS
  • Data is encrypted by default, supports encryption at rest and in transit
  • Supports continuous backups with PITR
  • All writes replicated three times across multiple AZs for durability and availability
  • Offers 99.99% availability SLA within Region with no scheduled downtime
  • Monitoring through CloudWatch, DDL actions logged with CloudTrail
  • USe cases: IoT device metadata / User profiles / Time-seriese data / Transaction data (e.g. ecommerce)

CQL (Cassandra Query Language)

 

  • You can CQL for interacting with Cassandra database (and with Keyspaces)
  • To run CQL queries, you can use:
    • CQL editor in the AWS Console
    • cqlsh client (CQL shell)
    • Cassandra client driver (programmatic access)

Migrating from Cassandra to Keyspaces

 

  • Export existing cluster data to CSV files
  • Import using cqlsh COPY command


Read and write consistency in Keyspaces

 

  • Two read consistency modes:
    • LOCAL_ONE consistency
    • LOCAL_QUORUM consistency
  • LOCAL_ONE optimizes for performance and availability by returning the first returned value from any storage replica
  • LOCAL_QUORUM optimizes for data correctness by requiring at least two replicas to return a value before it is returned to your application
  • All writes use LOCAL_QUORUM for durability

Keyspace pricing

 

On-demand mode Provisioned mode
Uses RRUs and WRUs (Read/Write request units) Use RCUs and WCUs (read/write capacity units)
You pay for the actual reads and writes You specify the number of reads and writes per second
Use with unpredictable application traffic Lets you optimize costs if you have predictable application traffic and can forecast capacity requirements in advance
1 RRU = one 4KB read with LOCAL_QUORUM consistency 1 RCU = one 4KB read with LOCAL_QUORUM consistency
1 RRU = two 4KB reads with LOCAL_ONE consistency 1 RCU = two 4KB reads with LOCAL_ONE consistency
1 WRU = one 1KB write with LOCAL_QUORUM consistency 1 WCU = one 1KB write with LOCAL_QUORUM consistency
  • If a query returns multiple rows, you are billed based on the aggregate size of the data returned
  • For example, if your query return four rows and each row has 2KB of data (8KB of data total), you are billed 2 RCUs using LOCAL_QUORUM consistency and 1 RCU using LOCAL_ONE consistency
  • Storage, backups and restore, and data transfer costs are additional