1 / 25

Deploying Rails on the cheap

Deploying Rails on the cheap. By Carl Mercier carl@karabunga.com Defensio.com. What it takes. Linux Mongrel Lots of memory (~50 megs / Mongrel) Good monitoring tools Monit (http://tildeslash.com/monit/) Munin ( http://munin.projects.linpro.no/ ) Capistrano And MORE memory.

arty
Download Presentation

Deploying Rails on the cheap

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Deploying Railson the cheap By Carl Mercier carl@karabunga.com Defensio.com

  2. What it takes • Linux • Mongrel • Lots of memory (~50 megs / Mongrel) • Good monitoring tools • Monit (http://tildeslash.com/monit/) • Munin (http://munin.projects.linpro.no/) • Capistrano • And MORE memory.

  3. Hosting options • Shared hosting • One Linux installation for many users • VPS (Virtual Private Server) • Many Linux installations on a single server (virtualized) • Amazon EC2 • VPS on steroids! • Dedicated server • Your own unshared server; rented or owned • Not covered today

  4. Shared hosting • Pros: • Cheap • Maintenance taken care of by your provider

  5. Shared hosting • Cons: • You get what you pay for (not much!) • Slow, slow, slow • Not enough memory can be allocated to you • Often uses FastCGI or a single Mongrel (doesn’t scale) • No control (sometimes non-root SSH) • Support team doesn’t know Rails • You’ll outgrow that in no time (ask Marc-André) I simply DON’T recommend shared hosting for Rails.

  6. Virtual Private Server • Great place to start! • ~$20/mo and up • Choose your provider carefully: • Make sure you have dedicated and guaranteed resources • Read plenty of reviews. • http://webhostingtalk.com • Don’t be cheap: it will backfire.

  7. VPS: Slicehost.com My favorite VPS provider! And damn cheap too!

  8. VPS: Slicehost.com • That money gets you “slices” of: • A Quad-core 64-bit servers (8+ghz) running Xen virtualization instances • RAID1 disk storage • Gigabit network backbone • Your own distro • Full root access • Between 7 and 24 users / server (vs 1000s for shared) • Awesome community and support (really)

  9. VPS: What kind of slice? • Minimum of 256 megs of RAM • Probably limited to 1 or 2 sites with that • No Apache! Go nginx and/or Swiftiply instead. • Keep memory usage at a minimum (ie: MySQL) and keep it for Mongrel. • Beware of VPS providers that don’t allow full root access.

  10. VPS: Slicehost.com Demo http://manage.slicehost.com

  11. VPS: Pros and Cons • Pros: • Only pay for what you need • Enough resources to run Rails effectively • Easy upgrade/downgrade • VERY easy to get started • You control everything • Affordable (great bang for your buck) • GreatSlicehostwikiwith plenty of information • http://wiki.slicehost.com (who would’ve guessed?) • Cons: • You have to build your slice from scratch • Can be outgrown rapidly if your world-changing app really takes off • IO • Not cost effective when you become big

  12. Recommended VPS providers • Slicehost.com • my personal favorite • they are giving MoR folks VIP treatment! • Rimuhosting.com • heard great things • more expensive (for no apparent benefit)

  13. Amazon EC2 • EC2 = Elastic Computing Cloud • Similar to a Slicehost VPS • Your own distro (even Windows!) • Full root access • Shared machines with Xen • But sometimes better • Auto-scaling • Hourly billing • Minimum 1.7 gigs of RAM!

  14. EC2: Pricing (CPU) One EC2 Compute Unit (CU) provides the equivalent CPU capacity of a 1.0-1.2 GHz 2007 Opteron or 2007 Xeon processor. This is also the equivalent to an early-2006 1.7 GHz Xeon processor.

  15. EC2: Pricing (bandwidth) • Incoming data (download) • $0.10/GB • Outgoing data (upload to users) • $0.18/GB for first 10 TB / month • $0.16/GB for next 40 TB / month • $0.13/GB for over 50 TB / month • Transfer between EC2-EC2 or EC2-S3 is free

  16. EC2: The AMI • Stands for Amazon Machine Image • A Linux installation bundled up and ready to be booted • EC2 on Rails • (http://ec2onrails.rubyforge.org/) • Ubuntu Gutsy 7.10, Apache 2.2, Mongrel Cluster, MySQL 5 • Rightscale’s Rails all-in-one • (http://info.rightscale.com/2007/9/20/rails-on-ec2-standard)

  17. EC2: What's to love? • Complete control • You pay hourly, not monthly (more on that later) • Almost instant instances • Lots of RAM per dollar • (remember, you need a lot of it!)

  18. EC2: What's to love? (cont'd) • Plenty of disk space • Easy integration with S3 (unlimited storage!) • API to control your instances • Scaling can be automated • Amazing firewall features • Many great “base” AMI available

  19. EC2: Change your mindset! Rebuild/deploy new servers with no downtime Test in a real-world scenario Turn your staging servers into production servers Auto-scale your app …and the database too! Backup like a champ (S3)

  20. EC2: Drawbacks Very confusing at first No static IP No permanent storage IO Not for email

  21. EC2: Confusing, huh? Yes, it’s confusing, but it’s not so bad! • Read, read, read • http://docs.amazonwebservices.com/AWSEC2/2007-03-01/GettingStartedGuide/ • http://developer.amazonwebservices.com/ec2/forums • http://info.rightscale.com (blog section) • Understand the drawbacks, their implications and the solutions • Use the right tools • I recommend RightScale.com • Or just ask me!

  22. EC2: No static IP? • New instance, new IP • They don’t change that often anyways • If they do, you have another problem! • Give all your instances host names • Use low TTL = minimal downtime • Plenty of good DNS servers: • dnsmadeeasy.com, everydns.net, zoneedit.com • I realized that static IPs were not a necessity.

  23. EC2: Lack of persistent storage • Your instance dies, your data dies with it! • The 10/150 rule • Put growing data on /mnt • Symlinks • Logrotate to /mnt • Backup, backup, backup • S3 • Replicate DB to remote location • Rebundling your instance is not a good solution

  24. EC2+RightScale Demo http://rightscale.com

  25. Links AWS Zone RubyWorks Production Stack on EC2 Amazon EC2 ephemeral storage (/mnt) and MySQL How to backup your MySQL server to S3 (not for large db) EC2 Walkthrough Installing and configuring nginx and Mongrel for Rails Amazon EC2 Gem Slicehost wiki RightScale.com WeoCEO Elastic Rails

More Related