SlideShare a Scribd company logo
1 of 51
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 UsersAmazon 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 EC2Kornel 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
 
AutoScaling and Drupal
AutoScaling and DrupalAutoScaling and Drupal
AutoScaling and DrupalPromet 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 2014amoghvk
 
Infrastructure as Code for Beginners
Infrastructure as Code for BeginnersInfrastructure as Code for Beginners
Infrastructure as Code for BeginnersDavid 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 LambdaAmazon Web Services
 
Utah Codecamp Cloud Computing
Utah Codecamp Cloud ComputingUtah Codecamp Cloud Computing
Utah Codecamp Cloud ComputingTom Creighton
 
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, 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
 
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
 
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 CloudAmazon 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 ServicesAmazon 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 ServicesAmazon Web Services
 
Application Lifecycle Management on AWS
Application Lifecycle Management on AWSApplication Lifecycle Management on AWS
Application Lifecycle Management on AWSDavid Mat
 
Running your First Application on AWS
Running your First Application on AWSRunning your First Application on AWS
Running your First Application on AWSAmazon 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 AnalystsAvere 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 AWSAmazon Web Services
 
Automating Security in your IaC Pipeline
Automating Security in your IaC PipelineAutomating Security in your IaC Pipeline
Automating Security in your IaC PipelineAmazon 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
 
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
 
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 ElishaHelen 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, 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...
 
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
 
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

Call Girls In Lahore || 03274100048 ||Lahore Call Girl Available 24/7
Call Girls In Lahore || 03274100048 ||Lahore Call Girl Available 24/7Call Girls In Lahore || 03274100048 ||Lahore Call Girl Available 24/7
Call Girls In Lahore || 03274100048 ||Lahore Call Girl Available 24/7Sana Rajpoot
 
Bhopal ❤CALL GIRL 9874883814 ❤CALL GIRLS IN Bhopal ESCORT SERVICE❤CALL GIRL IN
Bhopal ❤CALL GIRL 9874883814 ❤CALL GIRLS IN Bhopal ESCORT SERVICE❤CALL GIRL INBhopal ❤CALL GIRL 9874883814 ❤CALL GIRLS IN Bhopal ESCORT SERVICE❤CALL GIRL IN
Bhopal ❤CALL GIRL 9874883814 ❤CALL GIRLS IN Bhopal ESCORT SERVICE❤CALL GIRL INoyomaster143
 
Berhampur Call Girl 97487*63073 Call Girls in Berhampur Escort service book now
Berhampur  Call Girl 97487*63073 Call Girls in Berhampur Escort service book nowBerhampur  Call Girl 97487*63073 Call Girls in Berhampur Escort service book now
Berhampur Call Girl 97487*63073 Call Girls in Berhampur Escort service book nowapshanarani255
 
Girls For Night in Islamabad | 03274100048 🔞
Girls For Night in Islamabad | 03274100048 🔞Girls For Night in Islamabad | 03274100048 🔞
Girls For Night in Islamabad | 03274100048 🔞Ifra Zohaib
 
Mysore Call girl service 6289102337 Mysore escort service
Mysore Call girl service 6289102337 Mysore escort serviceMysore Call girl service 6289102337 Mysore escort service
Mysore Call girl service 6289102337 Mysore escort servicemaheshsingh64440
 
Shimla 💋 Call Girl 9748763073 Call Girls in Shimla Escort service book now
Shimla 💋  Call Girl 9748763073 Call Girls in Shimla Escort service book nowShimla 💋  Call Girl 9748763073 Call Girls in Shimla Escort service book now
Shimla 💋 Call Girl 9748763073 Call Girls in Shimla Escort service book nowapshanarani255
 
Chennai ❣️ Call Girl 97487*63073 Call Girls in Chennai Escort service book now
Chennai ❣️ Call Girl 97487*63073 Call Girls in Chennai Escort service book nowChennai ❣️ Call Girl 97487*63073 Call Girls in Chennai Escort service book now
Chennai ❣️ Call Girl 97487*63073 Call Girls in Chennai Escort service book nowapshanarani255
 
+91-9310611641 Russian Call Girls In New Delhi Independent Russian Call Girls...
+91-9310611641 Russian Call Girls In New Delhi Independent Russian Call Girls...+91-9310611641 Russian Call Girls In New Delhi Independent Russian Call Girls...
+91-9310611641 Russian Call Girls In New Delhi Independent Russian Call Girls...teencall080
 
