Being a good citizen in an event driven world Ajay Nair Principal - - PowerPoint PPT Presentation

being a good citizen in an event driven world ajay nair
SMART_READER_LITE
LIVE PREVIEW

Being a good citizen in an event driven world Ajay Nair Principal - - PowerPoint PPT Presentation

Being a good citizen in an event driven world Ajay Nair Principal Product Manager Amazon Web Services @ajaynairthinks Serverless will fundamentally change how we build business around technology and how you code. - Geekwire


slide-1
SLIDE 1

@ajaynairthinks

Ajay Nair Principal Product Manager Amazon Web Services

Being a good citizen in an event driven world

slide-2
SLIDE 2

@ajaynairthinks

“Serverless will fundamentally change how we build business around technology and how you code.” - Geekwire

slide-3
SLIDE 3

@ajaynairthinks

(from “AWS Lambda from the trenches” by Yan Cui)

TODAY

slide-4
SLIDE 4

@ajaynairthinks

Yubl (from “AWS Lambda from the trenches”)

TOMORROW

(from “AWS Lambda from the trenches” by Yan Cui)

slide-5
SLIDE 5

@ajaynairthinks

Web Applications

  • Static websites
  • Complex web

apps

Data Processing

  • Real-time data
  • Streaming data
  • Media content

Chatbots

  • Powering

chatbot logic

  • Powering

voice-enabled apps

  • Alexa Skills Kit

Backends

  • Apps & services
  • Mobile
  • IoT

</> </>

Autonomous IT

  • Policy engines
  • Infrastructure

management

USE CASES

Big Data

  • MapReduce
  • Batch
slide-6
SLIDE 6

@ajaynairthinks

EVENT SOURCE

Requests to endpoints Changes in resource state Changes in data state

FUNCTIONS/ACTORS DOWNSTREAM

✓ Communicate through events and APIs ✓ Stateless, ephemeral actors ✓ Separation of logic from data, cache, and state

EVENT DRIVEN ARCHITECTURES (GROSSLY SIMPLIFIED)

slide-7
SLIDE 7

@ajaynairthinks

How do I build an effective event source?

slide-8
SLIDE 8

@ajaynairthinks

Event delivery concepts

slide-9
SLIDE 9

@ajaynairthinks

Event destinatio n Event router Event source “An event is a signal emitted by a component upon reaching a given state.” – Reactive Manifesto Payload Batching On-success semantics On-Failure semantics

EVENT DELIVERY CONCEPTS

slide-10
SLIDE 10

@ajaynairthinks

Responsible for emitting information when the event of interest happens.

EVENT DELIVERY CONCEPTS

Event destinatio n Event router Event source Payload Batching On-success semantics On-Failure semantics

slide-11
SLIDE 11

@ajaynairthinks

EVENT DELIVERY CONCEPTS

Event destinatio n Event router Event source Payload Batching On-success semantics On-Failure semantics Responsible for getting the event payload to the desired destination.

slide-12
SLIDE 12

@ajaynairthinks

Event source Event router Controls… Payload Retention On-success semantics Filtering On-Failure semantics AWS Examples

EVENT DELIVERY CONCEPTS

Amazon SNS Amazon S3 CloudWatch events (CRON) CloudWatch events Rules Lambda (Event Source Mappings) AWS IoT (Gateway) EC2 Amazon DynamoDB

slide-13
SLIDE 13

@ajaynairthinks

DECISION #1 - PAYLOAD

slide-14
SLIDE 14

@ajaynairthinks

WHAT SHOULD BE IN THE EVENT?

* Martin Fowler – “What do you mean by “Event-Driven”?” – Feb 2017

Pattern #1 - Event notification pattern*

  • Event processor expected to contact event source to do work
  • Requires characteristics/identifier – “What can you tell the

event destination about the event source and entity affected?”

  • Baseline - Provenance
  • “What happened for this notification to occur?”
slide-15
SLIDE 15

@ajaynairthinks

WHAT SHOULD BE IN THE EVENT?

* Martin Fowler – “What do you mean by “Event-Driven”?” – Feb 2017

Pattern #2 - Event-carried state transfer pattern*

  • Event processor not expected to contact event source
  • Requires payload i.e. state you want to transfer downstream
  • Baseline - Provenance
  • “What happened for this notification to occur?”
slide-16
SLIDE 16

@ajaynairthinks

