Tag Archives: server monitoring

Why use Phusion Passenger for your Rails server

Phusion Passenger is one of three big players in the rails server game. The other two players are Unicorn and Puma. No matter which one you choose if you can configure it correctly and get through the setup process all of them work. All three of them are considered viable and able to handle the job. In my opinion though I feel that Passenger is the best out of the three.

Support

The first reason why I really like Passenger is because they have really great documentation. If you are unable to resolve your issue after reading through their documentation you didn’t look close enough. For example this is Passengers documentation for their nginx module. Yeah it has a ton of configuration options that you can just stick into your nginx configuration file and go. Also if you are wondering why something is not working you will be able to find the answer easily either by going through the documentation yourself or going to Google. If you Google for an issue using Unicorn you will probably end up finding it but it could take you a while. When I consider choosing a technology to use support is the first place I look at like am I able to get support and is the tool so easy to use that I most likely won’t need that support. If the answer is yes to both of them to me that is a good place to start. If the answer is yes to documentation but not to suppose I think that is an okay starting point. Sometimes you will not be able to find both.

Popularity

This one is a little controversial as the saying goes just because it’s popular doesn’t mean it’s great. That saying does hold true in some cases but when it comes to technology it usually doesn’t mean that it usually means a good sign. I have noticed that people in technology usually don’t stick with something too long if it’s not satisfying their needs. Passenger has great support including the rails core team. It also has support from some major companies including Basecamp, The New York Times, AirBnb, and Apple to name a few of them. If you would like to see a bigger list check out builtwith. Now the argument could be made that all of these companies have no clue what they are doing using Passenger but they all have very high levels of traffic and are well known as reputable companies. There is a reason why and passenger is a tool that helps them get there.

 Ease of Use

To be totally honest I only have experience in running Passenger and Unicorn. I have never had the experience setting up Puma so I will only be comparing Unicorn and passenger here. Although I have looked at Puma’s documentation and it doesn’t look so bad. Unicorn seems to be pretty easy to install on a single instance rails server. You can get your rails application up and running in a short amount of time. There are a lot of Unicorn scripts out there to get you started and up and running. The problem with Unicorn is when you have to do anything outside of running one application on the server. Dealing with multiple environments on one machine is possible (I think) but it seems like it wasn’t made for that. It also feels like Unicorn isn’t fully polished yet. Small things kept coming up like shutting down a Unicorn process without using the kill command. Like that example it just feels like commands that are suppose to work don’t. Now to be honest I am no server administrator so the problem may be obvious to someone else. So if you are a experience Unicorn professional these arguments could easily be debunked. The problem is most rails developers are not and therefore that argument really doesn’t matter. A lot of companies are rolling with developers being the server administrators also so the easier the tool is the better.

Install passenger is also a very simple process. The reason why it’s so simple is it ships with an installer that installs both passenger and nginx. You also install passenger and apache if that is your goal. In my case it was nginx. How cool is it that you get both nginx and passenger with one install. If you already installed nginx it’s recommended that you remove it and then run the passenger install. Also once it’s installed and started passenger handles everything else. This holds true even when you have multiple environments running on the same server. You don’t have to do any extra configuration to set this up either. You basically create another nginx file point it to the directory and go. Of course if you are adding another application on you will have to restart nginx but not passenger. Also passenger comes with a couple of pretty cool tools to monitor memory and performance. You simply type in the following command to get the memory usage.


rvmsudo passenger-memory-stats

Yes it’s that easy to monitor your rails processes. Unicorn you have to manually so a ps -ef | grep ‘unicorn’ to see the process. I suppose there are some tools like this for Unicorn but they don’t see as obvious to use. This tool is built into passenger so you can run it from anywhere you have an application running.

At the end of the day you have to use a tool that works best for your situation. Is passenger that tool probably but if you are an experience server administrator tools like Unicorn may be better. We all have our reason for choosing our toolset but you should have justification for those reason. At the end do whatever makes your life easier. In my case Passenger made my life easier as a non server administrator.

Here are some resources I used to determine the content in this post

  • https://github.com/phusion/passenger/wiki/Unicorn-vs-Phusion-Passenger
  • https://www.engineyard.com/articles/rails-server
  • https://www.digitalocean.com/community/articles/a-comparison-of-rack-web-servers-for-ruby-web-applications

New Relic free edition

I have used both the paid version and free version of new relic. My experience with the paid version was limited though. I used it on the job for a couple of months. I also used the 14 day trail they give you with my own projects. Even though the paid version gives you more features if you are a small business or website you don’t really need the paid version. The free version actually gives you enough information to be very useful. After talking with new relic support one thing they told me they want the free version to be useful. So they try to pack as much as possible into the free version but still be able to make money on the paid version for larger applications or businesses. The setup process could not be any easier.

Basically to set it up you just have to follow their documentation. Which in my opinion really well done it’s step by step. For example if you add it to a PHPapplication you just need to follow these instructions. It should take less than 10 minutes to setup. After you have it setup everything starts working right away. You start getting real time data within a minute. Also if you have it already installed on your server the setup process for other domains or subdomains is even easier. It would take less than a couple of minutes. It basically involves editing your .htaccess file. That is for PHP of course I believe the setup with a rails environment is about the same except you are adding it to you Gemfile. I have also had the experience of setting it up with an Android application. Again the setup process is very easy. They have instructions for different environments like Eclipse. The total time for the setup again is less than 10 minutes. So you are not having to put a lot of time getting it up and running. Not only is the setup easy but you also get a lot of really good features for free.

The best feature in my opinion is getting to see the transactions timed. For example you can see the load times for each request. It even breaks it down by the script name. This will allow you to target specific actions in your controller to refactor. It will also keep an Apdex score. This can be useful to see how well your site is responding to requests. You can do your research on what the scale is. Another feature for your website monitoring is it will send you an email alert if your site or application is down. You get these alerts right away when it goes down and then when it’s back up. You will also get a report with the downtime and how long it was. There are other tools that will do this but I have not had as good of a experience with them. On the Android or mobile side you get to see interactions with your application. So when the user hits a specific activity you will see how long the application is taking to respond. This is very important as each device the response time will be different. Some phones have better processors and respond faster. It’s important to know that some users may not be having a good experience. That is something that Google doesn’t provide either. Other information it tracks is OS versions and devices. Less important statistics as Google also tracks those.  The last free feature that I find useful is server information. It will give you your memory usage, CPU usage, processes running and space left on your disc. The best part of all these features as they call come with the free edition! The only downside is that this information is only retained on their site for 24 hours. After that is is gone. But again for free you can utilize their API and can download all that information locally if you want. The possible for free are endless. Although I do not have experience with their API it looks like a standard restful API.

I think new relic is worth checking out at the very least. I believe that it’s the tool of the future for server and application monitoring. I suppose it’s been around long enough to be called the tool of the present to. I have had no issues since I started using their service. Their customer service has been great and responded fast to questions too. Also you get to start with a free 14 day trial they don’t even ask for your credit card at least at the time I signed up they didn’t. Plus you get a free t-shirt just for signing up. I think the free version is enough to keep a small company or website satisfied. If you are a larger company I think their full version would be enough so you also have that option. You get all the features with the 14 day trial so you can see for yourself.