Hyderabad ❤CALL GIRL 9874883814 ❤CALL GIRLS IN Hyderabad ESCORT SERVICE❤CALL ...
Hyderabad ❤CALL GIRL 9874883814 ❤CALL GIRLS IN Hyderabad ESCORT SERVICE❤CALL ...Hyderabad ❤CALL GIRL 9874883814 ❤CALL GIRLS IN Hyderabad ESCORT SERVICE❤CALL ...
Hyderabad ❤CALL GIRL 9874883814 ❤CALL GIRLS IN Hyderabad ESCORT SERVICE❤CALL ...oyomaster143
 
Call Girls | 😏💦 03274100048 | Call Girls Near Me
Call Girls | 😏💦 03274100048 | Call Girls Near MeCall Girls | 😏💦 03274100048 | Call Girls Near Me
Call Girls | 😏💦 03274100048 | Call Girls Near MeIfra Zohaib
 
Call Girls in Saket (delhi) call me [9818683771 ] escort service 24X7
Call Girls in Saket (delhi) call me [9818683771 ] escort service 24X7Call Girls in Saket (delhi) call me [9818683771 ] escort service 24X7
Call Girls in Saket (delhi) call me [9818683771 ] escort service 24X7soniya singh
 
Call Girl Rohini ❤️7065000506 Pooja@ Rohini Call Girls Near Me ❤️♀️@ Sexy Cal...
Call Girl Rohini ❤️7065000506 Pooja@ Rohini Call Girls Near Me ❤️♀️@ Sexy Cal...Call Girl Rohini ❤️7065000506 Pooja@ Rohini Call Girls Near Me ❤️♀️@ Sexy Cal...
Call Girl Rohini ❤️7065000506 Pooja@ Rohini Call Girls Near Me ❤️♀️@ Sexy Cal...Sheetaleventcompany
 
Call Girls In {Connaught Place Delhi} 9667938988 IndianRussian High Profile E...
Call Girls In {Connaught Place Delhi} 9667938988 IndianRussian High Profile E...Call Girls In {Connaught Place Delhi} 9667938988 IndianRussian High Profile E...
Call Girls In {Connaught Place Delhi} 9667938988 IndianRussian High Profile E...aakahthapa70
 
Nagpur ❤CALL GIRL 9874883814 ❤CALL GIRLS IN nagpur ESCORT SERVICE❤CALL GIRL I...
Nagpur ❤CALL GIRL 9874883814 ❤CALL GIRLS IN nagpur ESCORT SERVICE❤CALL GIRL I...Nagpur ❤CALL GIRL 9874883814 ❤CALL GIRLS IN nagpur ESCORT SERVICE❤CALL GIRL I...
Nagpur ❤CALL GIRL 9874883814 ❤CALL GIRLS IN nagpur ESCORT SERVICE❤CALL GIRL I...oyomaster143
 
Call Now ☎9870417354|| Call Girls in Noida Sector 18 Escort Service Noida N.C.R.
Call Now ☎9870417354|| Call Girls in Noida Sector 18 Escort Service Noida N.C.R.Call Now ☎9870417354|| Call Girls in Noida Sector 18 Escort Service Noida N.C.R.
Call Now ☎9870417354|| Call Girls in Noida Sector 18 Escort Service Noida N.C.R.riyadelhic riyadelhic
 
NAGPUR CALL GIRL 7857803690 LOW PRICE ESCORT SERVICE
NAGPUR CALL GIRL 7857803690  LOW PRICE  ESCORT SERVICENAGPUR CALL GIRL 7857803690  LOW PRICE  ESCORT SERVICE
NAGPUR CALL GIRL 7857803690 LOW PRICE ESCORT SERVICEayushi9330
 
Hire 💕 8617370543 Uttara Kannada Call Girls Service Call Girls Agency
Hire 💕 8617370543 Uttara Kannada Call Girls Service Call Girls AgencyHire 💕 8617370543 Uttara Kannada Call Girls Service Call Girls Agency
Hire 💕 8617370543 Uttara Kannada Call Girls Service Call Girls AgencyJia Oberoi
 
