SlideShare a Scribd company logo
1 of 69
Creating Scalable Solutions
with
Amazon Cloud Services
ONDREJ BALAS @ONDREJBALAS
WWW.ONDREJBALAS.COM
ONDREJ@ONDREJBALAS.COM
ONDREJ BALAS
Microsoft MVP in C#
Writer for Visual Studio Magazine
Owner of UseTech Design (est. 2001)
Building software that drives business
Serial Entrepreneur
WWW.ONDREJBALAS.COM
ONDREJ@ONDREJBALAS.COM
@ONDREJBALAS
Data
Acquisition
Application
Data
Source
Data
Source
Data
Source
Data
Source
Data
Source
Data
Source
Data
Source
Data
Source
Data
Source
Data
Source
Data
Source
Data
Source
Data
Source
Data
Source
Data
Source
Data
Source
Data
Acquisition
Application
Data
Source
Data
Source
Data
Source
Data
Source
Data
Source
Data
Source
Data
Source
Data
Source
Data
Source
Data
Source
Data
Source
Data
Source
Data
Source
Data
Acquisition
Application
Elastic Compute Cloud (EC2)
INFRASTRUCTURE AS A SERVICE (IAAS)
Virtual Machines
Provisioned within minutes
Choose your own AMI (disk image) or use a pre-existing one
Pay by the hour – Linux as low as $0.003 per hour
or Windows for $0.006 per hour
Many machine sizes to choose from
EC2 Instance
AMI
When an EC2 Instance
is created, its hard disk
contents are copied
from an AMI
EC2 Instance
AMI
When an EC2 Instance
is created, its hard disk
contents are copied
from an AMI
EC2 Instance
AMI
When an EC2 Instance
is created, its hard disk
contents are copied
from an AMI
Internet
Security Group
A security group acts
as the firewall between
the internet and the
instance
An AMI can be created
by copying the current
state of an EC2 instance
EC2 Instance
AMI
When an EC2 Instance
is created, its hard disk
contents are copied
from an AMI
Internet
Security Group
A security group acts
as the firewall between
the internet and the
instance
Key Pair
An instance is assigned a key pair at
creation time, and the same one must be
later used to gain access to the instance.
Launching the Instance
DEMO – AWS CONTROL PANEL
AWSCredentials credentials = new BasicAWSCredentials("AccessKey", "SecretKey");
IAmazonEC2 client = new AmazonEC2Client(credentials, RegionEndpoint.USEast1);
DescribeInstancesResponse describeInstancesResponse = client.DescribeInstances();
List<Reservation> reservations = describeInstancesResponse.Reservations;
foreach (Instance instance in reservations.SelectMany(x => x.Instances))
{
Console.WriteLine("Instance with ID {0} is currently {1}",
instance.InstanceId,
instance.State.Name);
}
Accessing Instances Programmatically
AWSCredentials credentials = new BasicAWSCredentials("AccessKey", "SecretKey");
DescribeInstancesRequest request = new DescribeInstancesRequest();
request.Filters.Add(new Filter("instance-state-code",
new List<string>() {"0", "16"}));
List<Reservation> reservations = client.DescribeInstances(request).Reservations;
List<Reservation> reservations = client.DescribeInstances().Reservations;
foreach (Instance instance in reservations.SelectMany(x => x.Instances))
{
Console.WriteLine("Instance with ID {0} is currently {1}",
instance.InstanceId,
instance.State.Name);
}
Accessing Instances Programmatically
State codes
• 0 pending
• 16 running
• 32 shutting-down
• 48 terminated
• 64 stopping
• 80 stopped
Instrumentation
DEMO - MANAGING INSTANCES ACROSS THE GLOBE
Worker Service
Installed onto my Base AMI
Updateable from the Instrumentation
Uses WebAPI Selfhost to manage requests
And TopShelf to make it a service
Moving Bits Around
THERE’S MORE TO IT THAN JUST SCALING SERVERS UP AND DOWN
SQS (Simple Queue Service)
Queue ConsumerPublishers
Publishers send
messages to the queue
Consumer periodically checks
the queue for messages
SQS (Simple Queue Service)
Consumer
Consumer watches for
messages
QueuePublishers
Publishers send
messages to the queue
Consumer controls throughput
by only sending one write at a
time to the database
Database
SQS (Simple Queue Service)
Queue ConsumersPublishers
Publishers send
messages to the queue
Consumers take messages
from the queue and process
them in parallel
SQS (Simple Queue Service)
Queue
Consumers
& PublishersPublishers
Final
ConsumerQueue
SQS (Simple Queue Service)
Writing to a queue
AmazonSQSClient client = new AmazonSQSClient(credentials, RegionEndpoint.USEast1);
string message = "my message";
string queueUrl = "https://sqs.us-east-1.amazonaws.com/025631894481/aws-talk";
SendMessageResponse sendMessageResponse = client.SendMessage(queueUrl, message);
SQS (Simple Queue Service)
Reading from a queue
AmazonSQSClient client = new AmazonSQSClient(credentials, RegionEndpoint.USEast1);
string queueUrl = "https://sqs.us-east-1.amazonaws.com/025631894481/aws-talk";
ReceiveMessageResponse response = client.ReceiveMessage(queueUrl);
foreach (Message message in response.Messages)
{
// Do something with the message
client.DeleteMessage(queueUrl, message.ReceiptHandle);
}
SQS (Simple Queue Service)
Reading from a queue
AmazonSQSClient client = new AmazonSQSClient(credentials, RegionEndpoint.USEast1);
string queueUrl = "https://sqs.us-east-1.amazonaws.com/025631894481/aws-talk";
ReceiveMessageRequest request = new ReceiveMessageRequest(queueUrl);
request.MaxNumberOfMessages = 1;
ReceiveMessageResponse response = client.ReceiveMessage(request);
foreach (Message message in response.Messages)
{
// Do something with the message
client.DeleteMessage(queueUrl, message.ReceiptHandle);
}
SQS – Important Notes
Messages are not guaranteed to be delivered in order
In rare circumstances, messages can be delivered more than once
Dead letter queues can be created, allowing failed items to be
automatically moved after some number of failures
SNS (Simple Notification Service)
Topic ConsumersPublishers
Publishers send
messages to the topic
Consumers receive all
messages sent to the topic
SNS (Simple Notification Service)
Topic ConsumersPublishers
Publishers send
messages to the topic
All consumers receive all
messages sent to the topic
SQS Queue
SNS (Simple Notification Service)
Messages are not requested, they are pushed to subscribers
Subscribers are just endpoints
Endpoints can be: HTTP, HTTPS, Email, Email-JSON, SMS, SQS
Storing Data
LOTS OF WAYS TO DO IT
S3 (Simple Storage Service)
Like a simple key-value store
Great for storing files
Store up to 5TB per object
Extremely scalable and durable
Highly available
Glacier
Similar to S3
Meant for archival – long term storage is durable and cheap
From the Glacier website:
“Glacier is designed with the expectation that retrievals are infrequent and unusual, and data
will be stored for extended periods of time. You can retrieve up to 5% of your average monthly
storage (pro-rated daily) for free each month. If you choose to retrieve more than this amount of
data in a month, you are charged a retrieval fee starting at $0.01 per gigabyte.”
Source: http://aws.amazon.com/glacier/pricing/
FastGlacier
Data
SimpleDB
DynamoDB
RDS (Managed Relational Database Service)
SimpleDB
Writing data
AmazonSimpleDBClient client = new AmazonSimpleDBClient(credentials,
RegionEndpoint.USEast1);
CreateDomainRequest request = new CreateDomainRequest("aws-talk");
CreateDomainResponse response = client.CreateDomain(request);
PutAttributesRequest putData = new PutAttributesRequest("aws-talk", "products/" +
Guid.NewGuid().ToString(),
new List<ReplaceableAttribute>()
{
new ReplaceableAttribute("Name", "Couch", true),
new ReplaceableAttribute("Price", "20", true)
});
client.PutAttributes(putData);
SimpleDB
Reading data
AmazonSimpleDBClient client = new AmazonSimpleDBClient(credentials,RegionEndpoint.USEast1);
// attribute names are case sensitive
// comparisons are lexicographical. no numeric comparisons exist
SelectRequest request = new SelectRequest(
"select * from `aws-talk` WHERE `Price` > '01'");
SelectResponse response = client.Select(request);
foreach (Item item in response.Items)
{
Console.WriteLine("Item {0} has attributes: {1}",
item.Name, String.Join(" ; ", item.Attributes.Select(a => string.Format("{0}={1}",
a.Name, a.Value))));
}
Pricing
Estimating it can be difficult
“Fixed” costs such as instance-hours or
gigabyte-months aren’t too bad
Requests are counted in “Cost per million”
And then factor in bandwidth, too.
Usually ends up being really cheap!
So Many Services to Choose From
Thanks!
ONDREJ BALAS @ONDREJBALAS
WWW.ONDREJBALAS.COM
ONDREJ@ONDREJBALAS.COM
@ONDREJBALAS
GITHUB.COM/ONDREJBALAS
Notes & Other Things
IF YOU KEEP GOING YOU WILL RUN INTO MY NOTES
Demo Icon
Top Right Corner
SimpleDB
DynamoDB
RDS (Relational Database Service)
After creating a new account
• Go to “Security Credential”
• Create a user
• Make note of the Access Key ID and Secret Access Key
• Create a group to put that user into. I gave it power user
permissions
• Create the Security Group
• Create the Key Pair
• Launch the instance to create the AMI from
• Create the AMI
• Copy the AMI to all other regions
• Begin launching instances from that AMI
Transferring Data
Storing Data
EC2
• Code: Launch a VM, get a list of VMs, kill a VM.
• Mention AMIs, Security Groups & Key Pairs
• Updating applications that are currently running
• Demo: Launch some VMs all around the world using an
existing AMI that I’ve deployed my “worker” to once.
• Workers run selfhost WebAPI so I can query their status
• Workers can auto-update(?) or can be told to update
• Instrumentation allows me to list VMs, update, kill, and see
other health/status points
EC2
• Before creating an instance, there are a few important things
• AMI = Amazon Machine Image.
• Launch an instance based off a public AMI first, and then
customize it as needed by installing your services. Then
you can save the AMI into that region and copy it into all
other regions as needed.
• Security Group – Like a set of Firewall rules
• VPC = Virtual Private Cloud. A private network for your
instances. (Only within a region???)
SQS
• Need a way to feed data to the workers, to give it work to do
• Queues are often used at application boundaries (seams)
• Common queueing patterns slide
• Talk about AWS implementation of those patterns
Data
• S3 – Basically just online file storage
• DynamoDB – Unstructured?
• Any SQL-like structured DBs?
SNS
• If there is time let’s talk about notifications
• SNS can do some cool things for us
Cloud Architectures
• Processing
• Transferring (Queueing)
• Storing
• Presenting
AWS Management Console
Things I want to talk about
Overview of
Demo’d App
Requirements
Outbound connection

