SlideShare a Scribd company logo
Amazon Web Services.
From infrastructure
to platform Roman Gomolko
rg@audienceproject.com
AudienceProject
• Developing products that allow to learn digital audiences
• Started using AWS more than 5 years ago
• Fully migrated to AWS more than 2 years ago
• Processing 4 billions requests monthly
• Generating reports based on 8 billions of requests with batched reports
• Online reports on 300 millions of records
• Used ~40% of services provided by AWS
• Totally happy regarding using AWS
Why cloud?
VS
Amazon provides Infrastructure as a Services
• Virtual server (EC2) with operating system preinstalled
- Wide choice of instance types optimized for CPU, RAM or I/O
- Preinstalled operating systems or custom images
- Pay per hour of use
• Magnetic or SSD drives
- attach to running instances
- provisioned or size-dependent IOPs
- up to 64 Tb (SSD)
- backups
• Networking & Firewall
- Easy IP management
- Load balancers
- VPN & VPC
Development and deployment
Today’s agenda
YA.LS
* yet another link shortener
*
http://ya.ls/dx9 ↣ http://buildstuff.com.ua/
Add packages
{
"name": "yals",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"private": true,
"dependencies": {
"body-parser": "^1.14.1",
"express": "^4.13.3",
"node-localstorage": "^0.6.0",
"short-hash": "^1.0.0"
}
}
Bootstrap your application
var express = require('express');
var bodyParser = require('body-parser');
var shortHash = require('short-hash');
var LocalStorage = LocalStorage;
var storage = new (require('node-localstorage').LocalStorage)('./storage');
var app = express();
app.use(express.static(__dirname + '/public'));
app.use(bodyParser.json());
app.get('/', function (req, res) {
res.render('index.html')
});
Add your shorten logic
app.post('/shorten', function (req, res) {
var url = req.body && req.body.url;
if (!url) {
return res.status(400).json({message: 'no URL'}).end();
} else {
var hash = shortHash(url);
storage.setItem(hash, url);
res.json({
hash: hash,
shortUrl: process.env.HOST + hash,
targetUrl: url});
}
})
Add your redirection logic
app.get('/:key', function (req, res) {
var url = storage.getItem(req.params.key);
if (url) {
res.redirect(302, url);
} else {
res.status(404).send('Sorry, link not found');
}
});
var server = app.listen(process.env.PORT || 8888);
<form method="post" onsubmit="shorten(); return false;">
<input type="url"
id="url"
placeholder="Paste your URL here"/>
<input type="submit" value="Shorten">
<div id="recent-links"></div>
</form>
Create fancy UI
window.shorten = function () {
fetch('/shorten', {
method: 'post',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({url: document.getElementById('url').value})
}).then(function (response) {
var url = response.json().shortUrl;
var msg = url ? '<a href="' + url + '">' + url + '</a>' : response.message;
document.getElementById('recent-links').innerHTML = msg;
});
};
Create modern JavaScript frontend
PORT=8000
HOST=http://localhost:8000/
npm run start
Launch your application
Deploy your application to the AWS
Elastic Beanstalk
• Quick deployment and management of Web application
• PHP, ASP.NET, Python, NodeJS, Docker etc
• No need to setup infrastructure
• Performance metrics
• Scale up and scale down
• Rolling updates
Deploy your application
eb init shortener --region eu-west-1 --platform "node.js"
eb create demo
eb setenv HOST=http://ya.ls/
eb deploy
eb open
Your Beanstalk control panel
Near real-time metrics of your application
Your Beanstalk control panel
Elastic Beanstalk - scaled setup
Traditional SQL databases hosteb my Amazon - RDS
• Fully managed traditional SQL servers
- MySQL
- MS SQL
- PostgreSQL
- Oracle
• Variety of server sizes
• Licenses included into price
• Automated backups
• Restore to point at a time
• Document DB
• No limits on size
• Provisioned throughput
• Differents attribute types including Lists and JSON
DynamoDB
Get DynamoDB high level API
npm install aws-sdk --save
var AWS = require("aws-sdk");
AWS.config.update({region: 'eu-west-1'});
var db = new AWS.DynamoDB.DocumentClient(); // <!-- high level SDK
Put hash to DynamoDB
app.post('/shorten', function (req, res) {
var url = req.body && req.body.url;
…
var hash = shortHash(url);
db.put({
TableName: "short_links",
Item: {"hash": hash, targetUrl: url}
}, function () {
storage.setItem(hash, url);
res.json(...);
})
…
Get from DynamoDB
var hash = req.params.key;
var url = storage.getItem(hash);
if (url) {
return go(res, url);
}
db.get(
{TableName: "short_links", Key: {"hash": hash}},
function (err, record) {
url = record.targetUrl;
url && storage.setItem(hash, url); //local cache
go(res, url);
});
Security considerations - IAM
• Identity and Access Management
• Generate policies that describes
- what operations
- are allowed or denied
- to what AWS resources
- (in what circumstances)
• Apply policy to:
- IAM User identified by Access Key and Secret key
- EC2 instance
• vim ~/.aws/credentials
[dev]
aws_access_key_id = AKIA....
aws_secret_access_key = PQC+9o…
• AWS_PROFIEL=dev PORT=8000 HOST=http://localhost:8000/ npm run start
Horizontal scalability achieved
Adding screenshot functionality
var webshot = require('webshot');
webshot(targetUrl, hash + '.png', function(err) {
// Screenshot is ready. Where I should save it?
});
S3
• Virtually unlimited storage
• Reliable
• Fast
• Secure
• Accessible from Internet
Making screenshot
function makeScreenshot(url, hash, callback) {
var fileName = hash + '.png';
webshot(url, fileName, function (err) {
if (err) { return callback(err); }
var stream = fs.createReadStream(fileName)
s3.upload({
Bucket: 'yals-screenshots',
Key: fileName,
ACL: "public-read",
ContentType: "image/png",
Body: stream
}, callback);
});
}
Using queues for storing screenshotting commands - SQS
• Simple Queue System
- Send
- Receive
- Delete
• Cheap: $0.5 for 1M requests
• Reliable
• Durable
• Fast
Making screenshots using SQS to control flow
Screenshotting is just a function. Lambda in on the stage
• Invoke code in response to events
- File uploads to S3
- DynamoDB table changes
- SNS notifications
- HTTP requests
- Scheduled executions
• Just bring your code
- Node.JS
- Python 2.7
- Java 8
• Pay per invokations and computation power
- making 5M screenshots will cost you ~$42*
* 512 Mb RAM, 2 minutes timeout
Screenshotting function with writing results to DynamoDB
exports.handler = function (data, context) {
var hash = …;
var targetUrl = …;
makeScreenshot(hash, targetUrl, function(err, r) {
if (err) {return context.fail(err)};
db.put({
TableName: "short_links",
Item: {"hash": hash, screenshotUrl: r.Location}
}, context.done);
})
};
Hookup Lambda to new shorten links. DynamoDB streams is on the stage
Ordered stream of changes happened to DynamoDB table
• Any change in table is recorded
• Old record and new record can be stored together with change
• Multiple applications processing stream
• Lambda can be easily attached
Fine tuning screenshotting Lambda
exports.handler = function (data, context) {
var item = data.Records[0].dynamodb.NewImage;
var hash = item.hash.S;
var targetUrl = item.targetUrl.S;
var screenshotUrl = item.screenshotUrl.S;
if (screenshotUrl){
return context.success("Screenshot already taken");
}
makeScreenshot(hash, targetUrl, function(err, r) {
...
Architecture with screenshotting functionality
Static content delivery - CloudFront
• CDN for static and dynamic content
• Web and Streaming distributions
• Seamless integration with S3
• Own SSL certificates, free for SNI
• Requests logging and delivery to S3
• Serving dynamic content from Beanstalk, Load balancers and own servers
• Device detection
• Cost effective
Application architecture with CDN
Need to collect click statistic
Storage for statistics - DynamoDB
link_click_statistic
hash (key) date (sort key) desktop mobile tablet other
ddd79ad9 2015-11-22 1050 110 99 4
ddd79ad9 2015-11-23 1301 123 51 1
aa4cbddf 2015-11-22 1513 13 6 2
Click stream storage - Kinesis
• Ordered events stream
• Reliable
• Scalable
• High performance
• Multiple consumers
Processing stream
• Kinesis Client Library (Java)
• Kinesis Multilanguage Daemon (any platform)
• Lambda
Send to Kinesis
function go(req, res, hash, url) {
if (url) {
var kinesis = new AWS.Kinesis();
var params = {
Data: JSON.stringify({"hash": hash, "userAgent": req.header('user-
agent')}),
PartitionKey: "hash",
StreamName: 'yals_clicks'
};
kinesis.putRecord(params);
Lambda skeleton
• Configure batch size (e.g. 1000)
• Group batch to collection of structures
- hash
- date
- desktop
- mobile
- tablet
- other
• Perform DynamoDB update...
Aggregation function
exports.handler = function(data, context){
rows = ...;
// Agg
var params = {
TableName: "link_click_statistic",
Key: {
"hash": row.hash,
"date": row.date
},
UpdateExpression: "ADD desktop :d, mobile :m, ...";
ExpressionAttributeValues: {":d": row.desktop, ":m": row.mobile...};
};
dynamo.updateItem(params, send_next_item);
}
Aggregation architecture
Too many setup were done manually
CloudFormation
• describe services you need
• specify policies
• use configuration variable
• and let Amazon handle it
Quick recap
• Beanstalk - websites hostings
• RDS - hosted relational DB
• DynamoDB - document DB with cool features
• SQS - simple queue service
• S3 - infinite file storage
• CloudFront - static and dynamic content delivery
• Lambda - running code in response to event
• Kinesis - operate with data streams as wizard
• IAM - security in cloud
• CloudFormation - automated cloud resources provisioning
Thank you
Checkout sources https://github.com/romanych/yals
Further watching
• https://www.youtube.com/watch?v=KmHGrONoif4
• https://www.youtube.com/watch?v=8u9wIC1xNt8
• https://www.youtube.com/watch?v=pBLdMCksM3A
• https://www.youtube.com/watch?v=ZBxWZ9bgd44
• https://www.youtube.com/watch?v=TnfqJYPjD9I
• https://www.youtube.com/watch?v=6R44BADNJA8

More Related Content

What's hot

Scaling on AWS for the First 10 Million Users
Scaling on AWS for the First 10 Million UsersScaling on AWS for the First 10 Million Users
Scaling on AWS for the First 10 Million Users
Amazon Web Services
 
Scale Your Application while Improving Performance and Lowering Costs (SVC203...
Scale Your Application while Improving Performance and Lowering Costs (SVC203...Scale Your Application while Improving Performance and Lowering Costs (SVC203...
Scale Your Application while Improving Performance and Lowering Costs (SVC203...
Amazon Web Services
 
Hosting Drupal on Amazon EC2
Hosting Drupal on Amazon EC2Hosting Drupal on Amazon EC2
Hosting Drupal on Amazon EC2
Kornel Lugosi
 
AWS re:Invent 2016: Taking DevOps to the AWS Edge (CTD302)
AWS re:Invent 2016: Taking DevOps to the AWS Edge (CTD302)AWS re:Invent 2016: Taking DevOps to the AWS Edge (CTD302)
AWS re:Invent 2016: Taking DevOps to the AWS Edge (CTD302)
Amazon Web Services
 
AWS Black Belt Tips
AWS Black Belt TipsAWS Black Belt Tips
AWS Black Belt Tips
Amazon Web Services
 
AutoScaling and Drupal
AutoScaling and DrupalAutoScaling and Drupal
AutoScaling and Drupal
Promet Source
 
AWS re:Invent 2016: 5 Security Automation Improvements You Can Make by Using ...
AWS re:Invent 2016: 5 Security Automation Improvements You Can Make by Using ...AWS re:Invent 2016: 5 Security Automation Improvements You Can Make by Using ...
AWS re:Invent 2016: 5 Security Automation Improvements You Can Make by Using ...
Amazon Web Services
 
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...
Amazon Web Services
 
Deep Learning with AWS (November 2016)
Deep Learning with AWS (November 2016)Deep Learning with AWS (November 2016)
Deep Learning with AWS (November 2016)
Julien SIMON
 
Scaling on AWS for the First 10 Million Users
Scaling on AWS for the First 10 Million UsersScaling on AWS for the First 10 Million Users
Scaling on AWS for the First 10 Million UsersAmazon Web Services
 
Deep Dive on Amazon EC2 Instances (March 2017)
Deep Dive on Amazon EC2 Instances (March 2017)Deep Dive on Amazon EC2 Instances (March 2017)
Deep Dive on Amazon EC2 Instances (March 2017)
Julien SIMON
 
Stacktician - CloudStack Collab Conference 2014
Stacktician - CloudStack Collab Conference 2014Stacktician - CloudStack Collab Conference 2014
Stacktician - CloudStack Collab Conference 2014
amoghvk
 
IaaS azure_vs_amazon
IaaS azure_vs_amazonIaaS azure_vs_amazon
IaaS azure_vs_amazon
Udaiappa Ramachandran
 
Infrastructure as Code for Beginners
Infrastructure as Code for BeginnersInfrastructure as Code for Beginners
Infrastructure as Code for Beginners
David Völkel
 
Running High Availability Websites with Acquia and AWS
Running High Availability Websites with Acquia and AWSRunning High Availability Websites with Acquia and AWS
Running High Availability Websites with Acquia and AWSAcquia
 
SMC303 Real-time Data Processing Using AWS Lambda
SMC303 Real-time Data Processing Using AWS LambdaSMC303 Real-time Data Processing Using AWS Lambda
SMC303 Real-time Data Processing Using AWS Lambda
Amazon Web Services
 
Utah Codecamp Cloud Computing
Utah Codecamp Cloud ComputingUtah Codecamp Cloud Computing
Utah Codecamp Cloud Computing
Tom Creighton
 
AWS Webcast - Website Hosting
AWS Webcast - Website HostingAWS Webcast - Website Hosting
AWS Webcast - Website Hosting
Amazon Web Services
 
Best Practices for Genomic and Bioinformatics Analysis Pipelines on AWS
Best Practices for Genomic and Bioinformatics Analysis Pipelines on AWS Best Practices for Genomic and Bioinformatics Analysis Pipelines on AWS
Best Practices for Genomic and Bioinformatics Analysis Pipelines on AWS
Amazon Web Services
 
So you think you are an aws ninja dean samuels
So you think you are an aws ninja   dean samuelsSo you think you are an aws ninja   dean samuels
So you think you are an aws ninja dean samuelsAmazon Web Services
 

What's hot (20)

Scaling on AWS for the First 10 Million Users
Scaling on AWS for the First 10 Million UsersScaling on AWS for the First 10 Million Users
Scaling on AWS for the First 10 Million Users
 
Scale Your Application while Improving Performance and Lowering Costs (SVC203...
Scale Your Application while Improving Performance and Lowering Costs (SVC203...Scale Your Application while Improving Performance and Lowering Costs (SVC203...
Scale Your Application while Improving Performance and Lowering Costs (SVC203...
 
Hosting Drupal on Amazon EC2
Hosting Drupal on Amazon EC2Hosting Drupal on Amazon EC2
Hosting Drupal on Amazon EC2
 
AWS re:Invent 2016: Taking DevOps to the AWS Edge (CTD302)
AWS re:Invent 2016: Taking DevOps to the AWS Edge (CTD302)AWS re:Invent 2016: Taking DevOps to the AWS Edge (CTD302)
AWS re:Invent 2016: Taking DevOps to the AWS Edge (CTD302)
 
AWS Black Belt Tips
AWS Black Belt TipsAWS Black Belt Tips
AWS Black Belt Tips
 
AutoScaling and Drupal
AutoScaling and DrupalAutoScaling and Drupal
AutoScaling and Drupal
 
AWS re:Invent 2016: 5 Security Automation Improvements You Can Make by Using ...
AWS re:Invent 2016: 5 Security Automation Improvements You Can Make by Using ...AWS re:Invent 2016: 5 Security Automation Improvements You Can Make by Using ...
AWS re:Invent 2016: 5 Security Automation Improvements You Can Make by Using ...
 
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...
 
Deep Learning with AWS (November 2016)
Deep Learning with AWS (November 2016)Deep Learning with AWS (November 2016)
Deep Learning with AWS (November 2016)
 
Scaling on AWS for the First 10 Million Users
Scaling on AWS for the First 10 Million UsersScaling on AWS for the First 10 Million Users
Scaling on AWS for the First 10 Million Users
 
Deep Dive on Amazon EC2 Instances (March 2017)
Deep Dive on Amazon EC2 Instances (March 2017)Deep Dive on Amazon EC2 Instances (March 2017)
Deep Dive on Amazon EC2 Instances (March 2017)
 
Stacktician - CloudStack Collab Conference 2014
Stacktician - CloudStack Collab Conference 2014Stacktician - CloudStack Collab Conference 2014
Stacktician - CloudStack Collab Conference 2014
 
IaaS azure_vs_amazon
IaaS azure_vs_amazonIaaS azure_vs_amazon
IaaS azure_vs_amazon
 
Infrastructure as Code for Beginners
Infrastructure as Code for BeginnersInfrastructure as Code for Beginners
Infrastructure as Code for Beginners
 
Running High Availability Websites with Acquia and AWS
Running High Availability Websites with Acquia and AWSRunning High Availability Websites with Acquia and AWS
Running High Availability Websites with Acquia and AWS
 
SMC303 Real-time Data Processing Using AWS Lambda
SMC303 Real-time Data Processing Using AWS LambdaSMC303 Real-time Data Processing Using AWS Lambda
SMC303 Real-time Data Processing Using AWS Lambda
 
Utah Codecamp Cloud Computing
Utah Codecamp Cloud ComputingUtah Codecamp Cloud Computing
Utah Codecamp Cloud Computing
 
AWS Webcast - Website Hosting
AWS Webcast - Website HostingAWS Webcast - Website Hosting
AWS Webcast - Website Hosting
 
Best Practices for Genomic and Bioinformatics Analysis Pipelines on AWS
Best Practices for Genomic and Bioinformatics Analysis Pipelines on AWS Best Practices for Genomic and Bioinformatics Analysis Pipelines on AWS
Best Practices for Genomic and Bioinformatics Analysis Pipelines on AWS
 
So you think you are an aws ninja dean samuels
So you think you are an aws ninja   dean samuelsSo you think you are an aws ninja   dean samuels
So you think you are an aws ninja dean samuels
 

Similar to AWS as platform for scalable applications

Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Emerson Eduardo Rodrigues Von Staffen
 
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
Amazon Web Services
 
AWS Webcast - Website Hosting in the Cloud
AWS Webcast - Website Hosting in the CloudAWS Webcast - Website Hosting in the Cloud
AWS Webcast - Website Hosting in the Cloud
Amazon Web Services
 
Increase Speed and Agility with Amazon Web Services
Increase Speed and Agility with Amazon Web ServicesIncrease Speed and Agility with Amazon Web Services
Increase Speed and Agility with Amazon Web Services
Amazon Web Services
 
Increase Speed and Agility with Amazon Web Services
Increase Speed and Agility with Amazon Web ServicesIncrease Speed and Agility with Amazon Web Services
Increase Speed and Agility with Amazon Web Services
Amazon Web Services
 
Application Lifecycle Management on AWS
Application Lifecycle Management on AWSApplication Lifecycle Management on AWS
Application Lifecycle Management on AWS
David Mat
 
Running your First Application on AWS
Running your First Application on AWSRunning your First Application on AWS
Running your First Application on AWS
Amazon Web Services
 
Building a Just-in-Time Application Stack for Analysts
Building a Just-in-Time Application Stack for AnalystsBuilding a Just-in-Time Application Stack for Analysts
Building a Just-in-Time Application Stack for Analysts
Avere Systems
 
AWS Summit Auckland 2014 | Running your First Application on AWS
AWS Summit Auckland 2014 | Running your First Application on AWSAWS Summit Auckland 2014 | Running your First Application on AWS
AWS Summit Auckland 2014 | Running your First Application on AWS
Amazon Web Services
 
Introduction to DevOps on AWS
Introduction to DevOps on AWSIntroduction to DevOps on AWS
Introduction to DevOps on AWS
Shiva Narayanaswamy
 
Automating Security in your IaC Pipeline
Automating Security in your IaC PipelineAutomating Security in your IaC Pipeline
Automating Security in your IaC Pipeline
Amazon Web Services
 
AWS re:Invent 2016: Deep-Dive: Native, Hybrid and Web patterns with Serverles...
AWS re:Invent 2016: Deep-Dive: Native, Hybrid and Web patterns with Serverles...AWS re:Invent 2016: Deep-Dive: Native, Hybrid and Web patterns with Serverles...
AWS re:Invent 2016: Deep-Dive: Native, Hybrid and Web patterns with Serverles...
Amazon Web Services
 
App fabric introduction
App fabric introductionApp fabric introduction
App fabric introduction
Dennis van der Stelt
 
Running your First Application on AWS
Running your First Application on AWS Running your First Application on AWS
Running your First Application on AWS
Amazon Web Services
 
Migrating enterprise workloads to AWS
Migrating enterprise workloads to AWS Migrating enterprise workloads to AWS
Migrating enterprise workloads to AWS Tom Laszewski
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without serversAmazon Web Services
 
DW on AWS
DW on AWSDW on AWS
DW on AWS
Gaurav Agrawal
 
Migrating enterprise workloads to AWS
Migrating enterprise workloads to AWSMigrating enterprise workloads to AWS
Migrating enterprise workloads to AWSTom Laszewski
 
Aws-What You Need to Know_Simon Elisha
Aws-What You Need to Know_Simon ElishaAws-What You Need to Know_Simon Elisha
Aws-What You Need to Know_Simon Elisha
Helen Rogers
 
AWS September Webinar Series - Visual Effects Rendering in the AWS Cloud with...
AWS September Webinar Series - Visual Effects Rendering in the AWS Cloud with...AWS September Webinar Series - Visual Effects Rendering in the AWS Cloud with...
AWS September Webinar Series - Visual Effects Rendering in the AWS Cloud with...
Amazon Web Services
 

Similar to AWS as platform for scalable applications (20)

Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
 
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
 
AWS Webcast - Website Hosting in the Cloud
AWS Webcast - Website Hosting in the CloudAWS Webcast - Website Hosting in the Cloud
AWS Webcast - Website Hosting in the Cloud
 
Increase Speed and Agility with Amazon Web Services
Increase Speed and Agility with Amazon Web ServicesIncrease Speed and Agility with Amazon Web Services
Increase Speed and Agility with Amazon Web Services
 
Increase Speed and Agility with Amazon Web Services
Increase Speed and Agility with Amazon Web ServicesIncrease Speed and Agility with Amazon Web Services
Increase Speed and Agility with Amazon Web Services
 
Application Lifecycle Management on AWS
Application Lifecycle Management on AWSApplication Lifecycle Management on AWS
Application Lifecycle Management on AWS
 
Running your First Application on AWS
Running your First Application on AWSRunning your First Application on AWS
Running your First Application on AWS
 
Building a Just-in-Time Application Stack for Analysts
Building a Just-in-Time Application Stack for AnalystsBuilding a Just-in-Time Application Stack for Analysts
Building a Just-in-Time Application Stack for Analysts
 
AWS Summit Auckland 2014 | Running your First Application on AWS
AWS Summit Auckland 2014 | Running your First Application on AWSAWS Summit Auckland 2014 | Running your First Application on AWS
AWS Summit Auckland 2014 | Running your First Application on AWS
 
Introduction to DevOps on AWS
Introduction to DevOps on AWSIntroduction to DevOps on AWS
Introduction to DevOps on AWS
 
Automating Security in your IaC Pipeline
Automating Security in your IaC PipelineAutomating Security in your IaC Pipeline
Automating Security in your IaC Pipeline
 
AWS re:Invent 2016: Deep-Dive: Native, Hybrid and Web patterns with Serverles...
AWS re:Invent 2016: Deep-Dive: Native, Hybrid and Web patterns with Serverles...AWS re:Invent 2016: Deep-Dive: Native, Hybrid and Web patterns with Serverles...
AWS re:Invent 2016: Deep-Dive: Native, Hybrid and Web patterns with Serverles...
 
App fabric introduction
App fabric introductionApp fabric introduction
App fabric introduction
 
Running your First Application on AWS
Running your First Application on AWS Running your First Application on AWS
Running your First Application on AWS
 
Migrating enterprise workloads to AWS
Migrating enterprise workloads to AWS Migrating enterprise workloads to AWS
Migrating enterprise workloads to AWS
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
DW on AWS
DW on AWSDW on AWS
DW on AWS
 
Migrating enterprise workloads to AWS
Migrating enterprise workloads to AWSMigrating enterprise workloads to AWS
Migrating enterprise workloads to AWS
 
Aws-What You Need to Know_Simon Elisha
Aws-What You Need to Know_Simon ElishaAws-What You Need to Know_Simon Elisha
Aws-What You Need to Know_Simon Elisha
 
AWS September Webinar Series - Visual Effects Rendering in the AWS Cloud with...
AWS September Webinar Series - Visual Effects Rendering in the AWS Cloud with...AWS September Webinar Series - Visual Effects Rendering in the AWS Cloud with...
AWS September Webinar Series - Visual Effects Rendering in the AWS Cloud with...
 

Recently uploaded

Reliable Logistics Solutions - Truxcargo
Reliable Logistics Solutions - TruxcargoReliable Logistics Solutions - Truxcargo
Reliable Logistics Solutions - Truxcargo
Truxcargo
 
WORK PERMIT IN BULGARIA | Work Visa Services
WORK PERMIT IN BULGARIA | Work Visa ServicesWORK PERMIT IN BULGARIA | Work Visa Services
WORK PERMIT IN BULGARIA | Work Visa Services
RKIMT
 
All Trophies at Trophy-World Malaysia | Custom Trophies & Plaques Supplier
All Trophies at Trophy-World Malaysia | Custom Trophies & Plaques SupplierAll Trophies at Trophy-World Malaysia | Custom Trophies & Plaques Supplier
All Trophies at Trophy-World Malaysia | Custom Trophies & Plaques Supplier
Trophy-World Malaysia Your #1 Rated Trophy Supplier
 
Nature’s Paradise Glamorous And Sustainable Designs For Your Outdoor Living S...
Nature’s Paradise Glamorous And Sustainable Designs For Your Outdoor Living S...Nature’s Paradise Glamorous And Sustainable Designs For Your Outdoor Living S...
Nature’s Paradise Glamorous And Sustainable Designs For Your Outdoor Living S...
Landscape Express
 
Colors of Wall Paint and Their Mentally Properties.pptx
Colors of Wall Paint and Their Mentally Properties.pptxColors of Wall Paint and Their Mentally Properties.pptx
Colors of Wall Paint and Their Mentally Properties.pptx
Brendon Jonathan
 
How Does Littering Affect the Environment.
How Does Littering Affect the Environment.How Does Littering Affect the Environment.
How Does Littering Affect the Environment.
ClenliDirect
 
Are Gutters Necessary? Explore the details now!
Are Gutters Necessary? Explore the details now!Are Gutters Necessary? Explore the details now!
Are Gutters Necessary? Explore the details now!
AmeliaLauren3
 
Unlocking Insights: AI-powered Enhanced Due Diligence Strategies for Increase...
Unlocking Insights: AI-powered Enhanced Due Diligence Strategies for Increase...Unlocking Insights: AI-powered Enhanced Due Diligence Strategies for Increase...
Unlocking Insights: AI-powered Enhanced Due Diligence Strategies for Increase...
RNayak3
 
Comprehensive Water Damage Restoration Services
Comprehensive Water Damage Restoration ServicesComprehensive Water Damage Restoration Services
Comprehensive Water Damage Restoration Services
kleenupdisaster
 
Maximizing Efficiency with Integrated Water Management Systems
Maximizing Efficiency with Integrated Water Management SystemsMaximizing Efficiency with Integrated Water Management Systems
Maximizing Efficiency with Integrated Water Management Systems
Irri Design Studio
 
Best Catering Event Planner Miso-Hungry.pptx
Best Catering Event Planner  Miso-Hungry.pptxBest Catering Event Planner  Miso-Hungry.pptx
Best Catering Event Planner Miso-Hungry.pptx
Miso Hungry
 
Bulk SMS Service Provider In Mumbai | sms2orbit
Bulk SMS Service Provider In Mumbai | sms2orbitBulk SMS Service Provider In Mumbai | sms2orbit
Bulk SMS Service Provider In Mumbai | sms2orbit
Orbit Messaging Hub
 
Inspect Edge & NSPIRE Inspection Application - Streamline Housing Inspections
Inspect Edge & NSPIRE Inspection Application - Streamline Housing InspectionsInspect Edge & NSPIRE Inspection Application - Streamline Housing Inspections
Inspect Edge & NSPIRE Inspection Application - Streamline Housing Inspections
inspectedge1
 
Delightful Finds: Unveiling the Power of Gifts Under 100
Delightful Finds: Unveiling the Power of Gifts Under 100Delightful Finds: Unveiling the Power of Gifts Under 100
Delightful Finds: Unveiling the Power of Gifts Under 100
JoyTree Global
 
Get your dream bridal look with top North Indian makeup artist - Pallavi Kadale
Get your dream bridal look with top North Indian makeup artist - Pallavi KadaleGet your dream bridal look with top North Indian makeup artist - Pallavi Kadale
Get your dream bridal look with top North Indian makeup artist - Pallavi Kadale
Pallavi Makeup Artist
 
BesT panDit Ji LoVe problem solution 9463629203 UK uSA California New Zealand...
BesT panDit Ji LoVe problem solution 9463629203 UK uSA California New Zealand...BesT panDit Ji LoVe problem solution 9463629203 UK uSA California New Zealand...
BesT panDit Ji LoVe problem solution 9463629203 UK uSA California New Zealand...
gitapress3
 
Chandigarh call garal serives 9512450098
Chandigarh call garal serives 9512450098Chandigarh call garal serives 9512450098
Chandigarh call garal serives 9512450098
Chandigarh export services garal
 
SECUREX UK FOR SECURITY SERVICES AND MOBILE PATROL
SECUREX UK FOR SECURITY SERVICES AND MOBILE PATROLSECUREX UK FOR SECURITY SERVICES AND MOBILE PATROL
SECUREX UK FOR SECURITY SERVICES AND MOBILE PATROL
securexukweb
 
Office Business Furnishings | Office Equipment
Office Business Furnishings |  Office EquipmentOffice Business Furnishings |  Office Equipment
Office Business Furnishings | Office Equipment
OFWD
 
Waikiki Sunset Catamaran ! MAITAI Catamaran
Waikiki Sunset Catamaran !  MAITAI CatamaranWaikiki Sunset Catamaran !  MAITAI Catamaran
Waikiki Sunset Catamaran ! MAITAI Catamaran
maitaicatamaran
 

Recently uploaded (20)

Reliable Logistics Solutions - Truxcargo
Reliable Logistics Solutions - TruxcargoReliable Logistics Solutions - Truxcargo
Reliable Logistics Solutions - Truxcargo
 
WORK PERMIT IN BULGARIA | Work Visa Services
WORK PERMIT IN BULGARIA | Work Visa ServicesWORK PERMIT IN BULGARIA | Work Visa Services
WORK PERMIT IN BULGARIA | Work Visa Services
 
All Trophies at Trophy-World Malaysia | Custom Trophies & Plaques Supplier
All Trophies at Trophy-World Malaysia | Custom Trophies & Plaques SupplierAll Trophies at Trophy-World Malaysia | Custom Trophies & Plaques Supplier
All Trophies at Trophy-World Malaysia | Custom Trophies & Plaques Supplier
 
Nature’s Paradise Glamorous And Sustainable Designs For Your Outdoor Living S...
Nature’s Paradise Glamorous And Sustainable Designs For Your Outdoor Living S...Nature’s Paradise Glamorous And Sustainable Designs For Your Outdoor Living S...
Nature’s Paradise Glamorous And Sustainable Designs For Your Outdoor Living S...
 
Colors of Wall Paint and Their Mentally Properties.pptx
Colors of Wall Paint and Their Mentally Properties.pptxColors of Wall Paint and Their Mentally Properties.pptx
Colors of Wall Paint and Their Mentally Properties.pptx
 
How Does Littering Affect the Environment.
How Does Littering Affect the Environment.How Does Littering Affect the Environment.
How Does Littering Affect the Environment.
 
Are Gutters Necessary? Explore the details now!
Are Gutters Necessary? Explore the details now!Are Gutters Necessary? Explore the details now!
Are Gutters Necessary? Explore the details now!
 
Unlocking Insights: AI-powered Enhanced Due Diligence Strategies for Increase...
Unlocking Insights: AI-powered Enhanced Due Diligence Strategies for Increase...Unlocking Insights: AI-powered Enhanced Due Diligence Strategies for Increase...
Unlocking Insights: AI-powered Enhanced Due Diligence Strategies for Increase...
 
Comprehensive Water Damage Restoration Services
Comprehensive Water Damage Restoration ServicesComprehensive Water Damage Restoration Services
Comprehensive Water Damage Restoration Services
 
Maximizing Efficiency with Integrated Water Management Systems
Maximizing Efficiency with Integrated Water Management SystemsMaximizing Efficiency with Integrated Water Management Systems
Maximizing Efficiency with Integrated Water Management Systems
 
Best Catering Event Planner Miso-Hungry.pptx
Best Catering Event Planner  Miso-Hungry.pptxBest Catering Event Planner  Miso-Hungry.pptx
Best Catering Event Planner Miso-Hungry.pptx
 
Bulk SMS Service Provider In Mumbai | sms2orbit
Bulk SMS Service Provider In Mumbai | sms2orbitBulk SMS Service Provider In Mumbai | sms2orbit
Bulk SMS Service Provider In Mumbai | sms2orbit
 
Inspect Edge & NSPIRE Inspection Application - Streamline Housing Inspections
Inspect Edge & NSPIRE Inspection Application - Streamline Housing InspectionsInspect Edge & NSPIRE Inspection Application - Streamline Housing Inspections
Inspect Edge & NSPIRE Inspection Application - Streamline Housing Inspections
 
Delightful Finds: Unveiling the Power of Gifts Under 100
Delightful Finds: Unveiling the Power of Gifts Under 100Delightful Finds: Unveiling the Power of Gifts Under 100
Delightful Finds: Unveiling the Power of Gifts Under 100
 
Get your dream bridal look with top North Indian makeup artist - Pallavi Kadale
Get your dream bridal look with top North Indian makeup artist - Pallavi KadaleGet your dream bridal look with top North Indian makeup artist - Pallavi Kadale
Get your dream bridal look with top North Indian makeup artist - Pallavi Kadale
 
BesT panDit Ji LoVe problem solution 9463629203 UK uSA California New Zealand...
BesT panDit Ji LoVe problem solution 9463629203 UK uSA California New Zealand...BesT panDit Ji LoVe problem solution 9463629203 UK uSA California New Zealand...
BesT panDit Ji LoVe problem solution 9463629203 UK uSA California New Zealand...
 
Chandigarh call garal serives 9512450098
Chandigarh call garal serives 9512450098Chandigarh call garal serives 9512450098
Chandigarh call garal serives 9512450098
 
SECUREX UK FOR SECURITY SERVICES AND MOBILE PATROL
SECUREX UK FOR SECURITY SERVICES AND MOBILE PATROLSECUREX UK FOR SECURITY SERVICES AND MOBILE PATROL
SECUREX UK FOR SECURITY SERVICES AND MOBILE PATROL
 
Office Business Furnishings | Office Equipment
Office Business Furnishings |  Office EquipmentOffice Business Furnishings |  Office Equipment
Office Business Furnishings | Office Equipment
 
Waikiki Sunset Catamaran ! MAITAI Catamaran
Waikiki Sunset Catamaran !  MAITAI CatamaranWaikiki Sunset Catamaran !  MAITAI Catamaran
Waikiki Sunset Catamaran ! MAITAI Catamaran
 

AWS as platform for scalable applications

  • 1. Amazon Web Services. From infrastructure to platform Roman Gomolko rg@audienceproject.com
  • 2. AudienceProject • Developing products that allow to learn digital audiences • Started using AWS more than 5 years ago • Fully migrated to AWS more than 2 years ago • Processing 4 billions requests monthly • Generating reports based on 8 billions of requests with batched reports • Online reports on 300 millions of records • Used ~40% of services provided by AWS • Totally happy regarding using AWS
  • 4. Amazon provides Infrastructure as a Services • Virtual server (EC2) with operating system preinstalled - Wide choice of instance types optimized for CPU, RAM or I/O - Preinstalled operating systems or custom images - Pay per hour of use • Magnetic or SSD drives - attach to running instances - provisioned or size-dependent IOPs - up to 64 Tb (SSD) - backups • Networking & Firewall - Easy IP management - Load balancers - VPN & VPC
  • 5.
  • 7. Today’s agenda YA.LS * yet another link shortener * http://ya.ls/dx9 ↣ http://buildstuff.com.ua/
  • 8. Add packages { "name": "yals", "main": "index.js", "scripts": { "start": "node index.js" }, "private": true, "dependencies": { "body-parser": "^1.14.1", "express": "^4.13.3", "node-localstorage": "^0.6.0", "short-hash": "^1.0.0" } }
  • 9. Bootstrap your application var express = require('express'); var bodyParser = require('body-parser'); var shortHash = require('short-hash'); var LocalStorage = LocalStorage; var storage = new (require('node-localstorage').LocalStorage)('./storage'); var app = express(); app.use(express.static(__dirname + '/public')); app.use(bodyParser.json()); app.get('/', function (req, res) { res.render('index.html') });
  • 10. Add your shorten logic app.post('/shorten', function (req, res) { var url = req.body && req.body.url; if (!url) { return res.status(400).json({message: 'no URL'}).end(); } else { var hash = shortHash(url); storage.setItem(hash, url); res.json({ hash: hash, shortUrl: process.env.HOST + hash, targetUrl: url}); } })
  • 11. Add your redirection logic app.get('/:key', function (req, res) { var url = storage.getItem(req.params.key); if (url) { res.redirect(302, url); } else { res.status(404).send('Sorry, link not found'); } }); var server = app.listen(process.env.PORT || 8888);
  • 12. <form method="post" onsubmit="shorten(); return false;"> <input type="url" id="url" placeholder="Paste your URL here"/> <input type="submit" value="Shorten"> <div id="recent-links"></div> </form> Create fancy UI
  • 13. window.shorten = function () { fetch('/shorten', { method: 'post', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({url: document.getElementById('url').value}) }).then(function (response) { var url = response.json().shortUrl; var msg = url ? '<a href="' + url + '">' + url + '</a>' : response.message; document.getElementById('recent-links').innerHTML = msg; }); }; Create modern JavaScript frontend
  • 16. Elastic Beanstalk • Quick deployment and management of Web application • PHP, ASP.NET, Python, NodeJS, Docker etc • No need to setup infrastructure • Performance metrics • Scale up and scale down • Rolling updates
  • 17. Deploy your application eb init shortener --region eu-west-1 --platform "node.js" eb create demo eb setenv HOST=http://ya.ls/ eb deploy eb open
  • 19. Near real-time metrics of your application
  • 21. Elastic Beanstalk - scaled setup
  • 22. Traditional SQL databases hosteb my Amazon - RDS • Fully managed traditional SQL servers - MySQL - MS SQL - PostgreSQL - Oracle • Variety of server sizes • Licenses included into price • Automated backups • Restore to point at a time
  • 23. • Document DB • No limits on size • Provisioned throughput • Differents attribute types including Lists and JSON DynamoDB
  • 24. Get DynamoDB high level API npm install aws-sdk --save var AWS = require("aws-sdk"); AWS.config.update({region: 'eu-west-1'}); var db = new AWS.DynamoDB.DocumentClient(); // <!-- high level SDK
  • 25. Put hash to DynamoDB app.post('/shorten', function (req, res) { var url = req.body && req.body.url; … var hash = shortHash(url); db.put({ TableName: "short_links", Item: {"hash": hash, targetUrl: url} }, function () { storage.setItem(hash, url); res.json(...); }) …
  • 26. Get from DynamoDB var hash = req.params.key; var url = storage.getItem(hash); if (url) { return go(res, url); } db.get( {TableName: "short_links", Key: {"hash": hash}}, function (err, record) { url = record.targetUrl; url && storage.setItem(hash, url); //local cache go(res, url); });
  • 27. Security considerations - IAM • Identity and Access Management • Generate policies that describes - what operations - are allowed or denied - to what AWS resources - (in what circumstances) • Apply policy to: - IAM User identified by Access Key and Secret key - EC2 instance • vim ~/.aws/credentials [dev] aws_access_key_id = AKIA.... aws_secret_access_key = PQC+9o… • AWS_PROFIEL=dev PORT=8000 HOST=http://localhost:8000/ npm run start
  • 29. Adding screenshot functionality var webshot = require('webshot'); webshot(targetUrl, hash + '.png', function(err) { // Screenshot is ready. Where I should save it? });
  • 30. S3 • Virtually unlimited storage • Reliable • Fast • Secure • Accessible from Internet
  • 31. Making screenshot function makeScreenshot(url, hash, callback) { var fileName = hash + '.png'; webshot(url, fileName, function (err) { if (err) { return callback(err); } var stream = fs.createReadStream(fileName) s3.upload({ Bucket: 'yals-screenshots', Key: fileName, ACL: "public-read", ContentType: "image/png", Body: stream }, callback); }); }
  • 32. Using queues for storing screenshotting commands - SQS • Simple Queue System - Send - Receive - Delete • Cheap: $0.5 for 1M requests • Reliable • Durable • Fast
  • 33. Making screenshots using SQS to control flow
  • 34. Screenshotting is just a function. Lambda in on the stage • Invoke code in response to events - File uploads to S3 - DynamoDB table changes - SNS notifications - HTTP requests - Scheduled executions • Just bring your code - Node.JS - Python 2.7 - Java 8 • Pay per invokations and computation power - making 5M screenshots will cost you ~$42* * 512 Mb RAM, 2 minutes timeout
  • 35. Screenshotting function with writing results to DynamoDB exports.handler = function (data, context) { var hash = …; var targetUrl = …; makeScreenshot(hash, targetUrl, function(err, r) { if (err) {return context.fail(err)}; db.put({ TableName: "short_links", Item: {"hash": hash, screenshotUrl: r.Location} }, context.done); }) };
  • 36. Hookup Lambda to new shorten links. DynamoDB streams is on the stage Ordered stream of changes happened to DynamoDB table • Any change in table is recorded • Old record and new record can be stored together with change • Multiple applications processing stream • Lambda can be easily attached
  • 37. Fine tuning screenshotting Lambda exports.handler = function (data, context) { var item = data.Records[0].dynamodb.NewImage; var hash = item.hash.S; var targetUrl = item.targetUrl.S; var screenshotUrl = item.screenshotUrl.S; if (screenshotUrl){ return context.success("Screenshot already taken"); } makeScreenshot(hash, targetUrl, function(err, r) { ...
  • 39. Static content delivery - CloudFront • CDN for static and dynamic content • Web and Streaming distributions • Seamless integration with S3 • Own SSL certificates, free for SNI • Requests logging and delivery to S3 • Serving dynamic content from Beanstalk, Load balancers and own servers • Device detection • Cost effective
  • 41. Need to collect click statistic
  • 42. Storage for statistics - DynamoDB link_click_statistic hash (key) date (sort key) desktop mobile tablet other ddd79ad9 2015-11-22 1050 110 99 4 ddd79ad9 2015-11-23 1301 123 51 1 aa4cbddf 2015-11-22 1513 13 6 2
  • 43. Click stream storage - Kinesis • Ordered events stream • Reliable • Scalable • High performance • Multiple consumers Processing stream • Kinesis Client Library (Java) • Kinesis Multilanguage Daemon (any platform) • Lambda
  • 44. Send to Kinesis function go(req, res, hash, url) { if (url) { var kinesis = new AWS.Kinesis(); var params = { Data: JSON.stringify({"hash": hash, "userAgent": req.header('user- agent')}), PartitionKey: "hash", StreamName: 'yals_clicks' }; kinesis.putRecord(params);
  • 45. Lambda skeleton • Configure batch size (e.g. 1000) • Group batch to collection of structures - hash - date - desktop - mobile - tablet - other • Perform DynamoDB update...
  • 46. Aggregation function exports.handler = function(data, context){ rows = ...; // Agg var params = { TableName: "link_click_statistic", Key: { "hash": row.hash, "date": row.date }, UpdateExpression: "ADD desktop :d, mobile :m, ..."; ExpressionAttributeValues: {":d": row.desktop, ":m": row.mobile...}; }; dynamo.updateItem(params, send_next_item); }
  • 48. Too many setup were done manually CloudFormation • describe services you need • specify policies • use configuration variable • and let Amazon handle it
  • 49. Quick recap • Beanstalk - websites hostings • RDS - hosted relational DB • DynamoDB - document DB with cool features • SQS - simple queue service • S3 - infinite file storage • CloudFront - static and dynamic content delivery • Lambda - running code in response to event • Kinesis - operate with data streams as wizard • IAM - security in cloud • CloudFormation - automated cloud resources provisioning
  • 50. Thank you Checkout sources https://github.com/romanych/yals
  • 51. Further watching • https://www.youtube.com/watch?v=KmHGrONoif4 • https://www.youtube.com/watch?v=8u9wIC1xNt8 • https://www.youtube.com/watch?v=pBLdMCksM3A • https://www.youtube.com/watch?v=ZBxWZ9bgd44 • https://www.youtube.com/watch?v=TnfqJYPjD9I • https://www.youtube.com/watch?v=6R44BADNJA8