What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use DynamoDB Streams and a Lambda event-source mapping when a DynamoDB write should trigger asynchronous, near-real-time work. The table remains the system of record; the stream emits INSERT, MODIFY, and REMOVE change records; Lambda polls batches and invokes one or more consumers. This is managed change-data capture, not a synchronous database trigger or a durable event bus. Design for at-least-once delivery, eventual consistency, retries, and the stream’s 24-hour retention window.

The event flow

Consider an order API. The command is “create order.” The application writes the order item, and DynamoDB Streams records the resulting state change. Separate consumers can then update a read model, send a notification, or publish an integration event without coupling those operations to the request.

POST /orders
   |
   v
Lambda: CreateOrder
   |
   v
DynamoDB: Orders table
   |
   v
DynamoDB Stream (NEW_AND_OLD_IMAGES)
   |
   v
Lambda: ProjectOrder
   +--> OrderSummary table
   +--> SQS or EventBridge

Lambda services such as API Gateway or EventBridge use push invocation. DynamoDB Streams uses a pull integration: an event-source mapping polls stream shards and invokes the function with batches. See AWS’s event-driven Lambda guidance and the DynamoDB integration documentation.

Keep transactional business state in the write model. Consumers should build projections or perform asynchronous side effects, and must not assume that another consumer has already finished. Multiple mappings and functions can consume a stream; for single-Region, non-global tables, AWS documents support for up to two Lambda functions reading a shard concurrently, subject to throughput and concurrency limits.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When this pattern fits—and when it does not

  • It fits when DynamoDB is the source of truth, reactions are asynchronous, near-real-time processing is sufficient, and projections can be rebuilt.
  • It is a poor sole event backbone when events must be replayed for months, global ordering is required, a side effect must commit atomically with the write, or processing exceeds Lambda’s 15-minute maximum.
  • DynamoDB Streams retains records for only 24 hours, so it is not a complete event-sourcing history or archival log. See the Streams overview.

Configure the stream deliberately

Choose the smallest stream view that supplies the consumer:

View Contents Typical use
KEYS_ONLY Keys Consumers that fetch current state themselves
NEW_IMAGE Item after the change Read-model updates
OLD_IMAGE Item before the change Delete or before/after comparisons
NEW_AND_OLD_IMAGES Both versions Auditing and rich projections; larger events and greater data exposure

Enable it and retrieve the ARN:

aws dynamodb update-table 
  --table-name Orders 
  --stream-specification StreamEnabled=true,StreamViewType=NEW_AND_OLD_IMAGES

aws dynamodb describe-table 
  --table-name Orders 
  --query 'Table.LatestStreamArn' 
  --output text

Before creating a mapping, verify the Region, account, table, ARN, and view type. A REMOVE can represent an explicit delete or a TTL deletion; if that distinction matters, persist a deletion reason before removing the item. TTL behavior, especially with global tables, has additional rules in the TTL documentation.

Grant least-privilege access

The Lambda execution role needs to read the stream and its shards, write CloudWatch Logs, and access the downstream tables, queues, APIs, or services used by the consumer. AWSLambdaDynamoDBExecutionRole supplies basic stream permissions, but production roles should narrowly scope resources and actions rather than grant unrelated access. Consult the managed policy reference.

The Lambda function does not normally call GetRecords itself; the event-source mapping performs polling. AWS does not charge the standard Lambda-triggered GetRecords calls under the normal model, but the rest of the architecture still incurs costs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
SQL Server Hardware
  • Used Book in Good Condition

Create and inspect the event-source mapping

