Saturday, August 16, 2025

AWS DynamoDB: A NoSQL Database for High-Performance Applications



Are you building an application that needs to handle millions of users, massive amounts of data, and consistently deliver lightning-fast performance? If so, traditional relational databases might be holding you back. Welcome to Amazon DynamoDB, a key-value and document database that changes the game. Unlike a traditional database that can slow down under heavy load, DynamoDB is engineered for internet-scale applications, offering unparalleled performance and virtually unlimited scalability.

In this comprehensive guide, we'll dive deep into DynamoDB. We'll explore its core features, understand its internal architecture, and show you how it's the perfect fit for modern, high-traffic applications. From understanding its a key features and benefits to designing tables and writing code, you'll gain the knowledge you need to master this powerful service.

1. What is an Amazon DynamoDB Service?

Amazon DynamoDB is a fully managed, serverless NoSQL database service offered by AWS. It's designed for applications that require consistent, single-digit millisecond latency at any scale. As a managed service, DynamoDB abstracts away the administrative burden of running a database, including:

  • Server Provisioning: You don't need to manage servers, storage, or networking.

  • Scaling: It automatically scales to accommodate your workload.

  • Patching and Maintenance: AWS handles all software updates and security patches.

  • High Availability: Data is automatically replicated across multiple Availability Zones to ensure high availability and durability.

DynamoDB uses a key-value and document data model, making it ideal for a wide range of use cases from web and mobile apps to IoT and gaming.

2. Key Features of Amazon DynamoDB

DynamoDB's strength lies in its powerful feature set, built for speed and reliability.

  • Serverless and Fully Managed: There are no servers to provision, patch, or manage. You can focus entirely on your application logic.

  • Automatic Scaling: DynamoDB tables can automatically adjust throughput capacity to handle fluctuations in application traffic. You can choose between on-demand and provisioned capacity modes.

  • Performance at Any Scale: DynamoDB's distributed architecture ensures consistent, single-digit millisecond latency, even as your tables grow to petabytes of data and handle millions of requests per second.

  • Global Tables: For globally distributed applications, you can enable DynamoDB Global Tables to provide active-active replication of your data across multiple AWS regions, providing low-latency access to users worldwide.

  • Secondary Indexes: DynamoDB allows you to create Global Secondary Indexes (GSIs) and Local Secondary Indexes (LSIs) to query your data using attributes other than the primary key, giving you more flexibility in your access patterns.

  • Time to Live (TTL): This feature automatically expires and deletes items from your tables after a specific period, helping you reduce storage costs and manage data lifecycle.

  • ACID Transactions: DynamoDB provides native, server-side support for ACID (Atomicity, Consistency, Isolation, and Durability) transactions, allowing you to perform all-or-nothing changes to multiple items within and across tables.

3. Explain Internal Architecture on Amazon DynamoDB



Understanding the internal architecture of DynamoDB helps you design your tables for optimal performance.

  • Partitions: At its core, DynamoDB's data is partitioned across multiple physical servers. A partition is a unit of storage and processing capacity. DynamoDB automatically splits your data into partitions to distribute the load evenly. Each partition can handle a specific amount of read and write throughput.

  • Primary Key: Every item in a DynamoDB table must have a primary key to uniquely identify it. This key consists of a partition key and an optional sort key.

  • Partition Key Hashing: When you write an item to a table, DynamoDB calculates a hash of the partition key value. This hash value determines which partition the item will be stored in. A good partition key is crucial for distributing your data and traffic evenly across partitions, preventing "hot partitions" where a single partition receives a disproportionate amount of requests and gets throttled.

  • Replication and Consistency: DynamoDB automatically replicates each partition to at least three different Availability Zones within a region for fault tolerance. For each partition, there's a leader and follower model to maintain consistency. When you perform a write, it's synchronously replicated to all replicas. This ensures durability and high availability.

4. What are the benefits of Amazon DynamoDB and how is it different from traditional RDS?

DynamoDB and traditional relational databases like Amazon RDS are both powerful, but they are built for different purposes.

