SlideShare a Scribd company logo
BUILDING
               CLOUD
              CASTLES
ben scofield / @bscofield / LRUG / 11 April 2011
this presentation is a
  WORK IN PROGRESS


http://www.flickr.com/photos/natlockwood/1006351276/
Building Cloud Castles - LRUG
not just
the cloud allows
LIMITED ACCESS
FINDING PROBLEMS
LOCAL
$ ssh deploy@production.server.com
Linux production.server #1 SMP Sat Dec 5 16:04:55 UTC 2009 i686

To access official Ubuntu documentation, please visit:
http://help.ubuntu.com/
Last login: Fri Jan 28 16:33:49 2011 from local.host
deploy@production:~$ cd /var/log/apache2
deploy@production:/var/log/apache2$ tail error.log
[Sun Jan 23 06:25:02 2011] [notice] Apache/2.2.12 (Ubuntu) Phusion_Passenger...
[Tue Jan 25 15:21:42 2011] [error] [client 118.129.166.97] Invalid URI in ...
[Fri Jan 28 12:01:50 2011] [error] [client 85.132.70.133] client sent HTTP/1...
[Sun Jan 30 06:25:06 2011] [notice] SIGUSR1 received. Doing graceful restart
NODE   NODE   NODE   NODE


NODE   NODE   NODE   NODE
CLOUD
$ heroku logs --remote production
2011-04-11T01:34:22-07:00 app[web.1]: Rendered text template within layout...
2011-04-11T01:34:22-07:00 app[web.1]: Completed 200 OK in 54ms
2011-04-11T01:34:30-07:00 app[web.3]: Rendered text template within layout...
2011-04-11T01:34:30-07:00 app[web.3]: Completed 200 OK in 111ms (Views:57....
2011-04-11T08:34:42+00:00 heroku[router]: GET devcenter.heroku.com/article...
2011-04-11T01:34:42-07:00 heroku[nginx]: GET /articles/facebook HTTP/1.0 |...
2011-04-11T01:34:42-07:00 app[worker.1]: [Worker(host:railgun64.53370 pid:...
2011-04-11T01:34:42-07:00 app[worker.1]: [Worker(host:railgun64.53370 pid:...
http://hoptoadapp.com
http://newrelic.com
source
FIXING PROBLEMS
LOCAL
$ ssh deploy@production.server.com
Linux production.server #1 SMP Sat Dec 5 16:04:55 UTC 2009 i686

To access official Ubuntu documentation, please visit:
http://help.ubuntu.com/
Last login: Fri Jan 28 16:33:49 2011 from local.host
deploy@production:~$ cd /var/www/app/current/
deploy@production:/var/www/app/current$ rails console production
Loading production environment (Rails 3.0.3)
>> Article.count
 => 112
>> Article.where(:problem => true).update_attributes(:problem => false)
CLOUD
require 'test_helper'

class ArticleTest < ActiveSupport::TestCase
  context 'Broken articles' do
    setup do
      5.times.do { Factory :broken_article }
    end

    should 'be fixable' do
      assert_equal 5, Article.where(:problem => true).count
      Article.fix_problem_articles
      assert_equal 0, Article.where(:problem => true).count
    end
  end
end




class Article
  def self.fix_problem_articles
    where(:problem => true).update_attributes(:problem => false)
  end
end
the cloud is
UNRELIABLE
locally
LOCAL
class Comic < ActiveRecord::Base
  has_attached_file :cover, :styles => {
    :thumb => "80x120>",
    :medium => "300x450>"
  }
end




$ cd public/system
$ ls /covers
10/ 12/ 53/ 81/
$ ls /covers/10/
medium/ original/ thumb/
$ ls /covers/10/medium
batman-450.png
NODE   NODE   NODE   NODE


NODE   NODE   NODE   NODE
EVENTUAL
CONSISTENCY
CLOUD
class Comic < ActiveRecord::Base
  has_attached_file :cover, :storage => s3,
    :s3_credentials => {
       :access_key_id => ENV['S3_KEY'],
       :secret_access_key => ENV['S3_SECRET']
    },
    :bucket => 'comicsapp',
    :url => ":s3_path_url",
    :s3_headers => { 'Expires' => 1.year.from_now.httpdate },
    :styles => {
       :thumb => "80x120>",
       :medium => "300x450>"
    }
end
SERVER   SERVER
STORAGE




SERVER             SERVER
the cloud can be
EXPENSIVE
NODE   NODE   NODE   NODE


NODE   NODE   NODE   NODE
CACHING

NODE   NODE     NODE   NODE


NODE   NODE     NODE   NODE
SERVER
CACHING



SERVER
the cloud prefers
SMALL APPS
NODE   NODE   NODE   NODE


NODE   NODE   NODE   NODE
NODE   NODE   NODE   NODE


NODE   NODE   NODE   NODE
REST
NODE   NODE   NODE
                     EXTERNAL
                      SERVICE
NODE   NODE   NODE
Building Cloud Castles - LRUG
SERVER
SERVER   SERVER
SERVER   SERVICE
the cloud is
UNRELIABLE
remotely
CLOUD
class Searcher
  cattr_accessor :index

  def self.index
    @api ||= IndexTank::Client.new(ENV['INDEXTANK_API_URL'])
    @index = @api.indexes 'articles'
  end

  def self.search(term)
    raw = self.index.search(term, :function => 1)
    results = raw['results'].to_a

    article_ids = results.map {|result| result['docid'] }

    unsorted = Article.published.where(:id => article_ids)
    results.map { |result|
      unsorted.find {|u| u.id.to_i == result['docid'].to_i}
    }.compact
  end
end
EXPECT FAILURE
CLOUD
class Searcher
  # ...

  def self.search(term)
    results = begin
      raw = self.index.search(term, :function => 1)
      raw['results'].to_a
    rescue URI::InvalidURIError # An IndexTank error occurred
      search_by_sql(term)['results']
    end

    # ...
  end

  def self.search_by_sql(term)
    {'results' => Article.where(['content ILIKE ?', "%#{term}%"]).
      map {|a| {'docid' => a.id}}}
  end
end
DEFENSIVE CODING
the cloud is
ALWAYS CURRENT
RAISE YOUR HAND if
INFRASTRUCTURE
PATTERNS and VIRTUES
HUMILITY
LAZINESS
PARANOIA
SOLID
single responsibility principle
liskov substitution principle
interface segregation principle
CLOUD PRACTICES
are
BEST PRACTICES
THANK YOU!
 Ben Scofield / @bscofield
 http://benscofield.com
 http://speakerrate.com/t/7123

More Related Content

PDF
Great Developers Steal
PDF
Building Cloud Castles
PDF
With a Mighty Hammer
PDF
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
KEY
Keeping it small: Getting to know the Slim micro framework
PDF
How to develop modern web application framework
PDF
優しいWAFの作り方
KEY
Elegant APIs
Great Developers Steal
Building Cloud Castles
With a Mighty Hammer
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Keeping it small: Getting to know the Slim micro framework
How to develop modern web application framework
優しいWAFの作り方
Elegant APIs

What's hot (20)

PDF
Keeping it Small: Getting to know the Slim Micro Framework
PDF
Developing apps using Perl
PDF
Keeping it small - Getting to know the Slim PHP micro framework
PDF
Advanced symfony Techniques
PPT
Slim RedBeanPHP and Knockout
PDF
Inside Bokete: Web Application with Mojolicious and others
PDF
Symfony 2.0 on PHP 5.3
PDF
Bullet: The Functional PHP Micro-Framework
KEY
ISUCONアプリを Pythonで書いてみた
PDF
Perl web frameworks
KEY
And the Greatest of These Is ... Rack Support
PDF
Silex Cheat Sheet
KEY
Phpne august-2012-symfony-components-friends
PDF
Concurrecny inf sharp
PPTX
10 tips for making Bash a sane programming language
PDF
Best Practices in Plugin Development (WordCamp Seattle)
PDF
Nubilus Perl
PDF
Symfony 2
PPTX
Using WordPress as your application stack
PDF
Rails 3 overview
Keeping it Small: Getting to know the Slim Micro Framework
Developing apps using Perl
Keeping it small - Getting to know the Slim PHP micro framework
Advanced symfony Techniques
Slim RedBeanPHP and Knockout
Inside Bokete: Web Application with Mojolicious and others
Symfony 2.0 on PHP 5.3
Bullet: The Functional PHP Micro-Framework
ISUCONアプリを Pythonで書いてみた
Perl web frameworks
And the Greatest of These Is ... Rack Support
Silex Cheat Sheet
Phpne august-2012-symfony-components-friends
Concurrecny inf sharp
10 tips for making Bash a sane programming language
Best Practices in Plugin Development (WordCamp Seattle)
Nubilus Perl
Symfony 2
Using WordPress as your application stack
Rails 3 overview
Ad

Viewers also liked (11)

PDF
How to Be Awesome in 2.5 Steps
PDF
Resourceful Plugins
PDF
Cleanliness is Next to Domain-Specificity
PDF
Advanced RESTful Rails
PPT
KEY
Page Caching Resurrected
PDF
Open Source: A Call to Arms
PDF
Thinking Small
PDF
Ship It
PDF
Mastery or Mediocrity
PDF
Intentionality: Choice and Mastery
How to Be Awesome in 2.5 Steps
Resourceful Plugins
Cleanliness is Next to Domain-Specificity
Advanced RESTful Rails
Page Caching Resurrected
Open Source: A Call to Arms
Thinking Small
Ship It
Mastery or Mediocrity
Intentionality: Choice and Mastery
Ad

Similar to Building Cloud Castles - LRUG (20)

PDF
One-Man Ops
PDF
Cutting through the fog of cloud
PDF
Manage cloud infrastructures using Zend Framework 2 (and ZF1)
PPTX
An intro to Docker, Terraform, and Amazon ECS
PDF
Infrastructureascode slideshare-160331143725
PPTX
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
PDF
Infrastructureascode slideshare-160331143725
PPTX
Harmonious Development: Via Vagrant and Puppet
PDF
CoreOS, or How I Learned to Stop Worrying and Love Systemd
PDF
PDF
Fullstack conf 2017 - Basic dev pipeline end-to-end
PDF
Nell’iperspazio con Rocket: il Framework Web di Rust!
PDF
AWS Lambda from the trenches
PDF
Burn down the silos! Helping dev and ops gel on high availability websites
PPTX
Docker Security workshop slides
PDF
Lean Php Presentation
ODP
Itb session v_memcached
KEY
fog or: How I Learned to Stop Worrying and Love the Cloud
PPT
Heavy Web Optimization: Backend
KEY
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
One-Man Ops
Cutting through the fog of cloud
Manage cloud infrastructures using Zend Framework 2 (and ZF1)
An intro to Docker, Terraform, and Amazon ECS
Infrastructureascode slideshare-160331143725
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
Infrastructureascode slideshare-160331143725
Harmonious Development: Via Vagrant and Puppet
CoreOS, or How I Learned to Stop Worrying and Love Systemd
Fullstack conf 2017 - Basic dev pipeline end-to-end
Nell’iperspazio con Rocket: il Framework Web di Rust!
AWS Lambda from the trenches
Burn down the silos! Helping dev and ops gel on high availability websites
Docker Security workshop slides
Lean Php Presentation
Itb session v_memcached
fog or: How I Learned to Stop Worrying and Love the Cloud
Heavy Web Optimization: Backend
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)

More from Ben Scofield (17)

PDF
Mind Control - DevNation Atlanta
PDF
Understanding Mastery
PDF
Mind Control: Psychology for the Web
PDF
The State of NoSQL
PDF
NoSQL @ CodeMash 2010
PDF
NoSQL: Death to Relational Databases(?)
KEY
Charlotte.rb - "Comics" Is Hard
KEY
The Future of Data
PDF
WindyCityRails - "Comics" Is Hard
PDF
"Comics" Is Hard: Alternative Databases
KEY
Mind Control on the Web
KEY
How the Geeks Inherited the Earth
PDF
And the Greatest of These Is ... Space
PDF
"Comics" Is Hard: Domain Modeling Challenges
KEY
Page Caching Resurrected: A Fairy Tale
PDF
All I Need to Know I Learned by Writing My Own Web Framework
PDF
Advanced Restful Rails - Europe
Mind Control - DevNation Atlanta
Understanding Mastery
Mind Control: Psychology for the Web
The State of NoSQL
NoSQL @ CodeMash 2010
NoSQL: Death to Relational Databases(?)
Charlotte.rb - "Comics" Is Hard
The Future of Data
WindyCityRails - "Comics" Is Hard
"Comics" Is Hard: Alternative Databases
Mind Control on the Web
How the Geeks Inherited the Earth
And the Greatest of These Is ... Space
"Comics" Is Hard: Domain Modeling Challenges
Page Caching Resurrected: A Fairy Tale
All I Need to Know I Learned by Writing My Own Web Framework
Advanced Restful Rails - Europe

Recently uploaded (20)

PPTX
Big Data Technologies - Introduction.pptx
PPTX
Cloud computing and distributed systems.
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Empathic Computing: Creating Shared Understanding
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Spectroscopy.pptx food analysis technology
PDF
KodekX | Application Modernization Development
Big Data Technologies - Introduction.pptx
Cloud computing and distributed systems.
Chapter 3 Spatial Domain Image Processing.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Agricultural_Statistics_at_a_Glance_2022_0.pdf
cuic standard and advanced reporting.pdf
Review of recent advances in non-invasive hemoglobin estimation
Network Security Unit 5.pdf for BCA BBA.
The Rise and Fall of 3GPP – Time for a Sabbatical?
20250228 LYD VKU AI Blended-Learning.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
sap open course for s4hana steps from ECC to s4
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Empathic Computing: Creating Shared Understanding
Unlocking AI with Model Context Protocol (MCP)
Reach Out and Touch Someone: Haptics and Empathic Computing
“AI and Expert System Decision Support & Business Intelligence Systems”
Spectroscopy.pptx food analysis technology
KodekX | Application Modernization Development

Building Cloud Castles - LRUG

  • 1. BUILDING CLOUD CASTLES ben scofield / @bscofield / LRUG / 11 April 2011
  • 2. this presentation is a WORK IN PROGRESS http://www.flickr.com/photos/natlockwood/1006351276/
  • 7. LOCAL $ ssh deploy@production.server.com Linux production.server #1 SMP Sat Dec 5 16:04:55 UTC 2009 i686 To access official Ubuntu documentation, please visit: http://help.ubuntu.com/ Last login: Fri Jan 28 16:33:49 2011 from local.host deploy@production:~$ cd /var/log/apache2 deploy@production:/var/log/apache2$ tail error.log [Sun Jan 23 06:25:02 2011] [notice] Apache/2.2.12 (Ubuntu) Phusion_Passenger... [Tue Jan 25 15:21:42 2011] [error] [client 118.129.166.97] Invalid URI in ... [Fri Jan 28 12:01:50 2011] [error] [client 85.132.70.133] client sent HTTP/1... [Sun Jan 30 06:25:06 2011] [notice] SIGUSR1 received. Doing graceful restart
  • 8. NODE NODE NODE NODE NODE NODE NODE NODE
  • 9. CLOUD $ heroku logs --remote production 2011-04-11T01:34:22-07:00 app[web.1]: Rendered text template within layout... 2011-04-11T01:34:22-07:00 app[web.1]: Completed 200 OK in 54ms 2011-04-11T01:34:30-07:00 app[web.3]: Rendered text template within layout... 2011-04-11T01:34:30-07:00 app[web.3]: Completed 200 OK in 111ms (Views:57.... 2011-04-11T08:34:42+00:00 heroku[router]: GET devcenter.heroku.com/article... 2011-04-11T01:34:42-07:00 heroku[nginx]: GET /articles/facebook HTTP/1.0 |... 2011-04-11T01:34:42-07:00 app[worker.1]: [Worker(host:railgun64.53370 pid:... 2011-04-11T01:34:42-07:00 app[worker.1]: [Worker(host:railgun64.53370 pid:...
  • 14. LOCAL $ ssh deploy@production.server.com Linux production.server #1 SMP Sat Dec 5 16:04:55 UTC 2009 i686 To access official Ubuntu documentation, please visit: http://help.ubuntu.com/ Last login: Fri Jan 28 16:33:49 2011 from local.host deploy@production:~$ cd /var/www/app/current/ deploy@production:/var/www/app/current$ rails console production Loading production environment (Rails 3.0.3) >> Article.count => 112 >> Article.where(:problem => true).update_attributes(:problem => false)
  • 15. CLOUD require 'test_helper' class ArticleTest < ActiveSupport::TestCase context 'Broken articles' do setup do 5.times.do { Factory :broken_article } end should 'be fixable' do assert_equal 5, Article.where(:problem => true).count Article.fix_problem_articles assert_equal 0, Article.where(:problem => true).count end end end class Article def self.fix_problem_articles where(:problem => true).update_attributes(:problem => false) end end
  • 17. LOCAL class Comic < ActiveRecord::Base has_attached_file :cover, :styles => { :thumb => "80x120>", :medium => "300x450>" } end $ cd public/system $ ls /covers 10/ 12/ 53/ 81/ $ ls /covers/10/ medium/ original/ thumb/ $ ls /covers/10/medium batman-450.png
  • 18. NODE NODE NODE NODE NODE NODE NODE NODE
  • 20. CLOUD class Comic < ActiveRecord::Base has_attached_file :cover, :storage => s3, :s3_credentials => { :access_key_id => ENV['S3_KEY'], :secret_access_key => ENV['S3_SECRET'] }, :bucket => 'comicsapp', :url => ":s3_path_url", :s3_headers => { 'Expires' => 1.year.from_now.httpdate }, :styles => { :thumb => "80x120>", :medium => "300x450>" } end
  • 21. SERVER SERVER
  • 22. STORAGE SERVER SERVER
  • 23. the cloud can be EXPENSIVE
  • 24. NODE NODE NODE NODE NODE NODE NODE NODE
  • 25. CACHING NODE NODE NODE NODE NODE NODE NODE NODE
  • 29. NODE NODE NODE NODE NODE NODE NODE NODE
  • 30. NODE NODE NODE NODE NODE NODE NODE NODE
  • 31. REST
  • 32. NODE NODE NODE EXTERNAL SERVICE NODE NODE NODE
  • 35. SERVER SERVER
  • 36. SERVER SERVICE
  • 38. CLOUD class Searcher cattr_accessor :index def self.index @api ||= IndexTank::Client.new(ENV['INDEXTANK_API_URL']) @index = @api.indexes 'articles' end def self.search(term) raw = self.index.search(term, :function => 1) results = raw['results'].to_a article_ids = results.map {|result| result['docid'] } unsorted = Article.published.where(:id => article_ids) results.map { |result| unsorted.find {|u| u.id.to_i == result['docid'].to_i} }.compact end end
  • 40. CLOUD class Searcher # ... def self.search(term) results = begin raw = self.index.search(term, :function => 1) raw['results'].to_a rescue URI::InvalidURIError # An IndexTank error occurred search_by_sql(term)['results'] end # ... end def self.search_by_sql(term) {'results' => Article.where(['content ILIKE ?', "%#{term}%"]). map {|a| {'docid' => a.id}}} end end
  • 49. SOLID single responsibility principle liskov substitution principle interface segregation principle
  • 51. THANK YOU! Ben Scofield / @bscofield http://benscofield.com http://speakerrate.com/t/7123