More Related Content

What's hot

T1 – Architecting highly available applications on aws
T1 – Architecting highly available applications on awsT1 – Architecting highly available applications on aws
T1 – Architecting highly available applications on aws
Amazon Web Services
 

What's hot (20)

AWS Webcast - Website Hosting
AWS Webcast - Website HostingAWS Webcast - Website Hosting
AWS Webcast - Website Hosting
 
EC2 Container Service - Distributed Applications at Scale - Pop-up Loft Tel Aviv
EC2 Container Service - Distributed Applications at Scale - Pop-up Loft Tel AvivEC2 Container Service - Distributed Applications at Scale - Pop-up Loft Tel Aviv
EC2 Container Service - Distributed Applications at Scale - Pop-up Loft Tel Aviv
 
(SOV204) Scaling Up to Your First 10 Million Users | AWS re:Invent 2014
(SOV204) Scaling Up to Your First 10 Million Users | AWS re:Invent 2014(SOV204) Scaling Up to Your First 10 Million Users | AWS re:Invent 2014
(SOV204) Scaling Up to Your First 10 Million Users | AWS re:Invent 2014
 
Amazon EC2 Masterclass
Amazon EC2 MasterclassAmazon EC2 Masterclass
Amazon EC2 Masterclass
 
SRV403 Deep Dive on Object Storage: Amazon S3 and Amazon Glacier
SRV403 Deep Dive on Object Storage: Amazon S3 and Amazon GlacierSRV403 Deep Dive on Object Storage: Amazon S3 and Amazon Glacier
SRV403 Deep Dive on Object Storage: Amazon S3 and Amazon Glacier
 
