SlideShare a Scribd company logo
1 of 26
Rails in the Cloud
Ian Warshak

Developer @ RightScale

http://twitter.com/iwarshak

http://github.com/iwarshak/lsrc-cloud
The Clouds
Cloud Infrastructure       Cloud Services


                         Amazon S3
Amazon Ec2
                         Amazon SQS
Rackspace Cloudservers
                         Amazon SimpleDB
Flexiscale
                         Google AppEngine
GoGrid
                         Heroku
Pictr
Photo website. You upload photos, they are
resized, watermarked, and put on the homepage

Photos can be uploaded by the public

Photos are converted asynchronously by
separate processing servers

Very simple app, but hopefully shows some
ideas of how cloud computing apps work
Why Pictr?
Lots of Disk Storage

Lots of Bandwidth

Offline processing

I want to manage and host as little as possible

It will be an instant hit. Needs to scale from day 1
Don’t get your hopes up
about Pictr!
Why the Cloud?
I don’t want to build or configure hardware.

I don’t want to do much capacity planning.

I want to pay as I go for servers and service.

Offload as much as possible.

Lots of Bandwidth

Offline processing

I want to manage and host as little as possible

It will be an instant hit. Needs to scale from day 1
How is it built?

Rails application running on Amazon EC2 servers

Asynchronous image processing (resizing, effects)

Database is Amazon SimpleDB

Storage is Amazon S3

CDN is Amazon Cloudfront

Messaging queue is Amazon SQS

ImageMagick is used for image manipulation
gem install right_aws
Why Amazon?
Simple. Right now, they are the market leader...
But the competition is good.

Tight integration between services

RESTful APIs for their services

Lots of documentation and libraries
Amazon Ec2
Servers “on demand”.

Pay by the hour: $0.10 - $0.80/hour

Non-persistent.

Forces you to automate your configuration.

RightScale helps a lot with this.

Elastic IP can give you a static IP

Elastic Block Store gives you persistent data
store
Amazon S3
Oldest of the publicly available web services

Scalable, reliable data storage mechanism

Bucket/object concept

Pay for the data you are storing, as well as
bandwidth in and out

$0.15/GB stored. $0.10/GB transferred. $0.01/
request.

Very fine grained permissions
CloudFront
  Similar to LimeLight, Akamai

  Low latency, high data rate transfers

  8 edge locations in the US

  Origin server is an S3 bucket

  24 hour object expiration

  Very simple API

acf = RightAws::AcfInterface.new
acf.create_distribution('pictr.s3.amazonaws.com', 'Woo-Hoo!', true)
Amazon Simple Queue Service

 Reliable, scalable queue

 PUSH and PULL messages

 Messages can be up to 8K of text

 Messages are “locked” as they are processed,
 preventing them from being read multiple times.
Amazon SimpleDB
 Simple (but powerful) database

 Non-relational. No tables, only “domains”. No joins.

 No schema. Define it as you go.

 All data is stored as strings.

 Attributes can have up to 256 values.

 Automatically indexes all your data.

 Not exactly a speed daemon.
Amazon SimpleDB
ActiveSDB

RightAws::ActiveSdb.establish_connection
class Item < RightAws::ActiveSdb::Base; end

Item.create_domain
item = Item.create :Category => "Electronics", :Size => 47, :Manufacturer => "Sony"

# Add a new "column"
item["Illumination"] = "LCD"
item.save

# New category. Now, category is an "array"
item["Category"] << "Televisions"
item.save

items = Item.select(:all, :conditions => ["Size = ?", 47])
# => [#<Item:0x1a8a5ec @new_record=false, @attributes={"Size"=>["47"], "Category"=>["Electronics",
"Televisions"], "id"=>"788b5192-8a85-11de-a035-00264a1272e2", "Manufacturer"=>["Sony"],
"Illumination"=>["LCD"]}>]
SimpleDB caveats

All data is stored as a string.

Response cannot be > 1MB

Maximum query execution time: 5 sec

Eventually consistent (a tradeoff for availability)

Speed (network)
What does all this mean?
 I worry less about scaling

 I worry more about configuration management
 and automation

 Database performance is very consistent

 S3, Cloudfront handles static file serving

 Minimal upfront investment

 Only pay for what I need
SQS


              SimpleDB