Rajkot Call Girls Contact Number +919358341802 Call Girls In Rajkot
Rajkot Call Girls Contact Number +919358341802 Call Girls In RajkotRajkot Call Girls Contact Number +919358341802 Call Girls In Rajkot
Rajkot Call Girls Contact Number +919358341802 Call Girls In RajkotSivanyaPandeya
 
Indore ❣️Call Girl 97487*63073 Call Girls in Indore Escort service book now
Indore  ❣️Call Girl 97487*63073 Call Girls in Indore Escort service book nowIndore  ❣️Call Girl 97487*63073 Call Girls in Indore Escort service book now
Indore ❣️Call Girl 97487*63073 Call Girls in Indore Escort service book nowapshanarani255
 

Recently uploaded (20)

Call Girls In Lahore || 03274100048 ||Lahore Call Girl Available 24/7
Call Girls In Lahore || 03274100048 ||Lahore Call Girl Available 24/7Call Girls In Lahore || 03274100048 ||Lahore Call Girl Available 24/7
Call Girls In Lahore || 03274100048 ||Lahore Call Girl Available 24/7
 
Bhopal ❤CALL GIRL 9874883814 ❤CALL GIRLS IN Bhopal ESCORT SERVICE❤CALL GIRL IN
Bhopal ❤CALL GIRL 9874883814 ❤CALL GIRLS IN Bhopal ESCORT SERVICE❤CALL GIRL INBhopal ❤CALL GIRL 9874883814 ❤CALL GIRLS IN Bhopal ESCORT SERVICE❤CALL GIRL IN
Bhopal ❤CALL GIRL 9874883814 ❤CALL GIRLS IN Bhopal ESCORT SERVICE❤CALL GIRL IN
 
Berhampur Call Girl 97487*63073 Call Girls in Berhampur Escort service book now
Berhampur  Call Girl 97487*63073 Call Girls in Berhampur Escort service book nowBerhampur  Call Girl 97487*63073 Call Girls in Berhampur Escort service book now
Berhampur Call Girl 97487*63073 Call Girls in Berhampur Escort service book now
 
Girls For Night in Islamabad | 03274100048 🔞
Girls For Night in Islamabad | 03274100048 🔞Girls For Night in Islamabad | 03274100048 🔞
Girls For Night in Islamabad | 03274100048 🔞
 
Mysore Call girl service 6289102337 Mysore escort service
Mysore Call girl service 6289102337 Mysore escort serviceMysore Call girl service 6289102337 Mysore escort service
Mysore Call girl service 6289102337 Mysore escort service
 
➥🔝9953056974 🔝▻ Anand Vihar Call-girl in Women Seeking Men 🔝Delhi🔝 NCR
➥🔝9953056974 🔝▻ Anand Vihar Call-girl in Women Seeking Men 🔝Delhi🔝 NCR➥🔝9953056974 🔝▻ Anand Vihar Call-girl in Women Seeking Men 🔝Delhi🔝 NCR
➥🔝9953056974 🔝▻ Anand Vihar Call-girl in Women Seeking Men 🔝Delhi🔝 NCR
 
Shimla 💋 Call Girl 9748763073 Call Girls in Shimla Escort service book now
Shimla 💋  Call Girl 9748763073 Call Girls in Shimla Escort service book nowShimla 💋  Call Girl 9748763073 Call Girls in Shimla Escort service book now
Shimla 💋 Call Girl 9748763073 Call Girls in Shimla Escort service book now
 
Chennai ❣️ Call Girl 97487*63073 Call Girls in Chennai Escort service book now
Chennai ❣️ Call Girl 97487*63073 Call Girls in Chennai Escort service book nowChennai ❣️ Call Girl 97487*63073 Call Girls in Chennai Escort service book now
Chennai ❣️ Call Girl 97487*63073 Call Girls in Chennai Escort service book now
 
+91-9310611641 Russian Call Girls In New Delhi Independent Russian Call Girls...
+91-9310611641 Russian Call Girls In New Delhi Independent Russian Call Girls...+91-9310611641 Russian Call Girls In New Delhi Independent Russian Call Girls...
+91-9310611641 Russian Call Girls In New Delhi Independent Russian Call Girls...
 