{ "Records":[ { "eventVersion":"2.0", "eventSource":"aws:s3", "awsRegion":"us-east-1", "eventTime":The time, in ISO-8601 format, for example, 1970-01-01T00:00:00.000Z, when S3 finished processing the request, "eventName":"event-type", "userIdentity":{ "principalId":"Amazon-customer-ID-of-the-user-who-caused-the-event" }, "requestParameters":{ "sourceIPAddress":"ip-address-where-request-came-from" }, "responseElements":{ "x-amz-request-id":"Amazon S3 generated request ID", "x-amz-id-2":"Amazon S3 host that processed the request" }, "s3":{ "s3SchemaVersion":"1.0", "configurationId":"ID found in the bucket notification configuration", "bucket":{ "name":"bucket-name", "ownerIdentity":{ "principalId":"Amazon-customer-ID-of-the-bucket-owner" }, "arn":"bucket-ARN" }, "object":{ "key":"object-key", "size":object-size, "eTag":"object eTag", "versionId":"object version if bucket is versioning-enabled, otherwise null", "sequencer": "a string representation of a hexadecimal value used to determine event sequence,

  • nly used with PUTs and DELETEs"

} } }, ] }

Provenance Characteristics

EXAMPLE EVENTS

S3

"Records": [ { "eventID": "shardId-000000000000:49545115243490985018280067714973144582180062593244200961 "eventVersion": "1.0", "kinesis": { "partitionKey": "partitionKey-3", "data": "SGVsbG8sIHRoaXMgaXMgYSB0ZXN0IDEyMy4=", "kinesisSchemaVersion": "1.0", "sequenceNumber": "49545115243490985018280067714973144582180062593244200961" }, "invokeIdentityArn": identityarn, "eventName": "aws:kinesis:record", "eventSourceARN": eventsourcearn, "eventSource": "aws:kinesis", "awsRegion": "us-east-1" } ] }

Payload IoT data through Kinesis

slide-17
SLIDE 17

@ajaynairthinks

DECISION #2 – EVENT STORE

slide-18
SLIDE 18

@ajaynairthinks

OPTIONAL: EVENT STORE

Durability

Events are accessible even if event source is down

Retention

Events can be revisited until processed

Cost

Additional storage, data transfer, and service costs

Complexity

New service dependency,

  • perational surface area

VS.

Not required if:

  • Event source reclaims state (e.g. synchronous invocations)
  • Event source has persistent storage (e.g. S3)
slide-19
SLIDE 19

@ajaynairthinks

OPTION #1 - STREAMS

Benefits

  • Ordered processing on events
  • Multiple consumers processing

same event list

  • Downsides
  • Need to manage sharding and

scaling

  • Restricted concurrency
  • Complex routing/filtering rules
  • Scenarios
  • Event sourcing (e.g. replication)
  • Aggregations

Entity store Entities

slide-20
SLIDE 20

@ajaynairthinks

OPTION #2 - QUEUES

Benefits

  • Concurrent processing on events
  • Better scaling/ease of use
  • Downsides
  • Limited consumers
  • Order not guaranteed
  • Scenarios
  • Idempotent inspections
  • Parallel processing (e.g.

MapReduce)

slide-21
SLIDE 21

@ajaynairthinks

State transfer Queue based Notifications No event store State transfer Stream based

IMPACT ON SCALING/RESILIENCE

slide-22
SLIDE 22

@ajaynairthinks

DECISION #3 – ROUTERS

slide-23
SLIDE 23

@ajaynairthinks

Event source Event router Controls… Payload Retention On-success semantics Filtering On-Failure semantics AWS Examples

RECAP: EVENT ROUTERS

Amazon SNS Amazon S3 CloudWatch events (CRON) CloudWatch events Rules Lambda (Event Source Mappings) AWS IoT (Gateway) EC2 Amazon DynamoDB

slide-24
SLIDE 24

@ajaynairthinks

Must have

  • Pub/sub: Securely map arbitrary

sources/stores and destinations

  • Conditionals: Ability to discard

uninteresting events

  • E.g. S3 prefix filters
  • On-failure hooks: Specific

behavior if events are unprocessed

  • E.g. Lambda retries and Dead

Letter Queues

Ideal

  • Bidirectional discovery:

Discovery/registry for all available sources/stores and destinations

  • Combinations: allows joins

merges between multiple event sources

  • Multiplexing: many-to-many

combinations of sources and destinations

EVENT ROUTER CHARACTERISTICS

slide-25
SLIDE 25

@ajaynairthinks

BRINGING IT ALL TOGETHER

Entity store

Entities

SNS event consumer

slide-26
SLIDE 26

@ajaynairthinks

1.Be smart about what goes into your payload. 2.Surface an event store when appropriate. 3.Reuse standard routers where possible. RECAP

slide-27
SLIDE 27

@ajaynairthinks

Supercharge the event driven and serverless journey for you and your customers.

slide-28
SLIDE 28

@ajaynairthinks

Thank you!