Web Servers              Converter Servers




               S3
  Users
Step 1: Upload

    S3




                          EC2 INSTANCE
            REDIRECT ON
            SUCCESS

  POST
  PIC.JPG

                          INITIATES PROCESSING
Step 2: Queue the jobs

# Jobs are created
jobs = [ConvertJob.new(key, "paint", "400", "-paint 5"),
ConvertJob.new(key, "monochrome", "400", "-monochrome")]

# Push the jobs into the queue
sqs = RightAws::SqsGen2.new
convert_queue = sqs.queue("convert")

jobs.each do |job|
  convert_queue.send_message job.to_json
end
Step 3: Create SimpleDB record



# class Picture < RightAws::ActiveSdb::Base
# ...
# end

picture = Picture.create(:key => key)
picture["total_conversions"] = ["paint", "monochrome"]
picture.save
SimpleDB record

# Before conversion
{"key"=>["uploads/f1"],
"total_conversions"=>["paint", "monochrome"]}

# After conversion
{"key"=>["uploads/f1"],
"total_conversions"=>["paint", "monochrome"],
"paint"=>["processed/f1_paint.jpg"],
"monochrome"=>["processed/f1_monochrome.jpg"]
}
Step 4: Processor Daemon

 loop do
   sqs = RightAws::SqsGen2.new
   convert_queue = sqs.queue("convert")

  message = convert_queue.pop
  if message
    job = JSON.parse message.to_s
    puts "Found a new message #{job.key}"
    job.run!
  end
  sleep(5)
 end
Demo
Thanks!

right_aws gem

http://github.com/iwarshak/lsrc-cloud

twitter.com/iwarshak

More Related Content

What's hot

Amazon Web Service EC2 & S3
Amazon Web Service EC2 & S3Amazon Web Service EC2 & S3
Amazon Web Service EC2 & S3Pravin Vaja
 
Aws cloud best_practices
Aws cloud best_practicesAws cloud best_practices
Aws cloud best_practicesSuruli Kannan
 
Amazon ec2
Amazon ec2Amazon ec2
Amazon ec2Anu DeeP
 
When Should You Use AWS Lambda?
When Should You Use AWS Lambda?When Should You Use AWS Lambda?
When Should You Use AWS Lambda?Whizlabs
 
What is AWS lambda?
What is AWS lambda?What is AWS lambda?
What is AWS lambda?Whizlabs
 
T3 - Deploy, manage, and scale your apps
T3 - Deploy, manage, and scale your appsT3 - Deploy, manage, and scale your apps
T3 - Deploy, manage, and scale your appsAmazon Web Services
 
AWS Big Data combo
AWS Big Data comboAWS Big Data combo
AWS Big Data comboJulien SIMON
 
Accelerate Your Java Development on AWS (TLS301) | AWS re:Invent 2013
Accelerate Your Java Development on AWS (TLS301) | AWS re:Invent 2013Accelerate Your Java Development on AWS (TLS301) | AWS re:Invent 2013
Accelerate Your Java Development on AWS (TLS301) | AWS re:Invent 2013Amazon Web Services
 
Deploying Data Science with Docker and AWS
Deploying Data Science with Docker and AWSDeploying Data Science with Docker and AWS
Deploying Data Science with Docker and AWSMatt McDonnell
 
Services comparison among Microsoft Azure AWS and Google Cloud Platform
Services comparison among Microsoft Azure AWS and Google Cloud PlatformServices comparison among Microsoft Azure AWS and Google Cloud Platform
Services comparison among Microsoft Azure AWS and Google Cloud Platformindu Yadav
 
Shift Remote AI: Build and deploy PyTorch Models with Azure Machine Learning ...
Shift Remote AI: Build and deploy PyTorch Models with Azure Machine Learning ...Shift Remote AI: Build and deploy PyTorch Models with Azure Machine Learning ...
Shift Remote AI: Build and deploy PyTorch Models with Azure Machine Learning ...Shift Conference
 
Container Orchestration with Amazon ECS
Container Orchestration with Amazon ECSContainer Orchestration with Amazon ECS
Container Orchestration with Amazon ECSAmazon Web Services
 
Major Container Platform Comparison
Major Container Platform ComparisonMajor Container Platform Comparison
Major Container Platform Comparisonindu Yadav
 
