(arc206) architecting reactive applications on aws | aws re:invent 2014

Post on 27-Jun-2015

1.922 Views

Category:

Technology

5 Downloads

Preview:

Click to see full reader

DESCRIPTION

Application requirements have changed dramatically in recent years, requiring millisecond or even microsecond response times and 100 percent uptime. This change has led to a new wave of andquot;reactive applicationsandquot; with architectures that are event-driven, scalable, resilient, and responsive. In this session, we present the blueprint for building reactive applications on AWS. We compare reactive architecture to the classic n-tier architecture and discuss how it is cost-efficient and easy to implement using AWS. Next, we walk through how to design, build, deploy, and run reactive applications in the AWS cloud, delivering highly responsive user experiences with a real-time feel. This architecture uses Amazon EC2 instances to implement server push to broadcast events to application clients; AWS messaging (Amazon SQS/SNS); Amazon SWF to decouple system components; Amazon DynamoDB to minimize contention; and Elastic Load Balancing, Auto Scaling, Availability Zones, Amazon VPC, and Amazon Route 53 to make reactive applications scalable and resilient.

TRANSCRIPT

© 2014 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified, or distributed in whole or in part without the express consent of Amazon.com, Inc.

November 13, 2014 | Las Vegas, NV

ARC 206

Architecting Reactive Applications on AWSAtul Shukla, USEReady

Revanth Talari, USEReady

Agenda

• N-tier architecture and its limitations

• What is a Reactive Application

• Reactive Application architecture

• AWS for Reactive Applications

• Build a Reactive Application

Demo

N-Tier App

PopEvent

N-tier architecture

Front-end

server

Internal

APIInternal

APIAPI

Poll

Poll

Database

Storage

Queries

Synchronous

User waits

for update

N-tier architecture• Synchronous communication

• Blocking– Lower throughput

– Hardware under-utilization and higher costs

• Tightly coupled– Location dependent

– Difficult to extend and maintain

• Blocking

• Pull-based

Application requirements have

changed

Application requirements have

changedPetabytes of

data

Application requirements have

changedPetabytes of

data100% uptime

Application requirements have

changed

Sub seconds

response time

Petabytes of

data100% uptime

Change is inevitable• Users

– Demands richer experiences

– Expects super fast response time

• Applications

– Need to scale-on-demand

– Always-On

– Real-time

• Business

– Need to react to these changing requirements

Traditional Style of applications

cannot deliver on these

requirements any longer

Responsive

Elastic Resilient

Message-driven

Reactive Applications

Demo

Reactive Apphttp://popevent.elasticbeanstalk.com

PopEvent

ResponsiveApplication pushes updates to client in real time

Responsive

Elastic Resilient

Message-driven

ElasticScales out and in as demand varies

Responsive

Elastic Resilient

Message-driven

ElasticScales out and in as demand varies

Responsive

Elastic Resilient

Message-driven

Responsive

Elastic Resilient

Message-driven

ResilientSurvives failure of individual components

Responsive

Elastic Resilient

Message-driven

ResilientSurvives failure of individual components

Responsive

Elastic Resilient

Message-driven

ResilientSurvives failure of individual components

Message drivenLoosely coupled, message-driven components

Responsive

Elastic Resilient

Message-driven

Responsive

Elastic Resilient

Message-driven

Transition

• Synchronous

• Tightly coupled

• Blocking

• Pull-based

N-Tier

Reactive

N-tier to Reactive

N-tier to Reactive

Internal

APIInternal

APIAPI

Poll

Poll

Database

Storage

Queries

Synchronous

User waits

for update

Front-end

server

N-tier to Reactive

Front-end

server

Internal

APIInternal

APIAPI

Database

Storage

Queries

Synchronous

User waits

for update

Push

Push/Broadcast

N-tier to Reactive

Front-end

server

Internal

APIInternal

API

Database

Storage

Queries

Synchronous

User waits

for update

Push

Push/Broadcast

Message

handlers

N-tier to Reactive

Front-end

server

Internal

APIInternal

API

Database

Storage

Queries

Synchronous

User waits

for update

Push

Push/Broadcast

Message

handlersQueue

messages

N-tier to Reactive

Front-end

server

Internal

APIInternal

API

Database

Storage

Queries

Asynchronous

User waits

for update

Push

Push/Broadcast

Message

handlersQueue

messages

Reactive architecture• Asynchronous message passing

• Non-blocking– Higher throughput

– Effective hardware utilization and lower costs

• Loosely coupled– Location independent

– Easy to extend and maintain

• Push-based

AWS for Reactive Applications• Responsive

– Amazon EC2 (Websocket

Server)

– Amazon SNS

• Elastic– Elastic Load Balancing

– Auto Scaling

– Elastic Beanstalk

– Amazon DynamoDB

• Resilient– Availability Zones

– Amazon Route 53

– Auto Scaling

– Amazon VPC

– DynamoDB

• Message Driven– Amazon SQS

– Amazon SWF

Let's build a reactive application

Goals• React to Users

• React to Requests

• React to Load

• React to Failures

PopEvent

Reacting to users

Responsive

Elastic Resilient

Message-driven

messageTopicWebSocket

Server (EC2)

Subscribe/Notify

HTML5 Clients

SNS

Responsive

Elastic Resilient

Message-driven

messageTopicWebSocket

Server (EC2)

HTML5 Clients

WebSocket

Server (EC2) Subscribe/NotifySNS

Responsive

Elastic Resilient

Message-driven

Amazon SNS - Overview

• Publish-subscribe model

• Scalable, robust way to implement push

