Deployment is one of the most important technical steps in building a Ruby on Rails application. When communicating with developers, there are several steps and options you should be aware of. This short guide will help you to understand the workflow of the deployment process and help you to understand its main components.
Application deployment can be compared to installing software on a computer. The only difference is that we are installing an application. The application is redeployed to reflect changes in the code (fixing bugs, adding new features). Typically a project has at least three deployment environments:
This is a working environment used by engineers to see how their code performs right after it was written. In most cases, developers have their own development environment on their computers.
When engineers think their code is ready for testing, it’s deployed in a staging environment. This environment is used to test changes by testers and show progress to clients. In most cases, the staging environment is hosted at a small VPS (virtual private server). There are situations when a staging server is used to test integration with third-party services, as it is hard to do it in a development environment.
This environment hosts live apps that serve real users. It can contain several application and database servers. Before deployment to this environment, applications should be well tested in staging environments. Before deploying applications to the production environment, it is also important to configure database backups.
Where to deploy?
There are few options here – basically two.
1. Deploy to an unmanaged VPS (virtual private server) or dedicated server. In this case, developers should configure the server and prepare it for deployment. There are a number of good hosting providers, such as DigitalOcean, Linode, Amazon AWS…
2. Deploy to a PaaS (Platform as a Service) – Heroku, EngineYard, ShellyCloud, and others. The prices for resources are higher here, but you deploy your app to professionally prepared servers with monitoring and technical support. The deployment process is much easier than deploying to an unmanaged VPS.
What is a deployment stack?
When you choose to deploy to a PaaS, you should not care about this question, as the deployment stack is already configured for you. If you are deploying your application to unmanaged VPS, there are two main options:
- Phusion Passenger – This is easy to configure and to manage, has free and enterprise paid versions, and can be run as an Apache or Nginx module. Passenger itself can manage a number of running processes to serve all incoming requests as fast as possible.
- Proxy setup based on Unicorn, Thin, or Puma servers – This kind of deployment stack works well with Apache and Nginx HTTP servers.
It is good practice to configure Capistrano deployment unless you use PaaS. Capistrano is a tool that provides commands to deploy apps directly from the developer’s machine.
Speeding your Rails app up
When you see that an app became slower or you expect high traffic, then consider expanding your server power or add a third-party accelerating service. A platform as a service can automatically provide more resources when high traffic is coming to your site. In case of custom deployment, technical support should run more servers or upgrade existing ones.
An example of the deployment process
- Developers write code in development environments in different branches and merge them all into the staging branch.
- The staging branch is deployed on a free Heroku account. This allows the developers to show progress to the client and test the project.
- The production app is deployed with Capistrano to DigitalOcean VPS.
- The deployment stack is Nginx + Unicorn.
Have other questions? Post comments to this article, and we will reply as soon as we can. Or, alternatively, email us at firstname.lastname@example.org