Building a data warehouse with Amazon Redshift … and a quick look at Amazon ...
Building a data warehouse  with Amazon Redshift … and a quick look at Amazon ...Building a data warehouse  with Amazon Redshift … and a quick look at Amazon ...
Building a data warehouse with Amazon Redshift … and a quick look at Amazon ...Julien SIMON
 
How to Use AWS Lambda Layers and Lambda Runtime
How to Use AWS Lambda Layers and Lambda RuntimeHow to Use AWS Lambda Layers and Lambda Runtime
How to Use AWS Lambda Layers and Lambda RuntimeDonnie Prakoso
 
AWS Partner Webcast - Disaster Recovery: Implementing DR Across On-premises a...
AWS Partner Webcast - Disaster Recovery: Implementing DR Across On-premises a...AWS Partner Webcast - Disaster Recovery: Implementing DR Across On-premises a...
AWS Partner Webcast - Disaster Recovery: Implementing DR Across On-premises a...Amazon Web Services
 
AWS Lambda Tutorial | Introduction to AWS Lambda | AWS Tutorial | AWS Trainin...
AWS Lambda Tutorial | Introduction to AWS Lambda | AWS Tutorial | AWS Trainin...AWS Lambda Tutorial | Introduction to AWS Lambda | AWS Tutorial | AWS Trainin...
AWS Lambda Tutorial | Introduction to AWS Lambda | AWS Tutorial | AWS Trainin...Edureka!
 

What's hot (20)

Amazon Web Service EC2 & S3
Amazon Web Service EC2 & S3Amazon Web Service EC2 & S3
Amazon Web Service EC2 & S3
 
Aws cloud best_practices
Aws cloud best_practicesAws cloud best_practices
Aws cloud best_practices
 
AWS User Group December 2016
AWS User Group December 2016AWS User Group December 2016
AWS User Group December 2016
 
Amazon ec2
Amazon ec2Amazon ec2
Amazon ec2
 
When Should You Use AWS Lambda?
When Should You Use AWS Lambda?When Should You Use AWS Lambda?
When Should You Use AWS Lambda?
 
Serverless Architecture
Serverless ArchitectureServerless Architecture
Serverless Architecture
 
What is AWS lambda?
What is AWS lambda?What is AWS lambda?
What is AWS lambda?
 
T3 - Deploy, manage, and scale your apps
T3 - Deploy, manage, and scale your appsT3 - Deploy, manage, and scale your apps
T3 - Deploy, manage, and scale your apps
 
AWS Big Data combo
AWS Big Data comboAWS Big Data combo
AWS Big Data combo
 
Accelerate Your Java Development on AWS (TLS301) | AWS re:Invent 2013
Accelerate Your Java Development on AWS (TLS301) | AWS re:Invent 2013Accelerate Your Java Development on AWS (TLS301) | AWS re:Invent 2013
Accelerate Your Java Development on AWS (TLS301) | AWS re:Invent 2013
 
Deploying Data Science with Docker and AWS
Deploying Data Science with Docker and AWSDeploying Data Science with Docker and AWS
Deploying Data Science with Docker and AWS
 
Services comparison among Microsoft Azure AWS and Google Cloud Platform
Services comparison among Microsoft Azure AWS and Google Cloud PlatformServices comparison among Microsoft Azure AWS and Google Cloud Platform
Services comparison among Microsoft Azure AWS and Google Cloud Platform
 
Shift Remote AI: Build and deploy PyTorch Models with Azure Machine Learning ...
Shift Remote AI: Build and deploy PyTorch Models with Azure Machine Learning ...Shift Remote AI: Build and deploy PyTorch Models with Azure Machine Learning ...
Shift Remote AI: Build and deploy PyTorch Models with Azure Machine Learning ...
 
Container Orchestration with Amazon ECS
Container Orchestration with Amazon ECSContainer Orchestration with Amazon ECS
Container Orchestration with Amazon ECS
 
Major Container Platform Comparison
Major Container Platform ComparisonMajor Container Platform Comparison
Major Container Platform Comparison
 
Building a data warehouse with Amazon Redshift … and a quick look at Amazon ...
Building a data warehouse  with Amazon Redshift … and a quick look at Amazon ...Building a data warehouse  with Amazon Redshift … and a quick look at Amazon ...
Building a data warehouse with Amazon Redshift … and a quick look at Amazon ...
 