aws lambda create-event-source-mapping 
  --function-name ProcessDynamoDBRecords 
  --event-source-arn "$STREAM_ARN" 
  --starting-position LATEST 
  --batch-size 100 
  --function-response-types ReportBatchItemFailures 
  --bisect-batch-on-function-error 
  --maximum-retry-attempts 5 
  --maximum-record-age-in-seconds 3600 
  --enabled
  • LATEST handles new records; TRIM_HORIZON attempts records still retained from the beginning.
  • BatchSize defaults to 100 and can be as high as 10,000, subject to the 6 MB payload limit.
  • A batching window can be up to five minutes; zero seconds favors latency.
  • Partial responses retry only reported failures. Bisection splits a failed batch to isolate poison records.
  • Retry attempts and maximum record age default to infinite (-1); maximum retry attempts is 10,000 and maximum record age is 604,800 seconds.

Inspect state and processing results with:

aws lambda list-event-source-mappings 
  --function-name ProcessDynamoDBRecords

Check State, StateTransitionReason, LastProcessingResult, EventSourceArn, BatchSize, FunctionResponseTypes, retry and age limits, and LastModified. Full parameter definitions are in the DynamoDB mapping reference.

Write an idempotent, partial-batch handler

Lambda can deliver a record more than once. A handler should process every record, ignore irrelevant event names, derive a deterministic identifier, perform an idempotent side effect, and return only failed sequence numbers.

import boto3
from botocore.exceptions import ClientError

ddb = boto3.resource("dynamodb")
processed = ddb.Table("ProcessedStreamEvents")

def handler(event, context):
    failures = []
    for record in event.get("Records", []):
        event_id = record["eventSourceARN"] + ":" + record["dynamodb"]["SequenceNumber"]
        try:
            processed.put_item(
                Item={"eventId": event_id},
                ConditionExpression="attribute_not_exists(eventId)")
            name = record["eventName"]
            if name == "INSERT": handle_insert(record)
            elif name == "MODIFY": handle_modify(record)
            elif name == "REMOVE": handle_remove(record)
        except ClientError as exc:
            if exc.response["Error"]["Code"] == "ConditionalCheckFailedException":
                continue
            failures.append({"itemIdentifier": record["dynamodb"]["SequenceNumber"]})
        except Exception:
            failures.append({"itemIdentifier": record["dynamodb"]["SequenceNumber"]})
    return {"batchItemFailures": failures}

The mapping must explicitly enable ReportBatchItemFailures; returning the JSON alone is insufficient. Lambda uses the lowest failed sequence number as the checkpoint and retries from there. See partial batch reporting.

Choose a replay-safe idempotency strategy

  • Deterministic projection: upsert OrderSummary(orderId) from the event’s state instead of incrementing a counter. Replaying a state assignment produces the same result.
  • Conditional deduplication: store an event ID with attribute_not_exists(eventId). Add TTL when indefinite retention is unnecessary, and do not mark completion before the side effect succeeds.
  • Business key: use a key such as orderId#status#version when logical operations may have different transport IDs. A sequence number is useful for transport deduplication but is not automatically a globally unique business ID.

For external APIs, pass the event ID as the provider’s idempotency key when supported. For versioned projections, reject stale updates with conditional writes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Retries, poison records, and recovery

A failed batch can be retried, bisected, and eventually discarded. Configure an on-failure SQS queue or SNS topic for discarded-batch metadata; that destination does not replace preserving the original business data.

  • Retry transient outages and downstream throttling with controlled concurrency.
  • Isolate malformed records with bisection and quarantine them.
  • Record permanent business rejections for manual remediation.
  • Set age limits only when losing stale work is acceptable and a reconciliation path exists.

If processing fails, inspect logs and LastProcessingResult, then check IAM errors, timeouts, deployment changes, and downstream throttling. Reduce batch size or pause the mapping while fixing a poison record. Re-enable it with:

aws lambda update-event-source-mapping 
  --uuid "$UUID" 
  --enabled

A disabled mapping retains its processing position when re-enabled. After recovery, verify iterator age falls and reconcile the source table with the projection. A backlog older than 24 hours cannot be recovered from the stream alone; use backups, point-in-time recovery, exports, or a separately retained event log.

Ordering, consistency, and feedback loops