Feature | Amazon DynamoDBAmazon RDS

Data ModelKey-value, Document (NoSQL) | Relational (SQL)

SchemaFlexible, Schema-less | Strict, Predefined Schema

ScalabilityHorizontal (virtually unlimited) | Vertical (instance-size based) & Horizontal (Read Replicas)

PerformancePredictable, single-digit millisecond latency at any scale. | Can be optimized for high performance but can face bottlenecks at massive scale due to joins.

QueryingSimple, key-based queries. Lacks complex joins. | Complex, multi-table joins, subqueries, and aggregations.

ManagementFully managed, serverless. No server administration. | Managed service but requires some capacity planning and instance management.

Key Benefits of DynamoDB:

  • Unmatched Scalability: DynamoDB's horizontal scaling is a game-changer. It can handle petabytes of data and millions of requests per second without you needing to manually shard your database.

  • Cost-Effective for Variable Workloads: With on-demand capacity, you only pay for what you use, making it incredibly cost-efficient for unpredictable or spiky traffic.

  • Operational Simplicity: The fully managed nature of the service significantly reduces operational overhead. No more patching, backups, or server maintenance.

  • Ideal for Agile Development: The flexible, schema-less data model allows you to evolve your application's data structure without performing costly schema migrations.

5. Compare Amazon DynamoDB with Azure and Google Cloud Services

Amazon DynamoDB is a market leader, but it's important to know how it compares to its main competitors.

Feature | Amazon DynamoDBAzure Cosmos DB | Google Cloud Firestore

ModelKey-value, Document | Multi-model (key-value, document, graph, columnar)Document (collection-document)

PerformanceSingle-digit millisecond latency with Global Tables for multi-region. | Single-digit millisecond latency worldwide.Low-latency reads and writes.

Global ScaleGlobal Tables for active-active replication. | Built-in multi-region replication and multi-master write capabilities.Multi-region support with automatic data replication.

PricingOn-demand or Provisioned. Billed per read/write unit. | Request Units (RUs) for all operations. Billed for RUs and storage.Pay-per-document read/write. Billed for operations, storage, and networking.

Key DifferentiatorDynamoDB's core focus on performance at scale and its deep integration with the AWS ecosystem.Cosmos DB's multi-model API support (e.g., MongoDB, Cassandra, SQL) and its global, multi-master architecture.Firestore's real-time data synchronization and client-side SDKs, making it a favorite for mobile and web app development.

6. Hard Limits and Misconceptions on Amazon DynamoDB

Even though DynamoDB is highly flexible, it has specific design principles and limitations you must be aware of.

  • Misconception: DynamoDB can replace any database. DynamoDB is a NoSQL database, not a drop-in replacement for a relational one. It's not designed for complex queries with joins. If your application's primary access patterns are unknown or require complex aggregations and joins, a traditional RDBMS might be a better choice.

  • Misconception: On-Demand capacity is always cheaper. For predictable, steady-state workloads, Provisioned Capacity with auto-scaling can often be more cost-effective than On-Demand. On-Demand is best for unpredictable or spiky traffic.

  • Hard Limit: Item Size: The maximum size of an item in a DynamoDB table is 400 KB. If you need to store larger items, it's a best practice to store the data in Amazon S3 and save the S3 object key in your DynamoDB item.

  • Hard Limit: Partition Key Cardinality: Your partition key design is critical. If your partition keys are not diverse enough, you can create a hot partition, which can lead to throttling, even if your overall table capacity is not exceeded.

  • Misconception: You don't need to model your data. Data modeling is even more critical in DynamoDB than in an RDBMS. You must design your table schema based on your application's access patterns and queries.