T1 – Architecting highly available applications on aws
T1 – Architecting highly available applications on awsT1 – Architecting highly available applications on aws
T1 – Architecting highly available applications on aws
 
An introduction to AWS CloudFormation - Pop-up Loft Tel Aviv
An introduction to AWS CloudFormation - Pop-up Loft Tel AvivAn introduction to AWS CloudFormation - Pop-up Loft Tel Aviv
An introduction to AWS CloudFormation - Pop-up Loft Tel Aviv
 
(STG406) Using S3 to Build and Scale an Unlimited Storage Service
(STG406) Using S3 to Build and Scale an Unlimited Storage Service(STG406) Using S3 to Build and Scale an Unlimited Storage Service
(STG406) Using S3 to Build and Scale an Unlimited Storage Service
 
SEC303 Automating Security in cloud Workloads with DevSecOps
SEC303 Automating Security in cloud Workloads with DevSecOpsSEC303 Automating Security in cloud Workloads with DevSecOps
SEC303 Automating Security in cloud Workloads with DevSecOps
 
Deep Dive on Lambda@Edge - August 2017 AWS Online Tech Talks
Deep Dive on Lambda@Edge - August 2017 AWS Online Tech TalksDeep Dive on Lambda@Edge - August 2017 AWS Online Tech Talks
Deep Dive on Lambda@Edge - August 2017 AWS Online Tech Talks
 
