Databases
Amazon DynamoDB
A fully managed AWS key-value and document database with predictable latency and automatic scaling.
What it is
DynamoDB is a serverless NoSQL service from AWS. You do not manage servers: you create a table and AWS scales it and distributes data. Latency is typically single-digit milliseconds.
Each item has a partition key and optionally a sort key. Global and local secondary indexes give extra access patterns. Billing modes: on-demand or provisioned capacity.
The model demands designing access patterns up front, as in Cassandra. There are no joins and transactions are limited. In return you get huge scale with no administration.
Use it when
- Serverless apps on AWS Lambda with predictable latency.
- High loads with simple key-based access patterns.
- You do not want to administer a database.
Avoid it when
- Complex ad hoc queries and analytics: a SQL database.
- You need portability across clouds: the service is tied to AWS.
Key concepts
- Partition / sort key
- The item's primary key and ordering inside a partition.
- GSI / LSI
- Secondary indexes for other access patterns.
- Capacity modes
- On-demand or provisioned (RCU/WCU).
- Single-table design
- Several entities in one table around access patterns.
Example
Interview questions
1. How does Query differ from Scan?
Query reads items by partition key efficiently. Scan walks the whole table, slow and costly, so avoid it on the production path.
2. What is a hot partition?
When a large share of traffic hits one partition key and runs into its limits. Fix it with a better key distribution.
3. Why single-table design?
To fetch related entities in one query with no joins. The cost is a more complex model that is hard to change.
Comparisons with this technology
Related technologies
- AWSThe largest cloud platform, with hundreds of services from virtual machines and storage to databases, queues and ML.
- AWS LambdaAn AWS service that runs functions in response to events and bills only for execution time.
- Apache CassandraA distributed wide-column database with no single point of failure, built for massive write volumes.
- MongoDBThe most popular document NoSQL database, storing data as JSON-like documents (BSON).
- RedisRedis is a fast in-memory data store used for caching, queues, counters, sessions and leaderboards, with rich data structures.
Logos belong to their owners and are used for identification only. Icons: Simple Icons (CC0), Devicon (MIT).