Application Lifecycle Management and Event
Driven Programming
Version 1.0
Shiva N ([email protected])AWS Solution Architect
v
Application Lifecycle Management
v
Continuous process of managing the life of an application.
ALM | What is it?
v
Continuous process of managing the life of an application.
Change Automated In Stages Repeatable
ALM | What is it?
v
Versions Interfaces Repository Authorization Rollforward-Rollback
ALM | What is it?
Continuous process of managing the life of an application.
v
Entire time during which an organization spends money on it.
Developer’s laptop to production
ALM | What is it?
Continuous process of managing the life of an application.
v
How long does it take for a single line of code change to move to production?
ALM | Why?
v
ALM | Why?
Business Idea
Implementation
Testing
Release
Customer Feedback
Innovation Revolution
v
ALM | Why?
Innovation requires two things: the ability to try a lot
of experiments, and not having to live with the
collateral damage of failed experiments
Andy JassySVP, Amazon Web Services
Business Idea
Implementation
Testing
Release
Customer Feedback
Innovation Revolution
v
ALM | The landscape
v
Processes Tools
ALM | This presentation will focus on
v
Version Control CI Server
Package Builder
Deploy ServerCommit to
Git/masterDev
Get / PullCode
AMIs
Distributed BuildsRun Tests in parallel
Staging Env
Test Env
CodeConfigTests
Prod Env
Push
Config InstallCreate
Repo
CloudFormation Templates for Env
Generate
ALM | Sample Application Cycle
v
Version Control CI Server
Package Builder
Deploy ServerCommit to
Git/masterDev
Get / PullCode
AMIs
Send Build Report to DevStop everything if build failed
Distributed BuildsRun Tests in parallel
Staging Env
Test Env
CodeConfigTests
Prod Env
Push
Config InstallCreate
Repo
CloudFormation Templates for Env
Generate
ALM | Continuous Integration
v• Test driven promotion (of development change)• Increasing velocity of feedback cycle through iterative change• Contain change to reduce risk• Bugs are detected quickly• Automated testing reduces size of testing effort
ALM | Why CI?
v
Version Control CI Server
Package Builder
Deploy ServerCommit to
Git/masterDev
Get / PullCode
AMIs
Send Build Report to DevStop everything if build failed
Distributed BuildsRun Tests in parallel
Staging Env
Test Env
CodeConfigTests
Prod Env
Push
Config InstallCreate
Repo
CloudFormation Templates for Env
Generate
ALM | Continuous Delivery/Deployment
v
• Automated, repeatable process to push changes to production• Hardens, de-risks the deployment process• Immediate feedback from users• Supports A/B testing or “We test customer reactions to features in
production”• Gives us a breadth of data points across our applications
ALM | Why CD?
SOURCE CODE REPOSITORY
DNS
CONTINUOUS INTEGRATION SERVER
PROJECT MANAGEMENT SERVER
BUILDS
ALM | Sample CI-CD architecture
v
18
MonitorProvisionDeployTestBuildCode
AWS Elastic Beanstalk
AWS OpsWorks
CloudWatchCloudFormationCodeDeploy
CodeCommit CodePipeline
ALM | AWS Services
AWS Elastic Container Service
v
ALM | CodeCommit
• Fully managed service source control service for hosting private Git repositories
• Automatically scales to meet the needs of your project and stores any type of file (source, images, videos, libraries etc.) with no limit on repository size.
• Fully integrated with AWS CodePipeline and AWS CodeDeploy to streamline development.
Dev Source Control Continuous Integration
Continuous Delivery
v
ALM | CodeCommit
Dev Source Control Continuous Integration
Continuous Delivery
• Efficient - transfers incremental changes
• AWS CodeCommit supports all Git commands and works with your existing Git-based tools (e.g., continuous integration/continuous delivery systems, and graphical clients)
• Fully integrated with AWS Identity and Access Management (IAM)
v
ALM | CodePipeline
• A continuous delivery and release automation service that aids smooth deployments.
• You can design your development workflow for checking in code, building the code, deploying your application into staging, testing it, and releasing it to production
Dev Source Control Continuous Integration
Continuous Delivery
v
ALM | CodePipeline
• CodePipeline standardizes and automates the software release process, allowing you to rapidly release new features to users
• Provides the capability to set up configurable gates between each stage such as time-based rules or manual approvals
• Workflows can be created to run unit and integration tests before deploying to production
Dev Source Control Continuous Integration
Continuous Delivery
v
ALM | CodeDeploy
• Automates code deployments to Amazon EC2 instances.
• Makes it easier to rapidly release new features, helps avoid downtime during deployment, and handles the complexity of updating applications
Dev Source Control Continuous Integration
Continuous Delivery
v
ALM | CodeDeploy
• Deploys your released code to a fleet of EC2 instances, Autoscaling group, or On-Prem hosts.
• Accommodate fleets that range in size from one instance all the way up to tens of thousands of instances
• Automatically schedules updates across multiple Availability Zones in order to maintain high availability during the deployment
Dev Source Control Continuous Integration
Continuous Delivery
CODECOMMIT
DNS
CODEPIPELINE
PROJECT MANAGEMENT SERVER
BUILDS
CODEDEPLOY
v
Options for deploying workloads on AWS
Tools deployment
Platformdeployment(PaaS)
Manual deployment(Console/CLI)
Code in-placeContainer image (Docker)
v
27
MonitorProvisionDeployTestBuildCode
AWS Elastic Beanstalk
AWS OpsWorks
CloudWatchCloudFormationCodeDeploy
CodeCommit CodePipeline
ALM | AWS Services
AWS Elastic Container Service
v
What are we deploying?How much control do we want?
v• Unified command line-based
tool to manage your AWS services
• Control multiple AWS services from the command line and automate them through scripts
ALM | Automate with AWS CLI
v
ALM | Automate with AWS CLI
v
Infrastructure as Code
Integrates with version control
JSON format
Templates
Stacks
Supports all AWS resource typesAWS CloudFormation
ALM | Cloudformation
v
{"Description" : "Create an EC2 instance running the Amazon Linux 32 bit AMI.”,"Parameters" : {
"KeyPair" : { "Description" : "The EC2 Key Pair to allow SSH access to the instance", "Type" : "String"
} },"Resources" : {
"Ec2Instance" : { "Type" : "AWS::EC2::Instance", "Properties" : {
"KeyName" : { "Ref" : "KeyPair" }, "ImageId" : "ami-75g0061f”,“InstanceType” : “m1.medium”
} }
}, "Outputs" : {
"InstanceId" : { "Description" : "The InstanceId of the newly created EC2 instance", "Value" : { "Ref" : "Ec2Instance” }
} }
}
Architecting on AWS – Overview of Services for Web Applications
ALM | Cloudformation
v
Architecting on AWS – Overview of Services for Web Applications
Template File Defining Stack
GitSubversionMercurial
Dev
Test
Prod
The entire application can be represented in an AWS CloudFormation template.
Use the version control system of your choice to store and track changes to this template
Build out multiple environments, such as for Development, Test, and Production using the template
ALM | Cloudformation
v• AWS OpsWorks makes it easy to deploy
& operate apps of all shapes and sizes
• Define configurations for your entire environment in a format that you can maintain and version just like your application source code
• Uses the Chef framework so you can bring your own recipes or leverage 100’s of community-built configurations
ALM | Opsworks
v• Quickly deploy and manage applications
in the AWS cloud without worrying about the application infrastructure
• True PaaS – automatically handles allthe details of resource provisioning,load balancing & auto-scaling
• Launch your Java, PHP, .NET, Node.js, Python, and Ruby applications in a matter of minutes
ALM | Beanstalk
v• Cluster Management Made Easy
• Flexible scheduling
• High Performance
• Resource Efficiency
• Programmatic Control
• Docker Compatibility
ALM | Elastic Container Service
v
WWW server
WWW server
WWW server
WWW server
Logging Service
PayService
ProcessService
ProcessService
ProcessService
ProcessService
Cluster of underlyingEC2 instances
WWW containers Application-specific microservices
WWW server
WWW server
Scale out at the
container level
Launching containers is in the order of seconds – very fast to react
ALM | Elastic Container Service
v• Deploy in place • Deploy all at once (Service outage)• Rolling updates
• Blue-Green Deployment• Discrete environment
• Multiple environments from branches• Support A/B testing• “Rolling DNS”
• Alternate Blue-Green (Red-Black?) deployment• Alternate auto scaling group• Avoid messing with DNS
ALM | Deployment Approaches
v
CodeDeploy
ALM | Deploy in place – Rolling update
ELB
S3
EC2
v
ALM | Deploy in place – Rolling update
v
ALM | Deploy in place – Rolling update
v
ALM | Deploy in place – Rolling update
v
ALM | Deploy in place – Rolling update
v
ALM | Deploy in place – Rolling update
vAmazon Route 53
EC2 Instances
ELB
100%
DynamoDB MySQL RDSInstance
ElastiCache Cache Node
ALM | Blue-Green Deployment
v
Amazon Route 53
EC2 Instances
ELB
EC2 Instances
ELB
100%UAT
DynamoDB MySQL RDSInstance
ElastiCache Cache Node
ALM | Blue-Green Deployment
v
Amazon Route 53
EC2 Instances
ELB
EC2 Instances
ELB
90% 10%
DynamoDB MySQL RDSInstance
ElastiCache Cache Node
ALM | Blue-Green Deployment
vAmazon Route 53
EC2 Instances
ELB
EC2 Instances
ELB
50% 50%
DynamoDB MySQL RDSInstance
ElastiCache Cache Node
ALM | Blue-Green Deployment
vAmazon Route 53
EC2 Instances
ELB
EC2 Instances
ELB
0% 100%
DynamoDB MySQL RDSInstance
ElastiCache Cache Node
ALM | Blue-Green Deployment
vAmazon Route 53
EC2 Instances
ELB
EC2 Instances
ELB
0% 100%
DynamoDB MySQL RDSInstance
ElastiCache Cache Node
ALM | Blue-Green Deployment
v
Auto Scaling Group
V1
ELB
Amazon Relational
Database Service (RDS)
ALM | Red-Black Deployment
v
Auto Scaling Group
V1
Auto Scaling Group
V2
ELB
Amazon Relational
Database Service (RDS)
UAT
ALM | Red-Black Deployment
v
Auto Scaling Group
V1
Auto Scaling Group
V2
ELB
Amazon Relational
Database Service (RDS)
ALM | Red-Black Deployment
v
Auto Scaling Group
V2
ELB
Amazon Relational
Database Service (RDS)
ALM | Red-Black Deployment
v
Event Driven Programming
v
EDP | What is Event driven architecture?
A software architecture where loosly coupled components communicate with each other by triggering events
v
Type of interaction Time driven Request driven Event driven
Initiator Time Client Even
Participants The specified systems Client and Server Open ended
Example
EDP | Three styles of interaction
Fruit system
Run inventory every hour
Fruit system
Me want 5 bananas
Fruit system
Monkey took 5 bananas
v
• Real time (or near real time)• Push notifications• One-way ‘fire-and-forget’• Immediate action at event consumer• Informational (“monkey took bananas”) and not commands (“perform
banana inventory”)
EDP| 5 characteristics
v• “Stored procedures for the cloud”• A zero-administration compute platform• Just the code without needing to define
the underlying compute resources or OS• Asynchronous functions • Event driven from other services• …Or triggered externally and even chained
AWS Lambda: connective tissue for AWS services
All you need is code™
EDP | Event Driven Compute – AWS Lambda
No Infrastructure to Manage• Focus on business logic, not
infrastructure• Customer uploads code; AWS
Lambda handles• Capacity• Scaling• Deployment• Fault tolerance• Monitoring• Logging• Web service front end• Security patching
EDP | AWS Lambda
Automatic scaling• Customers can’t over or under
provision• Customers pay only for what
they use• E.g. Each object uploaded to
Amazon S3 is an event• Each event becomes a Lambda
request (hands free delivery)• Lambda scales to match the
event rate
EDP | AWS Lambda
Bring your own code (BYOC)
• Create threads and processes, run batch scripts or other executables, and read/write files in /tmp.
• Include any library with a Lambda function code, even native libraries.
EDP | AWS Lambda
Fine-grained pricing• Price compute time by
100ms, so even short jobs make sense
• Low request charge• No hourly, daily, or
monthly minimums• Free tier
EDP | AWS Lambda
v
• AWS Service Integration• Event triggers from Amazon S3,
DynamoDB, and Kinesis events• Compute at any scale
• One request a month or 10,000 parallel invocations
• Simple, stateless approach, expressed in conventional languages
• Fast response• No long delays for provisioning,
deployment or scale-up• Change and run code as fast as you can type
• Never pay for idle • Fine-grained pricing in 100ms, 64MB steps• Economical at any scale
AWS Lambda
AWS Event Integration
S3 Handler
Dynamo
Handler
Kinesis Handler
Custom Invoke
API
App Event
Handler
EDP | AWS Lambda – Key Features
v
OR
1
2
3
4
1
2
3
EDP | Photo album application architecture
v
On premises AWS EC2 AWS ECS AWS Lambda
Weeks Minutes Seconds Milliseconds
EDP | AWS Lambda
v