Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Deploying Rails Applications

259,159 views

Published on

Covers the different options for scaling Rails applications, Nginx, a light weight HTTP server / reverse proxy, using Cron for periodic scheduled task, and Monit for monitoring rails applications.

Published in: Technology
  • If you are looking for trusted essay writing service I highly recommend ⇒⇒⇒WRITE-MY-PAPER.net ⇐⇐⇐ The service I received was great. I got an A on my final paper which really helped my grade. Knowing that I can count on them in the future has really helped relieve the stress, anxiety and workload. I recommend everyone to give them a try. You'll be glad you did.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Dating direct: ❤❤❤ http://bit.ly/2F7hN3u ❤❤❤
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Dating for everyone is here: ❤❤❤ http://bit.ly/2F7hN3u ❤❤❤
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Deploying Rails Applications

  1. 1. Deploying Rails Applications Vivek Prahlad
  2. 2. Agenda <ul><ul><li>Typical Rails deployment scenarios </li></ul></ul><ul><ul><li>Mongrel </li></ul></ul><ul><ul><li>Nginx vs. Apache vs. Lighttpd </li></ul></ul><ul><ul><li>Shared vs. Virtual vs. Dedicated hosting </li></ul></ul><ul><ul><li>Monitoring Rails Applications </li></ul></ul>
  3. 3. Typical Rails Deployment Setup Web Server (Static Content)‏ Rails App (Mongrel)‏ Database (MySQL / PostgreSQL)‏
  4. 4. Lots of Static content? Web Server (Static Content)‏ Rails App (Mongrel)‏ Database )‏ (MySQL / PostgreSQL)‏ Load Balancer Cluster
  5. 5. Heavy database load? Web Server (Static Content)‏ Rails App (Mongrel)‏ Database (MySQL / PostgreSQL)‏ Cluster
  6. 6. Very dynamic application? Web Server (Static Content)‏ Rails App (Mongrel)‏ Database (MySQL / PostgreSQL)‏ Cluster
  7. 7. Installing the stack using Deprec <ul><ul><li>cd /path/to/railsapp </li></ul></ul><ul><ul><li>deprec --apply-to . --name projectname --domain www.projectname.com </li></ul></ul><ul><ul><li># edit config/deploy.rb to add svn details </li></ul></ul><ul><ul><li>cap install_rails_stack </li></ul></ul><ul><ul><li>cap setup </li></ul></ul><ul><ul><li>cap deploy_with_migrations </li></ul></ul><ul><ul><li>cap restart_apache </li></ul></ul>
  8. 8. Mongrel
  9. 9. Mongrel <ul><ul><li>Pure Ruby web server for Ruby applications </li></ul></ul><ul><ul><li>Supports Rails, Camping, Og + Nitro </li></ul></ul><ul><ul><li>Need a cluster due to Rails threadsafety issue </li></ul></ul><ul><ul><li>Significant footprint increase with Rails 1.2 </li></ul></ul><ul><ul><ul><li>Approximately 60MB / Mongrel / Mephisto instance </li></ul></ul></ul><ul><ul><li>Dash B logging for detecting memory leaks </li></ul></ul>
  10. 11. Nginx <ul><ul><li>Web server from Igor Sysoev: best used as a reverse proxy </li></ul></ul><ul><ul><li>Rapidly becoming preferred choice of Rails community </li></ul></ul><ul><ul><li>10MB footprint with 10,000 concurrent connections </li></ul></ul><ul><ul><li>Load balancing </li></ul></ul><ul><ul><li>Weighted load balancing </li></ul></ul><ul><ul><li>Relatively straightforward configuration </li></ul></ul>
  11. 12. Nginx vs. Apache <ul><ul><li>Apache: Relatively Larger footprint </li></ul></ul><ul><ul><li>Thread per request </li></ul></ul><ul><ul><li>Nginx: Low footprint </li></ul></ul><ul><ul><li>Non blocking IO </li></ul></ul>
  12. 13. Issues with Lighttpd <ul><ul><li>Stability </li></ul></ul><ul><ul><li>Memory leaks </li></ul></ul><ul><ul><li>Non-trivial URL rewriting </li></ul></ul>
  13. 14. Nginx: configuring mongrel <ul><ul><li>upstream mongrel { </li></ul></ul><ul><ul><li>server 127.0.0.1:10000; </li></ul></ul><ul><ul><li>server 127.0.0.1:10001; </li></ul></ul><ul><ul><li>} </li></ul></ul><ul><ul><li>proxy_pass http://mongrel; </li></ul></ul>
  14. 15. Nginx: load balancing <ul><ul><li>upstream backend { </li></ul></ul><ul><ul><li>server backend1.example.com weight=5; </li></ul></ul><ul><ul><li>server backend2.example.com:8080; </li></ul></ul><ul><ul><li>server unix:/tmp/backend3; </li></ul></ul><ul><ul><li>} </li></ul></ul>
  15. 16. Nginx: Caveats <ul><ul><li>Primary documentation in Russian </li></ul></ul><ul><ul><ul><li>(Documentation is rapidly improving, though)‏ </li></ul></ul></ul><ul><ul><li>No X-sendfile support (useful for serving large files)‏ </li></ul></ul><ul><ul><li>Virtual host support poor </li></ul></ul>
  16. 17. Rails Hosting <ul><ul><li>Rails 1.2+ unsuitable for shared hosting </li></ul></ul><ul><ul><li>Most shared hosts have published / unpublished memory caps </li></ul></ul><ul><ul><ul><li>Textdrive: 47 MB per process </li></ul></ul></ul><ul><ul><li>Dedicated hosting expensive </li></ul></ul><ul><ul><ul><li>Starts at ~ $70 per month (e.g. ServerPronto)‏ </li></ul></ul></ul>
  17. 18. Virtual Private Server (VPS) Hosting <ul><ul><li>Fits in between Shared and Dedicated hosting </li></ul></ul><ul><ul><li>Nice performance / price ratio (starts @ $20 / month)‏ </li></ul></ul><ul><ul><li>Can potentially exploit superior hardware </li></ul></ul><ul><ul><li>Alternatives: </li></ul></ul><ul><ul><ul><li>Xen </li></ul></ul></ul><ul><ul><ul><li>Virtuzzo </li></ul></ul></ul><ul><ul><li>Baked in kernel level virtualization support is coming </li></ul></ul><ul><ul><li>Caveat: Need to manage your own setup </li></ul></ul>
  18. 19. Advantages of VPS hosting <ul><ul><li>Entire CPU available when other users are idle. </li></ul></ul><ul><ul><li>Disk I/O usually faster than dedicated box (due to RAID etc.)‏ </li></ul></ul><ul><ul><li>Can take advantage of SANs if required. </li></ul></ul><ul><ul><li>Hosting company takes care of the VPS server </li></ul></ul><ul><ul><li>Fairly easy to scale VPS setup (just add more VMs)‏ </li></ul></ul>
  19. 20. Monitoring Rails applications <ul><ul><li>Monit (http://www.tideslash.com/monit)‏ </li></ul></ul><ul><ul><li>Process monitoring tool </li></ul></ul><ul><ul><li>Can monitor: </li></ul></ul><ul><ul><ul><li>HTTP server </li></ul></ul></ul><ul><ul><ul><li>Processes </li></ul></ul></ul><ul><ul><ul><li>Databases (MySQL and PostgreSQL)‏ </li></ul></ul></ul>
  20. 21. Cron Jobs <ul><ul><li>Clear stale sessions </li></ul></ul><ul><ul><li>Database maintenance </li></ul></ul><ul><ul><li>Clear logs </li></ul></ul><ul><ul><li>Best practice: get Cron to call out to a script </li></ul></ul><ul><ul><li>Don't hardcode commands in the crontab </li></ul></ul><ul><ul><li>Makes it easy to test </li></ul></ul>
  21. 22. Putting it all together <ul><ul><li>Can use Monit to create 'self healing' setup </li></ul></ul><ul><ul><li>PostgresQL </li></ul></ul><ul><ul><li>Nginx </li></ul></ul><ul><ul><li>Mongrel </li></ul></ul><ul><ul><li>Cron </li></ul></ul>
  22. 23. <ul><ul><li>http://nginx.net/ </li></ul></ul><ul><ul><li>http://railsexpress.de/blog (performance tuning)‏ </li></ul></ul><ul><ul><li>http://hostingfu.com (blog on hosting)‏ </li></ul></ul><ul><ul><li>http://www.slideshare.net/Georgio_1999/how-to-scale-your-web-app/ (scaling Rails)‏ </li></ul></ul>Additional Information
  23. 24. Thank You http://blog.vivekprahlad.com/

×