Ruby on Rails Enterprise Application Development::
Plan, Program, Extend
www.PACKTPUB.com  FREE ONLINE EDITION: Read full chapters online, download free samples from the book and more...
Book Contents Index > Chapter 9
Introduction
1: Introduction
2: The Initial Problem
3: Laying the Foundations
4: Working with Rails Free Chapter
5: Building the User Interface
6: Into Production
7: Improving the User Experience
8: Extending the Application
9: Advanced Deployment

10: Down the Track

Appendix A: Running Your Own Gem Server

Index

Latest Updates

Free Chapter:

Chapter 4: Working with Rails [ 1.7 MB PDF]

Code Download

Contact us

Chapter 9: Advanced Deployment

So far, we've dealt with a simple deployment situation—a single production machine running Intranet as a Mongrel instance, backed by a MySQL database. This will be able to cope with a fair amount of traffic, and it may be that in your situation, there will be no need for anything more complex.

Having said this, one issue that will definitely arise is how to roll out new versions of the application. This introduces several challenges, such as ensuring the application is compatible with new versions of Rails, upgrading the database, and so on. Capistrano, a tool for simplifying and automating deployment of applications, was designed to ease multiple deployments, and we'll be seeing how it can help us meet these challenges. We'll also cover common deployment issues and their solutions, plus other housekeeping that an application requires, such as clearing out stale sessions and managing log files.

If you have a lot of users connecting to the application concurrently, you may find that things start to slow down. In this chapter, we'll cover how to keep up your application's speed using some simple techniques, such as caching. If things are still too slow, the next option may be to add more hardware to cope with the load. We'll see how to scale a Rails application using Apache, as well as by adding more servers.

This chapter is slightly trickier to follow than previous ones, as we're now considering two machines—one for development and a second for production (called the development machine and production server respectively in this chapter). Intranet is being deployed from the former to the latter. You can still follow the tutorial on a single machine by treating it as both the development machine and production server: simply ensure that you can login to it via SSH. If you want to test the Apache deployment tips, ensure you have Apache installed (see Chapter 6 for some instructions). The section on large-scale deployments is harder to simulate with a single machine, so we'll just be covering some of the concepts to give you an idea of the issues and solutions.

Chapter 9: Advanced Deployment

  • Deployment with Capistrano
    • Getting Started with Capistrano
      • A Complete Deployment Recipe
    • Preparing the Production Database
    • First Deployment
    • Migrating the Production Database
    • Running Other Commands on the Server with invoke
    • Managing Mongrel from Capistrano
    • Centralizing File Uploads
      • Upgrading the Application
      • Cleaning Up Obsolete Releases
    • Downgrading the Application
  • Troubleshooting Deployment
    • Incompatible Rails Versions
    • Missing Libraries
    • Incorrect Subversion Password or Repository Permissions
    • User Doesn't Have SSH Access to the Server
    • Inaccessible Application Server
    • Inaccessible Database Server
    • Dealing with the Inexplicable
    • Getting Back to a Clean Slate
  • Housekeeping
    • Starting Mongrel Automatically
    • Clearing Out Stale Sessions
    • Keeping Log Files Manageable
      • Reducing Log Detail
  • Optimizing a Rails Application
    • Finding Bottlenecks
      • Controller Action Profiling Using around_filter
      • Profiling Everything
      • The Rails Profiler
    • Improving Application Performance with Caching
      • How Cache Elements are Named
      • Deciding What to Cache
      • Preparing for Caching
      • Page Caching 435 Action Caching
      • Fragment Caching
      • Fragment Caching for Actions
      • Avoiding Database Calls for Cached Fragments
      • Clearing out the Cache
    • Optimizing How Rails Uses the Database
      • Ordering for Eager Loading
    • Scaling Your Rails Infrastructure
      • Using Apache to Serve Static Assets
      • Proxying to a Mongrel Cluster
      • Advanced Scaling
  • Summary
   

 

Paperback 528 pages
Released: October 2007
ISBN: 1847190855
ISBN 13: 978-1-847190-85-7

     

 




View the book details
on PacktPub.com

 


 

  This website is owned and maintained by Packt Publishing Ltd, 2007. All rights reserved. Terms and Conditions