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.
2. Agenda
•N-tier architecture and its limitations
•What is a Reactive Application
•Reactive Application architecture
•AWS for Reactive Applications
•Build a Reactive Application
10. 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
11. Traditional Style of applications cannot deliver on these requirements any longer
22. N-tier to Reactive
Internal API
Internal API
API
Poll
Poll
Database
Storage
Queries
Synchronous
User waits for update
Front-end server
23. N-tier to Reactive
Front-end server
Internal API
Internal API
API
Database
Storage
Queries
Synchronous
User waits for update
Push
Push/Broadcast
24. N-tier to Reactive
Front-end server
Internal API
Internal API
Database
Storage
Queries
Synchronous
User waits for update
Push
Push/Broadcast
Message handlers
25. N-tier to Reactive
Front-end server
Internal API
Internal API
Database
Storage
Queries
Synchronous
User waits for update
Push
Push/Broadcast
Message handlers
Queue
messages
26. N-tier to Reactive
Front-end server
Internal API
Internal API
Database
Storage
Queries
Asynchronous
User waits for update
Push
Push/Broadcast
Message handlers
Queue
messages
27. 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
32. messageTopic
WebSocket
Server (EC2)
HTML5 Clients
WebSocket
Server (EC2)
Subscribe/Notify
SNS
Responsive
Elastic
Resilient
Message-driven
33. Amazon SNS -Overview
•Publish-subscribe model
•Scalable, robust way to implement push
•Topics
•Broadcast messages
Responsive
Elastic
Resilient
Message-driven
34. WebSocket -overview
•HTML5 Technology
•Full-duplex communication over TCP
Responsive
Elastic
Resilient
Message-driven
35. 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
46. Amazon SQS -overview
Responsive
Elastic
Resilient
Message-driven
•Enables loose coupling
•Enables location independent components
•Designed to provide high durability
•At least once delivery
•Timeouts to manage failure
47. 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
48. DynamoDB-overview
Responsive
Elastic
Resilient
Message-driven
•Fully managed cloud NoSQLdatabase
•Seamless Scaling
•Highly Available
•Flexible data models( key-value/document )
54. 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
59. Auto Scaling -Overview
•Scale-out and scale-in
•Works seamlessly with Amazon CloudWatch
•Define Auto Scaling groups
•Enables fault tolerance
•Enables high availability
60. Elastic Load Balancing -Overview
•Distribute the load automatically
•Works seamlessly with Auto Scaling groups
•Cross-zone load balancing
•Perform health checks
69. 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
70. Users
Load Balancer
EC2 Instances with Auto Scaling
Reacting to failures—Level 1
71. Reacting to failures—Level 2
Users
Load Balancer
EC2 Instances with Auto Scaling.
Secured with Amazon VPC
72. 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 53
Responsive
Elastic
Resilient
Message-driven
74. Across regions –Amazon Route 53
Region 1
Region 2
Based on a routing policy
Amazon Route 53
75. Multi AZ and Multi region
messageTopic
WebSocket
Servers(EC2)
Subscribe/Notify
Message
Worker
1. Receive
Message
DynamoDB
saveMessage
computePopular
4.QueueMessage
1. Get Message
SQS
SQS
SNS
calcPop
Worker
Load Balancer
Users
76. Multi AZ and Multi region
Users
AZ1
AZ2
AZ1
AZ2
Region 1
Region 2