Event-driven applications

Developing applications on AWS

Ricardo Sueiras

Principal Technologist

What is an event?

 

event-vs-messages

  • A message is a unit of work sent between components.
  • An event records that something already happened.
  • Services communicate by publishing events.
  • Other services react independently to those events.
  • Decoupling reduces dependencies and improves scalability.
Developing applications on AWS

Event producers

 

event producers

  • Producers create and publish events when actions occur.
  • Both AWS services and custom applications can produce events.
  • Uploading a file to Amazon S3 is one example.
  • Amazon S3 then emits an object-created event.
Developing applications on AWS

Event consumers

 

consumers

  • Consumers receive and process events asynchronously.
  • Event sources use different delivery models.
  • Push-based: events are delivered immediately.
  • Poll-based: consumers retrieve events when they poll.
Developing applications on AWS

Event source mapping

  • AWS Lambda is a common event consumer.
  • It polls sources and retrieves batches of records automatically.

 

event source mapping

Developing applications on AWS

Tuning Lambda event source mappings

  • Tune event source mappings to improve throughput.
  • Adjust batch size to control records per invocation.
  • Configure retry controls for failed records.
  • Use partial batch responses on supported sources.
  • ReportBatchItemFailures avoids reprocessing successful records.

 

event source mapping

Developing applications on AWS

Amazon EventBridge

  • EventBridge routes events between services and applications.
  • It enables dynamic routing without tightly coupling services.
  • Applications publish their events to EventBridge.
  • Routing rules decide which targets receive each event.

 

event bridge

Developing applications on AWS

EventBridge capabilities

 

capabilities

  • EventBridge offers several routing capabilities.
  • Rules fan one event out to many targets.
  • Scheduled rules remove the need for cron servers.
  • Schedules support rate(), at(), and cron() expressions.
  • Pipes provide point-to-point integration.
  • Pipes also enable filtering and transformation.
Developing applications on AWS

Event buses

 

event bus

  • Different event buses optimize how events are routed.
  • The default bus receives events from AWS services.
  • Custom buses carry application-specific events.
  • Partner buses receive events from third-party providers.
  • Rules sit between each bus and its targets.
Developing applications on AWS

Schemas discovery

 

event schema and registry

  • Producers and consumers often evolve independently.
  • Understanding event structure is essential.
  • Schema discovery captures the structure of incoming events.
  • Use it to inspect event payloads.
  • Use it to validate integrations.
  • Use it to generate bindings for supported languages.
Developing applications on AWS

Schema registry

  • The schema registry stores your event schemas.
  • It helps developers understand event structure and generate bindings.

 

event schema and registry

Developing applications on AWS

Event filtering

  • Filtering reduces unnecessary processing.
  • Define matches with JSON event patterns.
  • Patterns match only the specific events you want.
  • Downstream systems then process only relevant events.

 

event filtering

Developing applications on AWS

Event ordering

  • Event ordering is not always guaranteed.
  • Some services may process events out of sequence.
  • Use ordering controls to enforce sequence explicitly.

 

event ordering

Developing applications on AWS

Archiving and replaying events

 

archiving and replaying

  • EventBridge can archive and later replay events.
  • Replay events to recover from failures.
  • Replay events to test new consumers.
  • Replay events to rebuild downstream systems.
Developing applications on AWS

Error handling

 

handling errors

  • Event-driven apps must handle errors safely.
  • Failures include duplicate events.
    • Failed processing.
    • Unavailable consumers.
  • Design consumers to be idempotent wherever possible.
Developing applications on AWS

DLQs and destinations

 

handling errors

  • Use DLQs to isolate repeatedly failing events.
  • In EventBridge, DLQs are configured per rule target, not per function.
  • Lambda Destinations extend this routing.
  • Destinations route both success and failure results.
Developing applications on AWS

Testing and validating events

  • Testing event-driven apps validates routing.
  • It also validates event filtering.
  • It also validates event retries.
  • It confirms processing across distributed systems.
  • Use AWS SAM to generate sample test events.
  • Sample events replicate the exact JSON output.

 

testing

Developing applications on AWS

What to test

  • SAM lets you test locally before deployment.
  • Validate event pattern matching.
  • Validate retry behavior.
  • Validate throttling scenarios.
  • Validate duplicate event delivery.
  • Validate idempotent consumer behavior.

 

testing

Developing applications on AWS

Let's practice!

Developing applications on AWS

Preparing Video For Download...