Hyderabad ❤CALL GIRL 9874883814 ❤CALL GIRLS IN Hyderabad ESCORT SERVICE❤CALL ...
Hyderabad ❤CALL GIRL 9874883814 ❤CALL GIRLS IN Hyderabad ESCORT SERVICE❤CALL ...Hyderabad ❤CALL GIRL 9874883814 ❤CALL GIRLS IN Hyderabad ESCORT SERVICE❤CALL ...
Hyderabad ❤CALL GIRL 9874883814 ❤CALL GIRLS IN Hyderabad ESCORT SERVICE❤CALL ...
 
Call Girls | 😏💦 03274100048 | Call Girls Near Me
Call Girls | 😏💦 03274100048 | Call Girls Near MeCall Girls | 😏💦 03274100048 | Call Girls Near Me
Call Girls | 😏💦 03274100048 | Call Girls Near Me
 
Call Girls in Saket (delhi) call me [9818683771 ] escort service 24X7
Call Girls in Saket (delhi) call me [9818683771 ] escort service 24X7Call Girls in Saket (delhi) call me [9818683771 ] escort service 24X7
Call Girls in Saket (delhi) call me [9818683771 ] escort service 24X7
 
Call Girl Rohini ❤️7065000506 Pooja@ Rohini Call Girls Near Me ❤️♀️@ Sexy Cal...
Call Girl Rohini ❤️7065000506 Pooja@ Rohini Call Girls Near Me ❤️♀️@ Sexy Cal...Call Girl Rohini ❤️7065000506 Pooja@ Rohini Call Girls Near Me ❤️♀️@ Sexy Cal...
Call Girl Rohini ❤️7065000506 Pooja@ Rohini Call Girls Near Me ❤️♀️@ Sexy Cal...
 
Call Girls In {Connaught Place Delhi} 9667938988 IndianRussian High Profile E...
Call Girls In {Connaught Place Delhi} 9667938988 IndianRussian High Profile E...Call Girls In {Connaught Place Delhi} 9667938988 IndianRussian High Profile E...
Call Girls In {Connaught Place Delhi} 9667938988 IndianRussian High Profile E...
 
Nagpur ❤CALL GIRL 9874883814 ❤CALL GIRLS IN nagpur ESCORT SERVICE❤CALL GIRL I...
Nagpur ❤CALL GIRL 9874883814 ❤CALL GIRLS IN nagpur ESCORT SERVICE❤CALL GIRL I...Nagpur ❤CALL GIRL 9874883814 ❤CALL GIRLS IN nagpur ESCORT SERVICE❤CALL GIRL I...
Nagpur ❤CALL GIRL 9874883814 ❤CALL GIRLS IN nagpur ESCORT SERVICE❤CALL GIRL I...
 
Call Now ☎9870417354|| Call Girls in Noida Sector 18 Escort Service Noida N.C.R.
Call Now ☎9870417354|| Call Girls in Noida Sector 18 Escort Service Noida N.C.R.Call Now ☎9870417354|| Call Girls in Noida Sector 18 Escort Service Noida N.C.R.
Call Now ☎9870417354|| Call Girls in Noida Sector 18 Escort Service Noida N.C.R.
 
NAGPUR CALL GIRL 7857803690 LOW PRICE ESCORT SERVICE
NAGPUR CALL GIRL 7857803690  LOW PRICE  ESCORT SERVICENAGPUR CALL GIRL 7857803690  LOW PRICE  ESCORT SERVICE
NAGPUR CALL GIRL 7857803690 LOW PRICE ESCORT SERVICE
 
Hire 💕 8617370543 Uttara Kannada Call Girls Service Call Girls Agency
Hire 💕 8617370543 Uttara Kannada Call Girls Service Call Girls AgencyHire 💕 8617370543 Uttara Kannada Call Girls Service Call Girls Agency
Hire 💕 8617370543 Uttara Kannada Call Girls Service Call Girls Agency
 
Rajkot Call Girls Contact Number +919358341802 Call Girls In Rajkot
Rajkot Call Girls Contact Number +919358341802 Call Girls In RajkotRajkot Call Girls Contact Number +919358341802 Call Girls In Rajkot
Rajkot Call Girls Contact Number +919358341802 Call Girls In Rajkot
 
Indore ❣️Call Girl 97487*63073 Call Girls in Indore Escort service book now
Indore  ❣️Call Girl 97487*63073 Call Girls in Indore Escort service book nowIndore  ❣️Call Girl 97487*63073 Call Girls in Indore Escort service book now
Indore ❣️Call Girl 97487*63073 Call Girls in Indore Escort service book now
 

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