The Future is Now: Leveraging the Cloud with Ruby

3,177 views

Published on

My presentation from the Ruby Hoedown on cloud computing and how Ruby developers can take advantage of cloud services to build scalable web applications.

Published in: Technology
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,177
On SlideShare
0
From Embeds
0
Number of Embeds
216
Actions
Shares
0
Downloads
0
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide
  • The Future is Now: Leveraging the Cloud with Ruby

    1. 2. The Future is Now Leveraging the Cloud with Ruby Robert Dempsey Atlantic Dominion Solutions
    2. 3. <ul><li>CEO, Atlantic Dominion Solutions </li></ul><ul><li>Founder, Rails For All </li></ul><ul><li>Chair, acts_as_conference </li></ul><ul><li>Co-chair, doterati Membership </li></ul><ul><li>BA, Computer Science, Rollins </li></ul><ul><li>MBA Candidate 2009 </li></ul><ul><li>CSM in-training </li></ul>Robert Dempsey
    3. 4. I’m angry
    4. 5. Like mad cow angry
    5. 6. If I hear this one more time… Rails can’t scale
    6. 7. There will be trouble!
    7. 8. Ruby on Rails can scale… … if you understand how to scale it.
    8. 9. Rails MVC Architecture http://wiki.rubyonrails.org/rails/pages/UnderstandingRailsMVC
    9. 10. Rails MVC Overview http://betterexplained.com/articles/intermediate-rails-understanding-models-views-and-controllers/
    10. 12. Where the cloud comes in http://betterexplained.com/articles/intermediate-rails-understanding-models-views-and-controllers/
    11. 13. I want to… <ul><li>Not have to buy anything </li></ul><ul><li>Not have to think about resources </li></ul><ul><ul><li>Servers </li></ul></ul><ul><ul><li>Storage </li></ul></ul><ul><li>Easily scale my application </li></ul>
    12. 14. What is scalability? <ul><li>“…ability to either handle growing amounts of work in a graceful manner, or to be readily enlarged.” </li></ul><ul><li>“…it can refer to the capability of a system to increase total throughput under an increased load when resources (typically hardware) are added.” </li></ul>http://en.wikipedia.org/wiki/Scalability
    13. 15. Let’s add to that An application and the resources it uses grow as demand increases.
    14. 16. What I need… <ul><li>Servers </li></ul><ul><li>Storage </li></ul><ul><li>Access to other utilities </li></ul><ul><li>Do it all without buying anything upfront </li></ul><ul><li>Do it all with Ruby </li></ul><ul><li>The cloud! </li></ul>
    15. 17. <ul><li>Clusters </li></ul><ul><ul><li>High-availability (HA) </li></ul></ul><ul><ul><li>Load-balancing (LB) </li></ul></ul><ul><li>Grids </li></ul>Life Before The Cloud
    16. 18. High-availability cluster
    17. 19. Load balancing cluster
    18. 20. Grid
    19. 21. <ul><li>You can’t buy it on your personal credit card </li></ul><ul><li>They are trying to sell you hardware </li></ul><ul><li>There is no API </li></ul><ul><li>You need to rearchitect your systems for it </li></ul><ul><li>It takes more than 10 minutes to provision </li></ul><ul><li>You need to specify the number of machines you want upfront </li></ul><ul><li>You own all the hardware </li></ul>It’s not a cloud if… http://www.redmonk.com/jgovernor/2008/03/13/15-ways-to-tell-its-not-cloud-computing/
    20. 22. <ul><li>Compute resources packaged as a utility </li></ul><ul><li>Can use clusters and grids </li></ul><ul><li>Pay-as-you-go model </li></ul><ul><li>Examples </li></ul><ul><ul><li>Amazon Web Services - EC2, S3 </li></ul></ul><ul><ul><li>HP Utility Computing Services </li></ul></ul><ul><ul><li>Sun Microsystems’ Network.com </li></ul></ul>Utility computing
    21. 23. Cloud computing, defined http://www.infoworld.com/article/08/04/07/15FE-cloud-computing-reality_1.html “ A way to increase capacity or add capabilities on the fly without investing in new infrastructure, training new personnel, or licensing new software.” - InfoWorld, April 2008
    22. 24. The cloud is all encompassing <ul><li>SaaS </li></ul><ul><li>Utility computing </li></ul><ul><li>Web services in the cloud </li></ul><ul><li>Platform as a services (PaaS) </li></ul><ul><li>Managed service providers (MSP) </li></ul><ul><li>Service commerce platforms </li></ul><ul><li>Internet integration </li></ul>
    23. 25. Why is this important? &quot;By 2011, early technology adopters will forgo capital expenditures and instead purchase 40 percent of their IT infrastructure as a service. Increased high-speed bandwidth makes it practical to locate infrastructure at other sites and still receive the same response times. Enterprises believe that as service-oriented architecture (SOA) becomes common, 'cloud computing' will take off, thus untying applications from specific infrastructure.” - Gartner Group
    24. 26. <ul><li>No hardware to buy </li></ul><ul><li>No infrastructure to support </li></ul><ul><li>Add capability with minimal coding </li></ul>Advantages
    25. 27. <ul><li>Options and Pricing </li></ul><ul><li>Standard EC2 Deployment </li></ul><ul><li>Recommendations </li></ul><ul><li>Code </li></ul><ul><li>Wrap-up </li></ul>Agenda
    26. 28. <ul><li>Amazon Web Services </li></ul><ul><li>Mor.ph </li></ul><ul><li>RightScale </li></ul><ul><li>Heroku </li></ul><ul><li>Joyent Accelerator </li></ul><ul><li>Vertebra – Engine Yard (Coming Soon) </li></ul>What do we have to work with?
    27. 29. <ul><li>PoolParty </li></ul><ul><li>Scalr </li></ul><ul><li>ElasticRails </li></ul><ul><li>WeoCEO </li></ul>DIY Clouds
    28. 30. <ul><li>Amazon EC2 </li></ul><ul><ul><li>$0.10 - $0.80 / compute hour + transfer costs </li></ul></ul><ul><li>Amazon S3 </li></ul><ul><ul><li>$0.15 / GB + transfer costs </li></ul></ul><ul><li>Amazon SQS </li></ul><ul><ul><li>$0.01 / 10K requests + transfer costs </li></ul></ul><ul><li>Amazon SimpleDB </li></ul><ul><ul><li>$0.14 / machine hour + $1.50/GB/month storage + transfer costs </li></ul></ul>Amazon Web Services
    29. 31. <ul><li>Pros </li></ul><ul><ul><li>Pay-as-you-go </li></ul></ul><ul><ul><li>Use one or many </li></ul></ul><ul><ul><li>No infrastructure purchases </li></ul></ul><ul><ul><li>Third-party service providers </li></ul></ul><ul><li>Cons </li></ul><ul><ul><li>Need to build reliability yourself </li></ul></ul><ul><ul><li>Configuration overhead with EC2 </li></ul></ul>Amazon Web Services
    30. 32. Morph
    31. 33. <ul><li>Pros </li></ul><ul><ul><li>Pay-as-you-go </li></ul></ul><ul><ul><li>10 minutes sign-up to launch, near 0 configuration </li></ul></ul><ul><ul><li>One click scaling </li></ul></ul><ul><ul><li>Fully managed and backed-up, HW load balancing </li></ul></ul><ul><ul><li>Migrations run on deploy </li></ul></ul><ul><li>Cons </li></ul><ul><ul><li>No SSH or file-level access </li></ul></ul>Morph
    32. 34. <ul><li>RightSite </li></ul><ul><ul><li>$2500 setup and $500/month </li></ul></ul><ul><li>RightGrid </li></ul><ul><ul><li>$2500 setup and $500/month </li></ul></ul><ul><li>RightScale Premium </li></ul><ul><ul><li>$2500 setup and $750/month </li></ul></ul><ul><li>AWS fees </li></ul>RightScale
    33. 35. <ul><li>Pros </li></ul><ul><ul><li>Multitude of configuration options </li></ul></ul><ul><ul><li>Scale-on-demand capability </li></ul></ul><ul><ul><li>One-click multi-server deployments </li></ul></ul><ul><ul><li>Manage everything AWS from single interface </li></ul></ul><ul><li>Cons </li></ul><ul><ul><li>Expensive </li></ul></ul><ul><ul><li>A lot of up-front configuration </li></ul></ul>RightScale
    34. 36. <ul><li>Free (for now) </li></ul><ul><li>Later </li></ul><ul><ul><li>Based on “work” </li></ul></ul><ul><ul><li>Ask them ;) </li></ul></ul>Heroku
    35. 37. <ul><li>Pros </li></ul><ul><ul><li>Do everything via the browser </li></ul></ul><ul><ul><li>Automatic scaling </li></ul></ul><ul><ul><li>Work locally then deploy </li></ul></ul><ul><li>Cons </li></ul><ul><ul><li>Heroku.com domain name </li></ul></ul><ul><ul><li>Choices are made for you </li></ul></ul>Heroku
    36. 38. <ul><li>½ GiB </li></ul><ul><ul><li>$75/month </li></ul></ul><ul><ul><li>1/8 CPU, 512 MB RAM, 10 GB storage </li></ul></ul><ul><li>1 GB </li></ul><ul><ul><li>$125/month </li></ul></ul><ul><ul><li>½ CPU, 1 GB RAM, 15 GB storage </li></ul></ul><ul><li>2 GB </li></ul><ul><ul><li>$250/month </li></ul></ul><ul><ul><li>1 CPU, 2 GB RAM, 25GB storage </li></ul></ul>Joyent Accelerator
    37. 39. <ul><li>Pros </li></ul><ul><ul><li>Pay-as-you-go </li></ul></ul><ul><ul><li>Solid hardware </li></ul></ul><ul><ul><li>ZFS = scalable storage </li></ul></ul><ul><li>Cons </li></ul><ul><ul><li>Call in to scale your app </li></ul></ul><ul><ul><li>OpenSolaris is fun </li></ul></ul><ul><ul><li>Not really cloud computing </li></ul></ul>Joyent Accelerator
    38. 40. <ul><li>Free (Ruby gem) + AWS </li></ul>PoolParty
    39. 41. <ul><li>Pros </li></ul><ul><ul><li>Easy configuration and deployment </li></ul></ul><ul><ul><li>Highly configurable EC2 instances </li></ul></ul><ul><li>Cons </li></ul><ul><ul><li>Lacking documentation </li></ul></ul><ul><ul><li>Supports only Ubuntu EC2 AMIs </li></ul></ul><ul><ul><li>Not production ready (June 20) </li></ul></ul>PoolParty
    40. 42. <ul><li>Free (Google code) + AWS </li></ul><ul><li>$50/month + AWS </li></ul>Scalr
    41. 43. <ul><li>Pros </li></ul><ul><ul><li>Free for base code </li></ul></ul><ul><ul><li>Configurable auto-scaling of everything </li></ul></ul><ul><ul><li>Configurable automatic db backups </li></ul></ul><ul><li>Cons </li></ul><ul><ul><li>Have to use their base AMI </li></ul></ul>Scalr
    42. 44. <ul><li>Free Community Edition + AWS </li></ul><ul><li>$10/month Personal Edition + AWS </li></ul>ElasticRails
    43. 45. <ul><li>Pros </li></ul><ul><ul><li>Save VM for a virtual environment (VMware) </li></ul></ul><ul><ul><li>Build a custom bundle and deploy to EC2 </li></ul></ul><ul><ul><li>GUI management console </li></ul></ul><ul><li>Cons </li></ul><ul><ul><li>Elastic server = application stack </li></ul></ul><ul><ul><li>Community edition = non-commercial use </li></ul></ul><ul><ul><li>Rails 2.0.2 is the latest </li></ul></ul>ElasticRails
    44. 46. <ul><li>Free + AWS </li></ul>WeoCEO
    45. 47. <ul><li>Pros </li></ul><ul><ul><li>Automatic load balancing </li></ul></ul><ul><ul><li>Automatic scaling </li></ul></ul><ul><ul><li>Set min and max servers </li></ul></ul><ul><li>Cons </li></ul><ul><ul><li>Command-line setup </li></ul></ul><ul><ul><li>No specific documentation on using Rails </li></ul></ul>WeoCEO
    46. 48. <ul><li>Options and Pricing </li></ul><ul><li>Standard EC2 Deployment </li></ul><ul><li>Recommendations </li></ul><ul><li>Code </li></ul><ul><li>Wrap-up </li></ul>Agenda
    47. 49. Standard EC2 Deploy
    48. 50. Standard EC2 Deploy <ul><li>Small instance: $2.40/day </li></ul><ul><ul><li>2 x LB $144 </li></ul></ul><ul><ul><li>2 x HTTP $144 </li></ul></ul><ul><ul><li>2 x DB $144 </li></ul></ul><ul><ul><li>Total $432/month </li></ul></ul>
    49. 51. <ul><li>Options and Pricing </li></ul><ul><li>Standard EC2 Deployment </li></ul><ul><li>Recommendations </li></ul><ul><li>Code </li></ul><ul><li>Wrap-up </li></ul>Agenda
    50. 52. <ul><li>Developer or sys admin? </li></ul><ul><li>Pay for it… </li></ul><ul><ul><li>Morph </li></ul></ul><ul><ul><li>Scalr </li></ul></ul><ul><ul><li>RightScale </li></ul></ul>Recommendations
    51. 53. <ul><li>Options and Pricing </li></ul><ul><li>Standard EC2 Deployment </li></ul><ul><li>Recommendations </li></ul><ul><li>Code </li></ul><ul><ul><li>Books </li></ul></ul><ul><ul><li>Articles </li></ul></ul><ul><ul><li>Gems </li></ul></ul><ul><ul><li>Plugins </li></ul></ul><ul><ul><li>Code </li></ul></ul><ul><li>Wrap-up </li></ul>Agenda
    52. 54. Books
    53. 55. AWS Articles <ul><li>Introduction to AWS for Ruby Developers </li></ul><ul><li>Economical Use of Amazon S3 with Ruby on Rails </li></ul><ul><li>Using Amazon S3, EC2, SQS, Lucene, and Ruby for Web Spidering </li></ul><ul><li>Sample Applications in Ruby for Amazon FPS </li></ul>
    54. 56. Gems <ul><li>right_aws </li></ul><ul><ul><li>EC2, S3, SQS, SimpleDB </li></ul></ul><ul><li>right_http_connection </li></ul><ul><li>remit </li></ul><ul><li>poolparty </li></ul>
    55. 57. Plugins <ul><li>S3 </li></ul><ul><ul><li>paperclip </li></ul></ul><ul><ul><li>attachment_fu </li></ul></ul><ul><ul><li>backup_fu </li></ul></ul><ul><li>SimpleDB </li></ul><ul><ul><li>AWS SDB Proxy </li></ul></ul><ul><li>SQS </li></ul><ul><ul><li>ActiveMessaging </li></ul></ul>
    56. 58. S3: Using Paperclip right_aws right_http_connection Gems to use
    57. 59. S3: Using Paperclip class Product < ActiveRecord::Base has_attached_file :photo, :styles => { :medium => “300x300”, :thumb => “100x100” }, :storage => :s3, :s3_credentials => “#{RAILS_ROOT}/config/s3.yml”, :path => “:attachment/:id/:style.:extension”, :bucket => ‘introtoruby_development’ end app/models/product.rb
    58. 60. SQS sqs Gems to use
    59. 61. SQS Require ‘rubygems’ Require ‘sqs’ SQS.access_key_id = ‘YOUR_ACCESS_KEY_ID’ SQS.secret_access_key = ‘YOUR_SECRET_ACCESS_KEY’ config/environment.rb
    60. 62. SQS # Get an SQS queue q = SQS.get_queue ”my_sqs_queue_name” # Send a message made up of the job id q.send_message “#{self.id}” # Grab a job from the queue message = queue.receive_message # Delete the job from the queue message.delete app/models/job.rb
    61. 63. SQS: right_aws gem # Create a queue sqs = RightAws::SqsGen2.new(aws_access_key_id, aws_secret_access_key) queue1 = sqs.queue('my_awesome_queue') # Create a second queue queue2 = RightAws::SqsGen2::Queue.create(sqs, ‘ my_cool_queue’, true) puts queue2.size Gems used: right_aws, right_http_connection
    62. 64. SQS: right_aws gem # Pull a message from the queue and make it invisible message1 = queue2.receive message1.visibility = 0 puts message1 # Clear the queue, add a message, delete first accessible msg queue2.clear(true) queue2.send_message(‘Ola-la!’) message2 = queue2.pop
    63. 65. SimpleDB: right_aws gem # Create an instance of the SDB interface sdb = RightAws::SdbInterface.new( :server => ‘sdb.amazonaws.com’ :port => 443 :protocol => ‘https’ :signature_version => '0’ :multi_thread => true|false :logger => Logger Object) Gems used: right_aws, right_http_connection
    64. 66. SimpleDB: right_aws gem # Create a new domain sdb.create_domain(‘toys’) # Delete a domain Sdb.delete_domain(‘toys’) # Create and save attributes for Jon and Silvia attributes = {} attributes['Jon'] = %w{ car beer } attributes['Silvia'] = %w{ beetle rolling_pin kids } sdb.put_attributes ‘family’, ‘toys’
    65. 67. SimpleDB: right_aws gem # Get attributes sdb.get_attributes(‘family’, ‘toys’) # Get attributes only for cat sdb.get_attributes(‘family’, ‘toys’, ‘cat’) # Query query = ”[‘cat’ = ‘claw’]” sdb.query(‘family’, query) # Query returning 10 items sdb.query(‘family’, query, 10)
    66. 68. <ul><li>Options and Pricing </li></ul><ul><li>Standard EC2 Deployment </li></ul><ul><li>Recommendations </li></ul><ul><li>Code </li></ul><ul><li>Wrap-up </li></ul>Agenda
    67. 70. THANK YOU
    68. 71. Questions? ADS http ://www.techcfl.com Blog http://rorblog.techcfl.com Twitter http://www.twitter.com/rdempsey LinkedIn http://www.linkedin.com/in/techcfl

    ×