Amazon EC2:Masterclass
Amazon EC2:MasterclassAmazon EC2:Masterclass
Amazon EC2:Masterclass
 
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
 
AWS March 2016 Webinar Series - Amazon EC2 Masterclass
AWS March 2016 Webinar Series - Amazon EC2 MasterclassAWS March 2016 Webinar Series - Amazon EC2 Masterclass
AWS March 2016 Webinar Series - Amazon EC2 Masterclass
 
Cloudformation & VPC, EC2, RDS
Cloudformation & VPC, EC2, RDSCloudformation & VPC, EC2, RDS
Cloudformation & VPC, EC2, RDS
 
Deep Dive on Amazon S3
Deep Dive on Amazon S3Deep Dive on Amazon S3
Deep Dive on Amazon S3
 
Enterprise summit – architecting microservices on aws final v2
Enterprise summit – architecting microservices on aws   final v2Enterprise summit – architecting microservices on aws   final v2
Enterprise summit – architecting microservices on aws final v2
 
Agile Deployment using Git and AWS Elastic Beanstalk
Agile Deployment using Git and AWS Elastic BeanstalkAgile Deployment using Git and AWS Elastic Beanstalk
Agile Deployment using Git and AWS Elastic Beanstalk
 
Deploying a Disaster Recovery Site on AWS: Minimal Cost with Maximum Efficiency
Deploying a Disaster Recovery Site on AWS: Minimal Cost with Maximum EfficiencyDeploying a Disaster Recovery Site on AWS: Minimal Cost with Maximum Efficiency
Deploying a Disaster Recovery Site on AWS: Minimal Cost with Maximum Efficiency
 
Masterclass Webinar - AWS CloudFormation
Masterclass Webinar - AWS CloudFormationMasterclass Webinar - AWS CloudFormation
Masterclass Webinar - AWS CloudFormation
 
Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...
Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...
Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...
 

Similar to Creating scalable solutions with aws

AWS Cloud Computing for Startups Werner Vogels -part i
AWS Cloud Computing for Startups   Werner Vogels -part iAWS Cloud Computing for Startups   Werner Vogels -part i
AWS Cloud Computing for Startups Werner Vogels -part i
Amazon Web Services
 
Building Serverless Web Applications - DevDay Austin 2017
Building Serverless Web Applications - DevDay Austin 2017Building Serverless Web Applications - DevDay Austin 2017
Building Serverless Web Applications - DevDay Austin 2017
Amazon Web Services
 
Cloud Computing With AWS
Cloud Computing With AWSCloud Computing With AWS
Cloud Computing With AWS
Munish Gupta
 
AWS Cloud Kata | Manila - Getting to Scale on AWS
AWS Cloud Kata | Manila - Getting to Scale on AWSAWS Cloud Kata | Manila - Getting to Scale on AWS
AWS Cloud Kata | Manila - Getting to Scale on AWS
Amazon Web Services
 

Similar to Creating scalable solutions with aws (20)

Running Lean Architectures
Running Lean ArchitecturesRunning Lean Architectures
Running Lean Architectures
 
Uses, considerations, and recommendations for AWS
Uses, considerations, and recommendations for AWSUses, considerations, and recommendations for AWS
Uses, considerations, and recommendations for AWS
 
Leveraging elastic web scale computing with AWS
 Leveraging elastic web scale computing with AWS Leveraging elastic web scale computing with AWS
Leveraging elastic web scale computing with AWS
 