Amazon Lightsail
Amazon LightsailAmazon Lightsail
Amazon Lightsail
 
How to Use AWS Lambda Layers and Lambda Runtime
How to Use AWS Lambda Layers and Lambda RuntimeHow to Use AWS Lambda Layers and Lambda Runtime
How to Use AWS Lambda Layers and Lambda Runtime
 
AWS Partner Webcast - Disaster Recovery: Implementing DR Across On-premises a...
AWS Partner Webcast - Disaster Recovery: Implementing DR Across On-premises a...AWS Partner Webcast - Disaster Recovery: Implementing DR Across On-premises a...
AWS Partner Webcast - Disaster Recovery: Implementing DR Across On-premises a...
 
AWS Lambda Tutorial | Introduction to AWS Lambda | AWS Tutorial | AWS Trainin...
AWS Lambda Tutorial | Introduction to AWS Lambda | AWS Tutorial | AWS Trainin...AWS Lambda Tutorial | Introduction to AWS Lambda | AWS Tutorial | AWS Trainin...
AWS Lambda Tutorial | Introduction to AWS Lambda | AWS Tutorial | AWS Trainin...
 

Viewers also liked

Powerpoint
PowerpointPowerpoint
Powerpointdruminic
 
WordPress Policy Primer
WordPress Policy PrimerWordPress Policy Primer
WordPress Policy PrimerHans Dusink
 
Grant Presentation
Grant PresentationGrant Presentation
Grant Presentationchrysmum
 
Link Analysis and Link Building in a Penguin and Disavow World
Link Analysis and Link Building in a Penguin and Disavow WorldLink Analysis and Link Building in a Penguin and Disavow World
Link Analysis and Link Building in a Penguin and Disavow WorldChristoph C. Cemper
 

Viewers also liked (7)

Jantima Resume
Jantima ResumeJantima Resume
Jantima Resume
 
Powerpoint
PowerpointPowerpoint
Powerpoint
 
WordPress Policy Primer
WordPress Policy PrimerWordPress Policy Primer
WordPress Policy Primer
 
Ihya' ramadhan
Ihya' ramadhanIhya' ramadhan
Ihya' ramadhan
 
Grant Presentation
Grant PresentationGrant Presentation
Grant Presentation
 
Linkedin executive-playbook
Linkedin executive-playbookLinkedin executive-playbook
Linkedin executive-playbook
 
Link Analysis and Link Building in a Penguin and Disavow World
Link Analysis and Link Building in a Penguin and Disavow WorldLink Analysis and Link Building in a Penguin and Disavow World
Link Analysis and Link Building in a Penguin and Disavow World
 

Similar to Rails in the Cloud

The Future is Now: Leveraging the Cloud with Ruby
The Future is Now: Leveraging the Cloud with RubyThe Future is Now: Leveraging the Cloud with Ruby
The Future is Now: Leveraging the Cloud with RubyRobert Dempsey
 
Cloud computing-Practical Example
Cloud computing-Practical ExampleCloud computing-Practical Example
Cloud computing-Practical ExampleTasawar Gulzar
 
Media Processing Workflows using AWS Step Functions and Machine Learning on A...
Media Processing Workflows using AWS Step Functions and Machine Learning on A...Media Processing Workflows using AWS Step Functions and Machine Learning on A...
Media Processing Workflows using AWS Step Functions and Machine Learning on A...Cloudinary
 
How to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless EditionHow to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless EditionLecole Cole
 
AWS 201 - A Walk through the AWS Cloud: App Hosting on AWS - Games, Apps and ...
AWS 201 - A Walk through the AWS Cloud: App Hosting on AWS - Games, Apps and ...AWS 201 - A Walk through the AWS Cloud: App Hosting on AWS - Games, Apps and ...
AWS 201 - A Walk through the AWS Cloud: App Hosting on AWS - Games, Apps and ...Amazon Web Services
 
How to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless EditionHow to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless Editionecobold
 
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)Amazon Web Services
 
Building and scaling a B2D service, the bootstrap way
Building and scaling a B2D service, the bootstrap wayBuilding and scaling a B2D service, the bootstrap way
Building and scaling a B2D service, the bootstrap wayNadav Soferman
 