There is no global ordering guarantee. Concurrent consumers finish at different times, retries can complete out of order, and a later table read may show a newer version than the record being handled. Include a monotonic version in items where ordering matters and conditionally reject stale projection writes.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
ECHOGEAR Server Rack Screws 25 Pack - 10/32 Steel Screws with Attached Nylon Washers & Pilot Point Heads - Made to Use with Network Racks, Enclosures, & Cabinets
  • Expanding your network setup? These 10/32 rack mount screws work with any standard networking rack, cabinet, or enclosure.
  • These screws are built from high-grade steel and coated with black zinc to prevent stripping. Because nothing will ruin your day faster than stripped screws.
  • Rack rash? No thanks. Pre-attached nylon washers save time and keep your rack looking nice. Just bring a Philips screwdriver and let's get to it.
  • Sometimes it's hard to get the screw in the hole. That's why we added self-guiding pilot points to speed up installation and prevent curse words.
  • Big project? We've got groups of 25, 50, and 100 screws to choose from. Run into an issue with your rack? We've got ECHOGEAR pros available 7 days a week to help out.

The stream is asynchronous: the API can return before consumers finish, so read models may lag. Do not have a consumer write back into the same processing path without an entity discriminator or filter; otherwise it can create a feedback loop. Separate projection tables are usually safer.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Filtering and throughput tuning

Event filtering can invoke a consumer only for relevant event names or attributes, reducing invocations and downstream work. It is not authorization, validation, idempotency, or a retry mechanism; unmatched records simply do not invoke the function.

Control Benefit Risk
Larger batch Fewer invocations Larger retry blast radius and latency
Longer batching window Better efficiency Higher event latency
Higher parallelization factor More throughput Downstream overload and harder ordering
Reserved concurrency Protects dependencies Too low creates backlog
Strict age limit Prevents stale work blocking current work Data loss without reconstruction

Measure before changing settings: CloudWatch IteratorAge, duration, errors, throttles, concurrent executions, discarded records, downstream latency, and business processing lag. Lambda polls stream shards at a base rate of four times per second; service quotas and account concurrency still constrain scaling.

CDC versus domain events

A native stream record describes a table mutation, not necessarily a stable application contract. If other domains need a durable event, translate the change into a versioned envelope such as:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
{
  "entityType": "Order",
  "entityId": "order-123",
  "operation": "MODIFY",
  "version": 7,
  "occurredAt": "2026-08-18T12:00:00Z",
  "source": "Orders",
  "payload": {}
}

Publish that contract to EventBridge or Kinesis when independent consumers need routing, retention, partitioning, or replay. EventBridge Pipes can route and enrich DynamoDB stream records without custom Lambda code. Use SQS for explicit work queues and dead-letter workflows, Step Functions for stateful multi-step orchestration, and Fargate for long-running or specialized containers.

Cost model

Estimate the complete graph rather than only Lambda invocations:

Monthly cost ≈ Lambda requests and GB-seconds
 + source-table capacity
 + projection and deduplication writes
 + storage and logs
 + SQS, SNS, EventBridge, Kinesis, or API calls
 + cross-Region replication and backups

DynamoDB on-demand and provisioned pricing varies by Region, item size, consistency, and usage tier. Lambda-triggered stream reads avoid certain GetRecords charges, but the architecture is not free. Check the target Region and date in DynamoDB pricing, Lambda pricing, and the AWS Pricing Calculator.

Production checklist

  • Choose the stream view and data exposure deliberately.
  • Use least-privilege IAM for the mapping and downstream resources.
  • Implement idempotency and replay-safe projections.
  • Enable partial batch responses and, where useful, bisection.
  • Set retry, record-age, concurrency, and failure-destination policies.
  • Alarm on iterator age, errors, throttles, and discarded records.
  • Document projection rebuild and reconciliation from the source table.
  • Validate whether 24-hour retention meets recovery and replay requirements.
  • Review Region-specific pricing, quotas, and downstream capacity before launch.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.