Why Scale Matters and How the Cloud is Really Different (at scale)
Why Scale Matters and How the Cloud is Really Different (at scale)Why Scale Matters and How the Cloud is Really Different (at scale)
Why Scale Matters and How the Cloud is Really Different (at scale)
 
From your First Migration to Mass migrations.
From your First Migration to Mass migrations. From your First Migration to Mass migrations.
From your First Migration to Mass migrations.
 
AWS Cloud Computing for Startups Werner Vogels -part i
AWS Cloud Computing for Startups   Werner Vogels -part iAWS Cloud Computing for Startups   Werner Vogels -part i
AWS Cloud Computing for Startups Werner Vogels -part i
 
Getting Started with AWS Compute Services
Getting Started with AWS Compute ServicesGetting Started with AWS Compute Services
Getting Started with AWS Compute Services
 
Building Serverless Web Applications - DevDay Austin 2017
Building Serverless Web Applications - DevDay Austin 2017Building Serverless Web Applications - DevDay Austin 2017
Building Serverless Web Applications - DevDay Austin 2017
 
Cloud Computing With AWS
Cloud Computing With AWSCloud Computing With AWS
Cloud Computing With AWS
 
What's new in AWS?
What's new in AWS?What's new in AWS?
What's new in AWS?
 
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
 
Cloud computing-Practical Example
Cloud computing-Practical ExampleCloud computing-Practical Example
Cloud computing-Practical Example
 
Aws coi7
Aws coi7Aws coi7
Aws coi7
 
Day 5 - AWS Autoscaling Master Class - The New Capacity Plan
Day 5 - AWS Autoscaling Master Class - The New Capacity PlanDay 5 - AWS Autoscaling Master Class - The New Capacity Plan
Day 5 - AWS Autoscaling Master Class - The New Capacity Plan
 
Building Serverless Web Applications - DevDay Los Angeles 2017
Building Serverless Web Applications - DevDay Los Angeles 2017Building Serverless Web Applications - DevDay Los Angeles 2017
Building Serverless Web Applications - DevDay Los Angeles 2017
 
AWS Cloud Kata | Manila - Getting to Scale on AWS
AWS Cloud Kata | Manila - Getting to Scale on AWSAWS Cloud Kata | Manila - Getting to Scale on AWS
AWS Cloud Kata | Manila - Getting to Scale on AWS
 
Architecting for the Cloud: Best Practices
Architecting for the Cloud: Best PracticesArchitecting for the Cloud: Best Practices
Architecting for the Cloud: Best Practices
 
How Easy to Automate Application Deployment on AWS
How Easy to Automate Application Deployment on AWSHow Easy to Automate Application Deployment on AWS
How Easy to Automate Application Deployment on AWS
 
Day 2 - Amazon EC2 Masterclass - Getting the most from Amazon EC2
Day 2 - Amazon EC2 Masterclass - Getting the most from Amazon EC2Day 2 - Amazon EC2 Masterclass - Getting the most from Amazon EC2
Day 2 - Amazon EC2 Masterclass - Getting the most from Amazon EC2
 

More from ondrejbalas

More from ondrejbalas (7)

Power BI - Data from any Source
Power BI - Data from any SourcePower BI - Data from any Source
Power BI - Data from any Source
 
Open Source Game Development in C#
Open Source Game Development in C#Open Source Game Development in C#
Open Source Game Development in C#
 
Game Jams - Yum!
Game Jams - Yum!Game Jams - Yum!
Game Jams - Yum!
 
Identity in ASP.NET Core
Identity in ASP.NET CoreIdentity in ASP.NET Core
Identity in ASP.NET Core
 
Monetize yourself
Monetize yourselfMonetize yourself
Monetize yourself
 
ReSharper: Discover the Secrets
ReSharper: Discover the SecretsReSharper: Discover the Secrets
ReSharper: Discover the Secrets
 
Creating a Plug-In Architecture
Creating a Plug-In ArchitectureCreating a Plug-In Architecture
Creating a Plug-In Architecture
 

Recently uploaded

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 

Recently uploaded (20)

Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 