• Topics

• Broadcast messages

Responsive

Elastic Resilient

Message-driven

WebSocket - overview

• HTML5 Technology

• Full-duplex communication over TCP

Responsive

Elastic Resilient

Message-driven

SockJS - overview• Wrapper library over WebSocket

• Available for both clients and server

• SockJS library - https://github.com/sockjs

– Client side – sockjs-client

– Server Side – sockjs-node

Responsive

Elastic Resilient

Message-driven

Server – Subscribe to Amazon SNS topic

Server – Define endpoints

Server – Create SockJS server

Client – Connect to SockJS server

Server – handle client connection

Client– Send Message to SockJS server

http://popevent.elasticbeanstalk.com

Server - Broadcast to clients

Responsive

Elastic Resilient

Message-driven

messageTopicWebSocket

Server (EC2)

Subscribe/Notify

HTML5 Clients

SNS

Done!!

Responsive

Elastic Resilient

Message-driven

Reacting to requests

Responsive

Elastic Resilient

Message-driven

Amazon SQS - overviewResponsive

Elastic Resilient

Message-driven• Enables loose coupling

• Enables location independent components

• Designed to provide high durability

• At least once delivery

• Timeouts to manage failure

Message to Tasks – Amazon SWF Responsive

Elastic Resilient

Message-driven• Task based programming models

• Run application workflows

• Asynchronous invocation

• Coordinate distributed application processing

• Ordered execution of application steps

• At most once delivery

• Reliable and auditable

DynamoDB- overviewResponsive

Elastic Resilient

Message-driven• Fully managed cloud NoSQL database

• Seamless Scaling

• Highly Available

• Flexible data models( key-value/document )

messageTopic

WebSocket

Server (EC2) Subscribe/Notify

HTML5 Clients

Message

Worker

1. Receive

Message

DynamoDB

saveMessage

compute

Popular

calcPop

Worker

4.Queue

Message

1. Get

Message

SQS

SQS

SNS

Responsive

Elastic Resilient

Message-driven

Data ModelResponsive

Elastic Resilient

Message-driven• Tables

– Message• messageId(String) – Primary Hash Key

• timeCreated(Number) – Primary Range Key

– likeCounter• messageId(String) – Primary Hash Key

• dislikeCount(Number)

• likeCount(Number)

Key 1 Key 2 Key 3

Server 1 Server 2 Server 3 Server 4 Server 5

Use unique keys to increase throughput

Hotkey - likeCounter

Responsive

Elastic Resilient

Message-driven

Elastic Beanstalk - overview

• Fast and Simple way to deploy apps

• Makes development process productive

• Provides Auto Scaling and Elastic Load Balancing

out of the box

• Complete resource control

• Free!! Pay only for resources used

Demo

Deploying with

Elastic Beanstalk

PopEvent

Making WebSocket work

Select TCP

Making WebSocket work

Select None

Reacting to load—elastic

Responsive

Elastic Resilient

Message-driven

Auto Scaling - Overview• Scale-out and scale-in

• Works seamlessly with Amazon CloudWatch

• Define Auto Scaling groups

• Enables fault tolerance

• Enables high availability

Elastic Load Balancing - Overview

• Distribute the load automatically

• Works seamlessly with Auto Scaling groups

• Cross-zone load balancing

• Perform health checks

Reacting to load—elastic• Auto Scaling

• Elastic Load Balancing

• Configure in Elastic Beanstalk

Auto Scaling

Auto Scaling – contd.

Elastic Load Balancing - Config

Elastic Load Balancing - Config

Elastic Load Balancing

Users

Load Balancer

EC2 Instances with Auto Scaling

messageTopic

WebSocket

Servers(EC2) Subscribe/Notify

Messag

e

Worker

1. Receive

Message

DynamoDB

saveMessage

compute

Popular

4.Queue

Message

1. Get

Message

SQS

SQS

SNS

calcPop

Worker

Load Balancer

Users

Reacting to failures—resilient

Responsive

Elastic Resilient

Message-driven

Reacting to failures—Level 1• Avoiding single points of failures

• Auto Scaling and Elastic Load Balancing in a single

Availability Zone.

• Configure minimum number of instances

Responsive

Elastic Resilient

Message-driven

Users

Load Balancer

EC2 Instances with Auto Scaling

Reacting to failures—Level 1

Reacting to failures—Level 2

Users

Load Balancer

EC2 Instances with Auto Scaling.

Secured with Amazon VPC

Reacting to failures—Level 3• Auto Scaling and Elastic Load Balancing across

regions

• Configure minimum number of instances in each

zone in each region

• Configure DNS entries in Amazon Route 53Responsive

Elastic Resilient

Message-driven

Amazon Route 53

Across regions – Amazon Route 53

Region 1 Region 2

Based on a routing policy

Amazon Route 53

Multi AZ and Multi region

messageTopic

WebSocket

Servers(EC2) Subscribe/Notify

Messag

e

Worker

1. Receive

Message

DynamoDB

saveMessage

compute

Popular

4.Queue

Message

1. Get

Message

SQS

SQS

SNS

calcPop

Worker

Load Balancer

Users

Multi AZ and Multi region

Users

AZ1 AZ2

AZ1 AZ2

Region 1

Region 2

DemoReacting to failures—resilient

Responsive

Elastic Resilient

Message-driven

Responsive

Elastic Resilient

Message-driven

Reactive Applications

Thank You!

Please give us your feedback on this session.

Complete session evaluations and earn re:Invent swag.

http://bit.ly/awsevalsARC206

top related