7. Top 10 Real-World Use Cases on Amazon DynamoDB

  1. Web and Mobile Applications: Used for user profiles, session data, leaderboards, and other metadata due to its low latency and high scalability.

  2. Gaming: Powers real-time game leaderboards, player data, and session states, handling millions of concurrent requests.

  3. Ad-Tech: Stores user profiles and clickstream data for real-time bidding and ad personalization.

  4. IoT: Ingests and stores time-series data from millions of sensors and connected devices.

  5. E-commerce: Manages shopping carts, product catalogs, and customer order history.

  6. Serverless Architectures: Acts as the backend database for AWS Lambda functions, providing a scalable, low-latency data store without server management.

  7. SaaS Applications: Manages multi-tenant data, where each tenant's data is isolated and accessed efficiently.

  8. Media and Entertainment: Powers media streaming services by storing user viewing history, content metadata, and playback state.

  9. Financial Services: Stores real-time transactional data for financial applications and trading platforms.

  10. Log Ingestion: Ingests and stores high-volume logs from various applications for analysis and monitoring.

8. Design DynamoDB tables and perform CRUD operation

Table Design and Indexes

The most crucial step in using DynamoDB is designing your table schema based on your query patterns. Let's design a table for a simple e-commerce platform. Our main access patterns are:

  1. Fetch a specific order by order_id.

  2. Get all orders for a specific user.