Serverless Architectural Patterns & Best Practices
Serverless Architectural Patterns & Best PracticesServerless Architectural Patterns & Best Practices
Serverless Architectural Patterns & Best PracticesDaniel Zivkovic
 
McrUmbMeetup 22 May 14: Umbraco and Amazon
McrUmbMeetup 22 May 14: Umbraco and AmazonMcrUmbMeetup 22 May 14: Umbraco and Amazon
McrUmbMeetup 22 May 14: Umbraco and AmazonDan Lister
 
AWS re:Invent 2016: IoT Visualizations and Analytics (IOT306)
AWS re:Invent 2016: IoT Visualizations and Analytics (IOT306)AWS re:Invent 2016: IoT Visualizations and Analytics (IOT306)
AWS re:Invent 2016: IoT Visualizations and Analytics (IOT306)Amazon Web Services
 
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 AWSAmazon Web Services
 
Fowa Miami 09 Cloud Computing Workshop
Fowa Miami 09 Cloud Computing WorkshopFowa Miami 09 Cloud Computing Workshop
Fowa Miami 09 Cloud Computing WorkshopMark Masterson
 
AWS Cloud Kata | Taipei - Getting to Scale
AWS Cloud Kata | Taipei - Getting to ScaleAWS Cloud Kata | Taipei - Getting to Scale
AWS Cloud Kata | Taipei - Getting to ScaleAmazon Web Services
 
AWS Startup Webinar | Developing on AWS
AWS Startup Webinar | Developing on AWSAWS Startup Webinar | Developing on AWS
AWS Startup Webinar | Developing on AWSAmazon Web Services
 
AWS Webcast - What is Cloud Computing?
AWS Webcast - What is Cloud Computing?AWS Webcast - What is Cloud Computing?
AWS Webcast - What is Cloud Computing?Amazon Web Services
 
Cloud computing workshop at IIT bombay
Cloud computing workshop at IIT bombayCloud computing workshop at IIT bombay
Cloud computing workshop at IIT bombayNilesh Satpute
 
Deep Dive on Microservices and Docker
Deep Dive on Microservices and DockerDeep Dive on Microservices and Docker
Deep Dive on Microservices and DockerKristana Kane
 
SRV409 Deep Dive on Microservices and Docker
SRV409 Deep Dive on Microservices and DockerSRV409 Deep Dive on Microservices and Docker
SRV409 Deep Dive on Microservices and DockerAmazon Web Services
 

Similar to Rails in the Cloud (20)

The Future is Now: Leveraging the Cloud with Ruby
The Future is Now: Leveraging the Cloud with RubyThe Future is Now: Leveraging the Cloud with Ruby
The Future is Now: Leveraging the Cloud with Ruby
 
Cloud computing-Practical Example
Cloud computing-Practical ExampleCloud computing-Practical Example
Cloud computing-Practical Example
 
Media Processing Workflows using AWS Step Functions and Machine Learning on A...
Media Processing Workflows using AWS Step Functions and Machine Learning on A...Media Processing Workflows using AWS Step Functions and Machine Learning on A...
Media Processing Workflows using AWS Step Functions and Machine Learning on A...
 
How to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless EditionHow to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless Edition
 
AWS 201 - A Walk through the AWS Cloud: App Hosting on AWS - Games, Apps and ...
AWS 201 - A Walk through the AWS Cloud: App Hosting on AWS - Games, Apps and ...AWS 201 - A Walk through the AWS Cloud: App Hosting on AWS - Games, Apps and ...
AWS 201 - A Walk through the AWS Cloud: App Hosting on AWS - Games, Apps and ...
 
How to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless EditionHow to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless Edition
 
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)
 
Building and scaling a B2D service, the bootstrap way
Building and scaling a B2D service, the bootstrap wayBuilding and scaling a B2D service, the bootstrap way
Building and scaling a B2D service, the bootstrap way
 
Serverless Architectural Patterns & Best Practices
Serverless Architectural Patterns & Best PracticesServerless Architectural Patterns & Best Practices
Serverless Architectural Patterns & Best Practices
 