Creating scalable solutions with aws

  • 1. Creating Scalable Solutions with Amazon Cloud Services ONDREJ BALAS @ONDREJBALAS WWW.ONDREJBALAS.COM ONDREJ@ONDREJBALAS.COM
  • 2. ONDREJ BALAS Microsoft MVP in C# Writer for Visual Studio Magazine Owner of UseTech Design (est. 2001) Building software that drives business Serial Entrepreneur WWW.ONDREJBALAS.COM ONDREJ@ONDREJBALAS.COM @ONDREJBALAS
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14. Elastic Compute Cloud (EC2) INFRASTRUCTURE AS A SERVICE (IAAS)
  • 15.
  • 16. Virtual Machines Provisioned within minutes Choose your own AMI (disk image) or use a pre-existing one Pay by the hour – Linux as low as $0.003 per hour or Windows for $0.006 per hour Many machine sizes to choose from
  • 17. EC2 Instance AMI When an EC2 Instance is created, its hard disk contents are copied from an AMI
  • 18. EC2 Instance AMI When an EC2 Instance is created, its hard disk contents are copied from an AMI
  • 19. EC2 Instance AMI When an EC2 Instance is created, its hard disk contents are copied from an AMI Internet Security Group A security group acts as the firewall between the internet and the instance An AMI can be created by copying the current state of an EC2 instance
  • 20. EC2 Instance AMI When an EC2 Instance is created, its hard disk contents are copied from an AMI Internet Security Group A security group acts as the firewall between the internet and the instance Key Pair An instance is assigned a key pair at creation time, and the same one must be later used to gain access to the instance.
  • 21. Launching the Instance DEMO – AWS CONTROL PANEL
  • 22. AWSCredentials credentials = new BasicAWSCredentials("AccessKey", "SecretKey"); IAmazonEC2 client = new AmazonEC2Client(credentials, RegionEndpoint.USEast1); DescribeInstancesResponse describeInstancesResponse = client.DescribeInstances(); List<Reservation> reservations = describeInstancesResponse.Reservations; foreach (Instance instance in reservations.SelectMany(x => x.Instances)) { Console.WriteLine("Instance with ID {0} is currently {1}", instance.InstanceId, instance.State.Name); } Accessing Instances Programmatically
  • 23. AWSCredentials credentials = new BasicAWSCredentials("AccessKey", "SecretKey"); DescribeInstancesRequest request = new DescribeInstancesRequest(); request.Filters.Add(new Filter("instance-state-code", new List<string>() {"0", "16"})); List<Reservation> reservations = client.DescribeInstances(request).Reservations; List<Reservation> reservations = client.DescribeInstances().Reservations; foreach (Instance instance in reservations.SelectMany(x => x.Instances)) { Console.WriteLine("Instance with ID {0} is currently {1}", instance.InstanceId, instance.State.Name); } Accessing Instances Programmatically State codes • 0 pending • 16 running • 32 shutting-down • 48 terminated • 64 stopping • 80 stopped
  • 24. Instrumentation DEMO - MANAGING INSTANCES ACROSS THE GLOBE
  • 25.
  • 26.
  • 27. Worker Service Installed onto my Base AMI Updateable from the Instrumentation Uses WebAPI Selfhost to manage requests And TopShelf to make it a service
  • 28. Moving Bits Around THERE’S MORE TO IT THAN JUST SCALING SERVERS UP AND DOWN
  • 29. SQS (Simple Queue Service) Queue ConsumerPublishers Publishers send messages to the queue Consumer periodically checks the queue for messages
  • 30. SQS (Simple Queue Service) Consumer Consumer watches for messages QueuePublishers Publishers send messages to the queue Consumer controls throughput by only sending one write at a time to the database Database
  • 31. SQS (Simple Queue Service) Queue ConsumersPublishers Publishers send messages to the queue Consumers take messages from the queue and process them in parallel
  • 32. SQS (Simple Queue Service) Queue Consumers & PublishersPublishers Final ConsumerQueue
  • 33. SQS (Simple Queue Service) Writing to a queue AmazonSQSClient client = new AmazonSQSClient(credentials, RegionEndpoint.USEast1); string message = "my message"; string queueUrl = "https://sqs.us-east-1.amazonaws.com/025631894481/aws-talk"; SendMessageResponse sendMessageResponse = client.SendMessage(queueUrl, message);
  • 34. SQS (Simple Queue Service) Reading from a queue AmazonSQSClient client = new AmazonSQSClient(credentials, RegionEndpoint.USEast1); string queueUrl = "https://sqs.us-east-1.amazonaws.com/025631894481/aws-talk"; ReceiveMessageResponse response = client.ReceiveMessage(queueUrl); foreach (Message message in response.Messages) { // Do something with the message client.DeleteMessage(queueUrl, message.ReceiptHandle); }
  • 35. SQS (Simple Queue Service) Reading from a queue AmazonSQSClient client = new AmazonSQSClient(credentials, RegionEndpoint.USEast1); string queueUrl = "https://sqs.us-east-1.amazonaws.com/025631894481/aws-talk"; ReceiveMessageRequest request = new ReceiveMessageRequest(queueUrl); request.MaxNumberOfMessages = 1; ReceiveMessageResponse response = client.ReceiveMessage(request); foreach (Message message in response.Messages) { // Do something with the message client.DeleteMessage(queueUrl, message.ReceiptHandle); }
  • 36. SQS – Important Notes Messages are not guaranteed to be delivered in order In rare circumstances, messages can be delivered more than once Dead letter queues can be created, allowing failed items to be automatically moved after some number of failures
  • 37. SNS (Simple Notification Service) Topic ConsumersPublishers Publishers send messages to the topic Consumers receive all messages sent to the topic
  • 38. SNS (Simple Notification Service) Topic ConsumersPublishers Publishers send messages to the topic All consumers receive all messages sent to the topic SQS Queue
  • 39. SNS (Simple Notification Service) Messages are not requested, they are pushed to subscribers Subscribers are just endpoints Endpoints can be: HTTP, HTTPS, Email, Email-JSON, SMS, SQS
  • 40. Storing Data LOTS OF WAYS TO DO IT
  • 41. S3 (Simple Storage Service) Like a simple key-value store Great for storing files Store up to 5TB per object Extremely scalable and durable Highly available
  • 42. Glacier Similar to S3 Meant for archival – long term storage is durable and cheap From the Glacier website: “Glacier is designed with the expectation that retrievals are infrequent and unusual, and data will be stored for extended periods of time. You can retrieve up to 5% of your average monthly storage (pro-rated daily) for free each month. If you choose to retrieve more than this amount of data in a month, you are charged a retrieval fee starting at $0.01 per gigabyte.” Source: http://aws.amazon.com/glacier/pricing/
  • 45. SimpleDB Writing data AmazonSimpleDBClient client = new AmazonSimpleDBClient(credentials, RegionEndpoint.USEast1); CreateDomainRequest request = new CreateDomainRequest("aws-talk"); CreateDomainResponse response = client.CreateDomain(request); PutAttributesRequest putData = new PutAttributesRequest("aws-talk", "products/" + Guid.NewGuid().ToString(), new List<ReplaceableAttribute>() { new ReplaceableAttribute("Name", "Couch", true), new ReplaceableAttribute("Price", "20", true) }); client.PutAttributes(putData);
  • 46. SimpleDB Reading data AmazonSimpleDBClient client = new AmazonSimpleDBClient(credentials,RegionEndpoint.USEast1); // attribute names are case sensitive // comparisons are lexicographical. no numeric comparisons exist SelectRequest request = new SelectRequest( "select * from `aws-talk` WHERE `Price` > '01'"); SelectResponse response = client.Select(request); foreach (Item item in response.Items) { Console.WriteLine("Item {0} has attributes: {1}", item.Name, String.Join(" ; ", item.Attributes.Select(a => string.Format("{0}={1}", a.Name, a.Value)))); }
  • 47. Pricing Estimating it can be difficult “Fixed” costs such as instance-hours or gigabyte-months aren’t too bad Requests are counted in “Cost per million” And then factor in bandwidth, too. Usually ends up being really cheap!
  • 48. So Many Services to Choose From
  • 50. Notes & Other Things IF YOU KEEP GOING YOU WILL RUN INTO MY NOTES
  • 52.
  • 56. After creating a new account • Go to “Security Credential” • Create a user • Make note of the Access Key ID and Secret Access Key • Create a group to put that user into. I gave it power user permissions • Create the Security Group • Create the Key Pair • Launch the instance to create the AMI from • Create the AMI • Copy the AMI to all other regions • Begin launching instances from that AMI
  • 58.
  • 60. EC2 • Code: Launch a VM, get a list of VMs, kill a VM. • Mention AMIs, Security Groups & Key Pairs • Updating applications that are currently running • Demo: Launch some VMs all around the world using an existing AMI that I’ve deployed my “worker” to once. • Workers run selfhost WebAPI so I can query their status • Workers can auto-update(?) or can be told to update • Instrumentation allows me to list VMs, update, kill, and see other health/status points
  • 61. EC2 • Before creating an instance, there are a few important things • AMI = Amazon Machine Image. • Launch an instance based off a public AMI first, and then customize it as needed by installing your services. Then you can save the AMI into that region and copy it into all other regions as needed. • Security Group – Like a set of Firewall rules • VPC = Virtual Private Cloud. A private network for your instances. (Only within a region???)
  • 62. SQS • Need a way to feed data to the workers, to give it work to do • Queues are often used at application boundaries (seams) • Common queueing patterns slide • Talk about AWS implementation of those patterns
  • 63. Data • S3 – Basically just online file storage • DynamoDB – Unstructured? • Any SQL-like structured DBs?
  • 64. SNS • If there is time let’s talk about notifications • SNS can do some cool things for us
  • 65. Cloud Architectures • Processing • Transferring (Queueing) • Storing • Presenting
  • 66.
  • 68. Things I want to talk about Overview of

Editor's Notes

  1. The icons use FontAwesome. If they appear to be missing, try installing the font from here: http://fortawesome.github.io/Font-Awesome/ This talk covers EC2, which I consider to be Amazon’s most “famous” offering – an IaaS (Infrastructure as a Service) offering and how I was able to use it to solve a problem. It also covers SQS (queueing) and SNS (notifications) as well as a few data storage offerings. I will talk not only about what these things are but also how to manage them programmatically. The code I show will be in C# using the .NET SDK, which isn’t much more than a thin wrapper over the AWS REST API. So regardless of what your language of choice is, once you see how the API calls are named it will make sense in any language.
  2. A little about me… serial entrepreneur. I’ve been involved in a lot of businesses and a lot of this talk is my story. Along the way I have learned a lot of things, and that’s what I want to share. The reason I got started is interesting..
  3. Years ago I was working on a project where we had to grab data from a few data sources and aggregate it into one place. Like any other developer would, we created a Data Acquisition Application and got to it. It was simple and effective.
  4. Overtime more and more data sources were added. But the application was well architected and handled them without issue.
  5. But after some time we started connecting to data sources that were farther away.
  6. You’re probably wondering at this point “So? What does that matter?” And it doesn’t until you put things into context (map shows up)
  7. The actually had expanded dramatically since we started using it and we were now acquiring data from all over the world. This caused problems though because internet connections aren’t always great and international links sometimes go down, or connectivity outside of some countries/regions isn’t as quick as we’d like.
  8. The first problem we’d run into is increased latency which meant we had to work around that when transferring data.
  9. Some connections were not just slow but also intermittent.
  10. And with a few of the worst ones we’d see long periods of time where no connection was possible.
  11. However at the time that we were dealing with these problems Amazon had just recently launched EC2 in some of its data centers. This map is more recent than what was available then and represents the current infrastructure. As of October 2015, there is an additional European data center in Frankfurt, Germany which is not represented on this map.
  12. While doing some testing with instances in data centers across the globe we noticed that a lot of our connection problems seem to be greatly reduced or even completely mitigated by connecting from a data center closer to the data source. So we began work on expanding the application to instances in each data center and assigning each data source to the closest data center.
  13. And then a secondary benefit gained from this is that because we were sending our data to instances back in the states, that data was being transmitted through Amazon’s network. And believe me, Amazon is very committed to keeping the connection between data centers as quick as possible and practically without downtime.
  14. To make this happen we used Amazon’s “EC2” offering which is basically infrastructure as a service. Meaning that when you start up an instance, you get this:
  15. A remote desktop. Amazon maintains the infrastructure, handles the machine side of things, and provides you with an instance that is of a certain “size” depending on what you want.
  16. There are a lot of terms that you will hear when dealing with EC2 instances, so here is a diagram to explain what some of those things mean in the context of EC2.
  17. Go into the AWS control panel. Create a Security Group. Create a Key Pair. Create the Instance. RDP into the pre-created Instance (like Martha Stewart, pull the cookies out of the oven). Transition point: Talk about how to make the transition into managing these things with code. To do that I will need to go into IAM. Create a User. Create a Group. Add a user to the Group.
  18. This very simple code can be powerful. I’ve created a dashboard where I can see my instances across the globe.
  19. The way we set up the instances was to create an AMI with a windows service that can receive communications from the control panel. And then be updated from it as well by deploying a zip file to S3 and having the service update itself to the new version. So now.. wait for it.. there we go..
  20. We have instances that can be updated to run any code we throw at it within minutes.