Table Design:

  • Table Name: ECommerceOrders

  • Primary Key:

    • Partition Key: pk (e.g., USER#<user_id>)

    • Sort Key: sk (e.g., ORDER#<order_id>)

  • Global Secondary Index (GSI):

    • GSI Name: GSI1

    • Partition Key: gsi1_pk (e.g., ORDER#<order_id>)

    • Sort Key: gsi1_sk (e.g., PRODUCT#<product_id>)

This design allows for both fetching a specific user's orders (using the primary key) and querying orders based on other attributes like a product (using the GSI).

CRUD Operations (Python with Boto3)

Let's use Python's Boto3 library to perform common operations.

Create an Item (PutItem)

This code snippet shows how to add a new order.

Python

import boto3

dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('ECommerceOrders')

response = table.put_item(
    Item={
        'pk': 'USER#123',
        'sk': 'ORDER#A1B2C3D4',
        'order_date': '2025-08-16',
        'total_amount': 99.99,
        'status': 'Processing',
        'gsi1_pk': 'ORDER#A1B2C3D4',
        'gsi1_sk': 'PRODUCT#P567',
        'items': [
            {'product_id': 'P567', 'name': 'Laptop', 'price': 99.99}
        ]
    }
)
print("PutItem succeeded:", response)

Read an Item (GetItem)

To retrieve a specific order.

Python

response = table.get_item(
    Key={
        'pk': 'USER#123',
        'sk': 'ORDER#A1B2C3D4'
    }
)
item = response.get('Item')
print("GetItem succeeded:", item)

Query with Pagination and Secondary Index

To get all orders for a specific user, we query the main table. If the result set is large, we use pagination.

Python

from boto3.dynamodb.conditions import Key

# Query the main table to get all orders for a user
response = table.query(
    KeyConditionExpression=Key('pk').eq('USER#123')
)

print("Orders for USER#123:", response['Items'])
last_key = response.get('LastEvaluatedKey')
while 'LastEvaluatedKey' in response:
    response = table.query(
        KeyConditionExpression=Key('pk').eq('USER#123'),
        ExclusiveStartKey=response['LastEvaluatedKey']
    )
    print("More orders:", response['Items'])

# Query the GSI to find orders for a specific product
gsi_response = table.query(
    IndexName='GSI1',
    KeyConditionExpression=Key('gsi1_pk').eq('ORDER#A1B2C3D4')
)
print("Orders for product P567 via GSI:", gsi_response['Items'])

Atomic and Conditional Writes

Use ConditionExpression to prevent overwriting an item if a condition is not met (e.g., optimistic locking).

Python

from botocore.exceptions import ClientError

try:
    table.update_item(
        Key={
            'pk': 'USER#123',
            'sk': 'ORDER#A1B2C3D4'
        },
        UpdateExpression="SET #s = :new_status",
        ConditionExpression="attribute_exists(pk) AND #s = :old_status",
        ExpressionAttributeNames={'#s': 'status'},
        ExpressionAttributeValues={
            ':new_status': 'Shipped',
            ':old_status': 'Processing'
        }
    )
    print("Update succeeded!")
except ClientError as e:
    if e.response['Error']['Code'] == 'ConditionalCheckFailedException':
        print("Conditional update failed. The item has been modified by another process.")
    else:
        raise

Enable On-Demand Capacity Mode

You can switch to on-demand capacity via the console or CLI. For a new table, you can specify it at creation.

Bash

aws dynamodb create-table \
    --table-name YourTable \
    --billing-mode PAY_PER_REQUEST \
    --attribute-definitions AttributeName=pk,AttributeType=S \
    --key-schema AttributeName=pk,KeyType=HASH

Secure DynamoDB Tables using IAM Policies

IAM policies control access to your DynamoDB tables with fine-grained permissions.

JSON

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AllowReadOnSpecificTable",
            "Effect": "Allow",
            "Action": [
                "dynamodb:GetItem",
                "dynamodb:Query",
                "dynamodb:Scan"
            ],
            "Resource": "arn:aws:dynamodb:us-east-1:123456789012:table/ECommerceOrders"
        },
        {
            "Sid": "AllowWriteToSpecificItem",
            "Effect": "Allow",
            "Action": [
                "dynamodb:PutItem",
                "dynamodb:UpdateItem",
                "dynamodb:DeleteItem"
            ],
            "Resource": "arn:aws:dynamodb:us-east-1:123456789012:table/ECommerceOrders",
            "Condition": {
                "ForAllValues:StringEquals": {
                    "dynamodb:LeadingKeys": ["USER#${aws:username}"]
                }
            }
        }
    ]
}

This policy allows a user to read from the ECommerceOrders table but only write to items where the partition key matches their username, a common practice for multi-tenant applications.

9. Conclusion

Amazon DynamoDB is a powerful, fully managed NoSQL database service that provides the performance and scalability needed for modern, internet-scale applications. Its serverless nature, flexible data model, and built-in features like Global Tables and Transactions make it a go-to choice for a wide range of use cases. By understanding its architecture and designing your tables based on your application's access patterns, you can unlock its full potential.

Ready to supercharge your application? Start designing your first DynamoDB table today!

10. Recommended AWS Blog Links on Amazon DynamoDB

11. Good Amazon DynamoDB Knowledge Practice Questions

  1. What is the primary key in a DynamoDB table?

    a) A column that is always unique and cannot be empty.

    b) It can be a simple partition key or a composite partition key and sort key.

    c) It is the same as the primary key in a relational database.

    d) It is an optional attribute for a table.

    • Answer: b) It can be a simple partition key or a composite partition key and sort key. A simple primary key is just a partition key, while a composite primary key combines a partition key and a sort key.

  2. What is a "hot partition" in DynamoDB?

    a) A partition that is physically located on a hot server.

    b) A partition that receives a disproportionately high volume of read or write requests, leading to throttling.

    c) A partition that stores data related to temperature sensors.

    d) A partition that is located in a tropical AWS region.

    • Answer: b) A partition that receives a disproportionately high volume of read or write requests, leading to throttling. This is a common performance bottleneck that can be avoided with good key design.

  3. Which capacity mode is best for a new application with unpredictable traffic?

    a) Provisioned Capacity

    b) On-Demand Capacity

    c) Reserved Capacity

    d) Hybrid Capacity

    • Answer: b) On-Demand Capacity. On-demand mode scales automatically to handle spiky traffic and you only pay for the requests you use.

  4. What is a DynamoDB Global Secondary Index (GSI)?

    a) An index with the same partition key as the base table but a different sort key.

    b) An index with a different partition key from the base table.

    c) A global index that can be queried from any AWS region.

    d) An index that is strongly consistent with the base table.

    • Answer: b) An index with a different partition key from the base table. A GSI allows you to query your data using an alternate primary key and is eventually consistent with the base table.

  5. What is the maximum size of a single item in a DynamoDB table?

    a) 1 MB

    b) 1 GB

    c) 400 KB

    d) Unlimited

    • Answer: c) 400 KB. This is a hard limit. For larger items, you should store the data in S3 and reference the S3 object key in your DynamoDB item.

  6. Which DynamoDB feature helps in automatically removing old data from a table to reduce storage costs?

    a) Automated Backups

    b) TTL (Time to Live)

    c) On-Demand Capacity

    d) DynamoDB Streams

    • Answer: b) TTL (Time to Live). This feature allows you to define a timestamp attribute on items, and DynamoDB will automatically delete them once the timestamp is reached.

  7. How can you secure a DynamoDB table to grant specific users read-only access to a table?

    a) By using a Security Group.

    b) By using a NACL.

    c) By creating an IAM policy with dynamodb:GetItem and dynamodb:Query permissions on the table.

    d) By setting the table to public access.

    • Answer: c) By creating an IAM policy with dynamodb:GetItem and dynamodb:Query permissions on the table. IAM policies are the primary way to manage access to DynamoDB resources.

  8. What is the main difference in data consistency between a base table read and a Global Secondary Index (GSI) read?

    a) Base table reads are always eventually consistent, while GSI reads are strongly consistent.

    b) Base table reads can be strongly or eventually consistent, while GSI reads are always eventually consistent.

    c) Both are always strongly consistent.

    d) Both are always eventually consistent.

    • Answer: b) Base table reads can be strongly or eventually consistent, while GSI reads are always eventually consistent. Data is asynchronously replicated from the base table to the GSI.

  9. Which operation would you use to retrieve multiple items from a DynamoDB table by their primary key in a single API call?

    a) Query

    b) Scan

    c) GetItem

    d) BatchGetItem

    • Answer: d) BatchGetItem. This operation allows you to retrieve up to 100 items from one or more tables in a single request.

  10. What is a major advantage of a DynamoDB Global Table?

    a) It allows you to perform cross-region queries.

    b) It provides multi-master, active-active replication across multiple regions.

    c) It is a cheaper alternative to a single-region table.

    d) It is automatically enabled for all tables.

    • Answer: b) It provides multi-master, active-active replication across multiple regions. This allows for low-latency writes and reads for globally distributed users.

  11. What is the purpose of a Sort Key in a DynamoDB table?

    a) To sort the items by creation date.

    b) To enable efficient range queries on items with the same partition key.

    c) To ensure that the partition key is unique.

    d) To enable full-text search.

    • Answer: b) To enable efficient range queries on items with the same partition key.

  12. Which of the following is NOT a responsibility of a DynamoDB user?

    a) Designing the primary key for a table.

    b) Deciding on the capacity mode (On-Demand vs. Provisioned).

    c) Managing the underlying servers and operating system.

    d) Writing application code to perform CRUD operations.

    • Answer: c) Managing the underlying servers and operating system. This is a core part of the managed service that AWS handles.

  13. Which DynamoDB operation is the least efficient for querying a large table?

    a) Query

    b) GetItem

    c) Scan

    d) BatchGetItem

    • Answer: c) Scan. A Scan operation reads every item in the table, which is inefficient and costly for large datasets. It should be avoided for most production use cases.

  14. What is a DynamoDB Stream?

    a) A stream of real-time video data.

    b) A change data capture (CDC) feature that records item-level modifications.

    c) A feature for streaming data from a DynamoDB table to Amazon S3.

    d) A feature that allows you to store large files in DynamoDB.

    • Answer: b) A change data capture (CDC) feature that records item-level modifications. DynamoDB Streams are often used to trigger AWS Lambda functions for event-driven architectures.

  15. To handle a transaction that modifies multiple items within or across DynamoDB tables, which API would you use?

    a) BatchWriteItem

    b) TransactWriteItems

    c) UpdateItem

    d) PutItem

    • Answer: b) TransactWriteItems. This API ensures that a group of write operations on multiple items and tables either all succeed or all fail together.

  16. In Provisioned Capacity mode, what does one Write Capacity Unit (WCU) represent?

    a) One write operation per second for an item up to 1 KB.

    b) One write operation per second for an item up to 4 KB.

    c) One write operation per second for an item of any size.

    d) One strongly consistent write operation.

    • Answer: a) One write operation per second for an item up to 1 KB.

  17. Which of the following is NOT a benefit of using DynamoDB?

    a) Automatic scaling

    b) Support for complex SQL joins

    c) High availability

    d) Managed backups

    • Answer: b) Support for complex SQL joins. DynamoDB is a NoSQL database and does not support joins.

  18. Which DynamoDB feature is designed to reduce latency for read-heavy workloads?

    a) DynamoDB Streams

    b) Time to Live (TTL)

    c) DynamoDB Accelerator (DAX)

    d) Global Tables

    • Answer: c) DynamoDB Accelerator (DAX). DAX is an in-memory cache that provides microsecond read performance for read-heavy workloads.

  19. What is the purpose of an IAM condition key dynamodb:LeadingKeys?

    a) To specify a sort key for a query.

    b) To grant or deny permissions to an item based on the partition key.

    c) To define the primary key of a table.

    d) To manage DynamoDB Streams.

    • Answer: b) To grant or deny permissions to an item based on the partition key. This allows for fine-grained, item-level access control.

  20. When using Query with pagination, what does LastEvaluatedKey represent?

    a) The last key returned in the entire query result set.

    b) The primary key of the last item in the current page of results.

    c) The last sort key in the result set.

    d) The primary key of the item you want to start the next query from.

    • Answer: b) The primary key of the last item in the current page of results. You pass this key to the ExclusiveStartKey parameter in the next query to get the next page of results.

  21. How can you ensure that a write operation only succeeds if an item with a specific attribute value exists?

    a) Use ConditionalCheckFailedException.

    b) Use a ConditionExpression.

    c) Use a Query operation.

    d) Use a TransactWriteItems operation.

    • Answer: b) Use a ConditionExpression. This allows you to specify a condition that must be met for the write to succeed.

  22. What is the main benefit of using a composite primary key in DynamoDB?

    a) It makes every item in the table unique.

    b) It allows for more efficient range queries on the sort key.

    c) It makes it easier to migrate data from a relational database.

    d) It allows you to store more data in a single item.

    • Answer: b) It allows for more efficient range queries on the sort key.

  23. Which DynamoDB operation should you use for a full table scan?

    a) GetItem

    b) Query

    c) Scan

    d) BatchGetItem

    • Answer: c) Scan. A Scan operation is the correct API to perform a full table scan, but it should be used with caution due to its cost and inefficiency.

  24. In the context of Query, what is a KeyConditionExpression used for?

    a) To filter the results of a scan.

    b) To specify the partition key and sort key for the query.

    c) To apply a condition on a non-key attribute.

    d) To define the primary key of the table.

    • Answer: b) To specify the partition key and sort key for the query. A Query operation must always specify a partition key.

  25. When you define a Global Secondary Index, what is the default projection type?

    a) KEYS_ONLY

    b) INCLUDE

    c) ALL

    d) ALL_ATTRIBUTES

    • Answer: a) KEYS_ONLY. By default, only the keys of the base table and the GSI are projected into the index, which is the most cost-effective option.

  26. What is the purpose of ExpressionAttributeNames in a DynamoDB API call?

    a) To define the names of attributes in the table.

    b) To use a placeholder for an attribute name to avoid a conflict with a DynamoDB reserved word.

    c) To specify the names of the primary key attributes.

    d) To list all the attributes in an item.

    • Answer: b) To use a placeholder for an attribute name to avoid a conflict with a DynamoDB reserved word.

  27. What is the main difference between a Local Secondary Index (LSI) and a GSI?

    a) An LSI can have a different partition key from the base table, while a GSI must have the same partition key.

    b) An LSI can only be created at table creation, while a GSI can be created after.

    c) An LSI is eventually consistent, while a GSI is strongly consistent.

    d) An LSI has a separate partition key from the base table.

    • Answer: b) An LSI can only be created at table creation, while a GSI can be created after. LSI's share the same partition key as the base table.

  28. How does DynamoDB ensure durability of data?

    a) By writing data to a single server in the primary region.

    b) By replicating data to a minimum of three Availability Zones.

    c) By writing data to a single server and then backing it up to S3.

    d) By storing a single copy of data on a solid-state drive.

    • Answer: b) By replicating data to a minimum of three Availability Zones. This ensures that even if an entire AZ goes down, your data remains safe and available.

  29. What is a potential cost issue when using DynamoDB Streams with AWS Lambda?

    a) DynamoDB Streams are always free.

    b) You are charged for the data transfer from DynamoDB to Lambda.

    c) You are charged for Lambda invocations, which can be high with a high volume of writes.

    d) There is no cost for this integration.

    • Answer: c) You are charged for Lambda invocations, which can be high with a high volume of writes.

  30. Which of the following is an example of a good partition key for an IoT application?

    a) device_id

    b) A random UUID

    c) A timestamp

    d) The device's location

    • Answer: a) device_id. Using a high-cardinality attribute like device_id ensures that data is distributed evenly across partitions, preventing hot partitions.

  31. What is the main benefit of using BatchGetItem over multiple GetItem calls?

    a) It is always cheaper and more efficient due to fewer API calls.

    b) It provides strongly consistent reads.

    c) It is the only way to read from multiple tables at once.

    d) It is required for reading more than 10 items.

    • Answer: a) It is always cheaper and more efficient due to fewer API calls. It reduces the round-trip network overhead.

  32. When would you use DynamoDB Accelerator (DAX)?

    a) For a write-heavy application.

    b) To process batch jobs.

    c) For a read-heavy application that requires microsecond latency.

    d) To perform complex analytical queries.

    • Answer: c) For a read-heavy application that requires microsecond latency. DAX is an in-memory cache specifically designed to boost read performance.

  33. What is the purpose of UpdateExpression in a DynamoDB UpdateItem API call?

    a) To define a new attribute for an item.

    b) To specify the attributes to be modified and their new values.

    c) To update an item with a condition.

    d) To update a table's schema.

    • Answer: b) To specify the attributes to be modified and their new values.

  34. Which of the following is true about a Scan operation?

    a) It is a highly efficient operation for large tables.

    b) It can be paginated using LastEvaluatedKey.

    c) It must specify a partition key.

    d) It is the fastest way to get a single item.

    • Answer: b) It can be paginated using LastEvaluatedKey. While inefficient, it can be paginated to avoid overwhelming the application.

  35. What is the purpose of a ProjectionExpression in a Query or Scan operation?

    a) To specify the primary key to query on.

    b) To return only a subset of attributes from the matching items.

    c) To project a GSI.

    d) To perform a conditional write.

    • Answer: b) To return only a subset of attributes from the matching items. This reduces the amount of data transferred and can save costs.

  36. Which DynamoDB feature enables you to perform all-or-nothing operations on multiple items?

    a) Transactions

    b) Batch operations

    c) Atomic counters

    d) Conditional writes

    • Answer: a) Transactions. DynamoDB's transaction APIs (TransactGetItems, TransactWriteItems) ensure atomicity across multiple operations.

  37. What is the cost implication of using a Scan operation on a large table?

    a) It is free.

    b) It consumes a large number of read capacity units and can be very expensive.

    c) It is only billed for the number of items returned.

    d) It is more expensive than a Query.

    • Answer: b) It consumes a large number of read capacity units and can be very expensive. Every item in the table is read, regardless of the filter applied.

  38. What is the purpose of a DB Subnet Group in a DynamoDB context?

    a) DynamoDB does not use DB Subnet Groups.

    b) It is used to connect a DynamoDB table to an EC2 instance.

    c) It is a collection of private subnets for your DynamoDB table.

    d) It is used to define the public access for a DynamoDB table.

    • Answer: a) DynamoDB does not use DB Subnet Groups. This concept is specific to Amazon RDS.

  39. What is the maximum number of items that can be processed in a single TransactWriteItems operation?

    a) 100

    b) 25

    c) 10

    d) 50

    • Answer: b) 25. A single TransactWriteItems operation can process up to 25 items across different tables.

  40. How can you ensure that an item's data is consistent when it is read from a GSI?

    a) You cannot, GSIs are always eventually consistent.

    b) By using the ConsistentRead=True parameter in the query.

    c) By waiting for a few minutes before reading.

    d) By enabling DynamoDB Streams.

    • Answer: a) You cannot, GSIs are always eventually consistent. The ConsistentRead parameter only applies to the base table.

  41. What is the primary way to reduce the cost of a DynamoDB table with a predictable, steady workload?

    a) Use On-Demand capacity mode.

    b) Use a Local Secondary Index.

    c) Use Provisioned capacity with auto-scaling.

    d) Use a Scan operation.

    • Answer: c) Use Provisioned capacity with auto-scaling. This allows you to reserve a base level of throughput at a lower cost, while auto-scaling handles any unexpected spikes.

  42. What does the ConditionExpression attribute_not_exists(pk) do in a PutItem call?

    a) It prevents the write if the item already exists with the specified primary key.

    b) It creates a new attribute called pk.

    c) It updates an existing item.

    d) It checks if the item is empty.

    • Answer: a) It prevents the write if the item already exists with the specified primary key. This is useful for creating a new item without accidentally overwriting an old one.

  43. What is a "write sharding" strategy used for in DynamoDB?

    a) To increase the number of partitions.

    b) To split a large item into smaller ones.

    c) To distribute a high volume of writes for a single key across multiple partitions.

    d) To back up a table to S3.

    • Answer: c) To distribute a high volume of writes for a single key across multiple partitions. This is a best practice to avoid hot partitions.

  44. Which of the following data types is NOT supported for a primary key in DynamoDB?

    a) Number

    b) String

    c) Binary

    d) Set

    • Answer: d) Set. Primary keys must be of a scalar type (String, Number, or Binary).

  45. What is the main purpose of DynamoDB Streams in an event-driven architecture?

    a) To store the entire table's data.

    b) To provide a real-time, time-ordered log of all item-level changes.

    c) To enable complex analytical queries.

    d) To perform cross-region replication.

    • Answer: b) To provide a real-time, time-ordered log of all item-level changes. This log can then be consumed by services like AWS Lambda to trigger downstream actions.

  46. How does DynamoDB manage the data when you enable TTL?

    a) It deletes the item immediately after the TTL expires.

    b) It marks the item for deletion and deletes it asynchronously in the background.

    c) It archives the item to Amazon S3.

    d) The user must manually delete the item after its TTL expires.

    • Answer: b) It marks the item for deletion and deletes it asynchronously in the background. This process does not consume any of your provisioned capacity.

  47. What is a "projection" in the context of a DynamoDB secondary index?

    a) The process of creating an index.

    b) The set of attributes from the base table that are copied into the index.

    c) The process of performing a query on an index.

    d) The name of the index itself.

    • Answer: b) The set of attributes from the base table that are copied into the index.

  48. Which of the following is true about BatchWriteItem?

    a) It is a transactional operation.

    b) It can only write to a single table.

    c) It can perform up to 25 put or delete operations in a single call.

    d) It guarantees all items are written successfully.

    • Answer: c) It can perform up to 25 put or delete operations in a single call. It is not transactional and may return a list of unprocessed items.

  49. What is a major difference between a Query and a Scan operation?

    a) Query always returns more data than Scan.

    b) Query requires a partition key, while Scan does not.

    c) Scan can use secondary indexes, while Query cannot.

    d) Query is always more expensive than Scan.

    • Answer: b) Query requires a partition key, while Scan does not. A Query is targeted and efficient, whereas a Scan reads the entire table.

  50. What is a benefit of using DynamoDB over a self-hosted database on an EC2 instance?

    a) You have full control over the underlying server's OS.

    b) It is easier to set up a new instance.

    c) It is a serverless, managed service that requires minimal administration.

    d) It supports complex joins and subqueries.

    • Answer: c) It is a serverless, managed service that requires minimal administration. This is the main value proposition of DynamoDB.

No comments:

Post a Comment

GCP Cloud Quiz - quiz2 Question

Google cloud platform Quiz ☁️ Google cloud Platform Professional Certificati...