McrUmbMeetup 22 May 14: Umbraco and Amazon
McrUmbMeetup 22 May 14: Umbraco and AmazonMcrUmbMeetup 22 May 14: Umbraco and Amazon
McrUmbMeetup 22 May 14: Umbraco and Amazon
 
AWS re:Invent 2016: IoT Visualizations and Analytics (IOT306)
AWS re:Invent 2016: IoT Visualizations and Analytics (IOT306)AWS re:Invent 2016: IoT Visualizations and Analytics (IOT306)
AWS re:Invent 2016: IoT Visualizations and Analytics (IOT306)
 
NodeJS @ ACS
NodeJS @ ACSNodeJS @ ACS
NodeJS @ ACS
 
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
 
Fowa Miami 09 Cloud Computing Workshop
Fowa Miami 09 Cloud Computing WorkshopFowa Miami 09 Cloud Computing Workshop
Fowa Miami 09 Cloud Computing Workshop
 
AWS Cloud Kata | Taipei - Getting to Scale
AWS Cloud Kata | Taipei - Getting to ScaleAWS Cloud Kata | Taipei - Getting to Scale
AWS Cloud Kata | Taipei - Getting to Scale
 
AWS Startup Webinar | Developing on AWS
AWS Startup Webinar | Developing on AWSAWS Startup Webinar | Developing on AWS
AWS Startup Webinar | Developing on AWS
 
AWS Webcast - What is Cloud Computing?
AWS Webcast - What is Cloud Computing?AWS Webcast - What is Cloud Computing?
AWS Webcast - What is Cloud Computing?
 
Cloud computing workshop at IIT bombay
Cloud computing workshop at IIT bombayCloud computing workshop at IIT bombay
Cloud computing workshop at IIT bombay
 
Deep Dive on Microservices and Docker
Deep Dive on Microservices and DockerDeep Dive on Microservices and Docker
Deep Dive on Microservices and Docker
 
SRV409 Deep Dive on Microservices and Docker
SRV409 Deep Dive on Microservices and DockerSRV409 Deep Dive on Microservices and Docker
SRV409 Deep Dive on Microservices and Docker
 

Recently uploaded

What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 

Recently uploaded (20)

What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 

Rails in the Cloud

  • 1. Rails in the Cloud Ian Warshak Developer @ RightScale http://twitter.com/iwarshak http://github.com/iwarshak/lsrc-cloud
  • 2. The Clouds Cloud Infrastructure Cloud Services Amazon S3 Amazon Ec2 Amazon SQS Rackspace Cloudservers Amazon SimpleDB Flexiscale Google AppEngine GoGrid Heroku
  • 3. Pictr Photo website. You upload photos, they are resized, watermarked, and put on the homepage Photos can be uploaded by the public Photos are converted asynchronously by separate processing servers Very simple app, but hopefully shows some ideas of how cloud computing apps work
  • 4. Why Pictr? Lots of Disk Storage Lots of Bandwidth Offline processing I want to manage and host as little as possible It will be an instant hit. Needs to scale from day 1
  • 5. Don’t get your hopes up about Pictr!
  • 6. Why the Cloud? I don’t want to build or configure hardware. I don’t want to do much capacity planning. I want to pay as I go for servers and service. Offload as much as possible. Lots of Bandwidth Offline processing I want to manage and host as little as possible It will be an instant hit. Needs to scale from day 1
  • 7. How is it built? Rails application running on Amazon EC2 servers Asynchronous image processing (resizing, effects) Database is Amazon SimpleDB Storage is Amazon S3 CDN is Amazon Cloudfront Messaging queue is Amazon SQS ImageMagick is used for image manipulation
  • 9. Why Amazon? Simple. Right now, they are the market leader... But the competition is good. Tight integration between services RESTful APIs for their services Lots of documentation and libraries
  • 10. Amazon Ec2 Servers “on demand”. Pay by the hour: $0.10 - $0.80/hour Non-persistent. Forces you to automate your configuration. RightScale helps a lot with this. Elastic IP can give you a static IP Elastic Block Store gives you persistent data store
  • 11. Amazon S3 Oldest of the publicly available web services Scalable, reliable data storage mechanism Bucket/object concept Pay for the data you are storing, as well as bandwidth in and out $0.15/GB stored. $0.10/GB transferred. $0.01/ request. Very fine grained permissions
  • 12. CloudFront Similar to LimeLight, Akamai Low latency, high data rate transfers 8 edge locations in the US Origin server is an S3 bucket 24 hour object expiration Very simple API acf = RightAws::AcfInterface.new acf.create_distribution('pictr.s3.amazonaws.com', 'Woo-Hoo!', true)
  • 13. Amazon Simple Queue Service Reliable, scalable queue PUSH and PULL messages Messages can be up to 8K of text Messages are “locked” as they are processed, preventing them from being read multiple times.
  • 14. Amazon SimpleDB Simple (but powerful) database Non-relational. No tables, only “domains”. No joins. No schema. Define it as you go. All data is stored as strings. Attributes can have up to 256 values. Automatically indexes all your data. Not exactly a speed daemon.
  • 16. ActiveSDB RightAws::ActiveSdb.establish_connection class Item < RightAws::ActiveSdb::Base; end Item.create_domain item = Item.create :Category => "Electronics", :Size => 47, :Manufacturer => "Sony" # Add a new "column" item["Illumination"] = "LCD" item.save # New category. Now, category is an "array" item["Category"] << "Televisions" item.save items = Item.select(:all, :conditions => ["Size = ?", 47]) # => [#<Item:0x1a8a5ec @new_record=false, @attributes={"Size"=>["47"], "Category"=>["Electronics", "Televisions"], "id"=>"788b5192-8a85-11de-a035-00264a1272e2", "Manufacturer"=>["Sony"], "Illumination"=>["LCD"]}>]
  • 17. SimpleDB caveats All data is stored as a string. Response cannot be > 1MB Maximum query execution time: 5 sec Eventually consistent (a tradeoff for availability) Speed (network)
  • 18. What does all this mean? I worry less about scaling I worry more about configuration management and automation Database performance is very consistent S3, Cloudfront handles static file serving Minimal upfront investment Only pay for what I need
  • 19. SQS SimpleDB Web Servers Converter Servers S3 Users
  • 20. Step 1: Upload S3 EC2 INSTANCE REDIRECT ON SUCCESS POST PIC.JPG INITIATES PROCESSING
  • 21. Step 2: Queue the jobs # Jobs are created jobs = [ConvertJob.new(key, "paint", "400", "-paint 5"), ConvertJob.new(key, "monochrome", "400", "-monochrome")] # Push the jobs into the queue sqs = RightAws::SqsGen2.new convert_queue = sqs.queue("convert") jobs.each do |job| convert_queue.send_message job.to_json end
  • 22. Step 3: Create SimpleDB record # class Picture < RightAws::ActiveSdb::Base # ... # end picture = Picture.create(:key => key) picture["total_conversions"] = ["paint", "monochrome"] picture.save
  • 23. SimpleDB record # Before conversion {"key"=>["uploads/f1"], "total_conversions"=>["paint", "monochrome"]} # After conversion {"key"=>["uploads/f1"], "total_conversions"=>["paint", "monochrome"], "paint"=>["processed/f1_paint.jpg"], "monochrome"=>["processed/f1_monochrome.jpg"] }
  • 24. Step 4: Processor Daemon loop do sqs = RightAws::SqsGen2.new convert_queue = sqs.queue("convert") message = convert_queue.pop if message job = JSON.parse message.to_s puts "Found a new message #{job.key}" job.run! end sleep(5) end
  • 25. Demo

Editor's Notes

  1. rightscale is a cloud management platform goal is to give you an overview of some of the cloud technologies, and how you can use ruby to leverage them for your own app will show you a sample app
  2. no users, no permissions. nothing.
  3. photo processing is a good sample app.
  4. completely contrived could scale pretty well if needed. around 300 lines of code
  5. tongue in cheek
  6. boot in a few minutes animoto story
  7. starling, based on memcached beanstalkd
  8. people are starting to look at alternatives to traditional ACID databases. too much overhead, and not scalable enough. database is first big bottleneck very consistent. 100, 10,000, 1,000,000 records all had similar response time. ~100ms return from a query is ids, you need to reload to get attributes
  9. first version of API had a very custom. algabraic query language. now supporting more SQL like expressions. union, intersection. now deprecated.
  10. get a token to retrieve next set of results if results are too big
  11. show the job.rb class
  12. Very similar to activerecord
  13. job is a ConvertJob. show it.