Applications hosted by Phusion Passenger now benefit from lower latencies and lower resource usage during deployments and restarts.

Over the last couple of releases, Phusion has worked with one of our wonderful customers to improve the way that Passenger routes incoming requests to your application. These changes come in two parts: in Passenger 6.0.23 the Rolling-Restart feature was updated; and in Passenger 6.0.24 the algorithm Passenger uses to route requests to app processes was updated.

Rolling-Restart Process-Replacement Order

In Passenger 6.0.23 the Rolling-Restart feature of Passenger Enterprise was modified to replace app processes in newest-to-oldest order, to better take advantage of warmer app processes during the Rolling-Restart's duration.

Previous to this change, app processes were chosen in oldest-to-newest order for replacement. This resulted in the most-used processes being replaced first, and newer less-used processes receiving more traffic as they became the oldest-remaining process, which in many cases resulted in reduced performance as the newer processes had to "warm-up" before they could process requests at peak efficiency, by which point they were likely to then be selected for replacement and the cycle would continue until all processes had been replaced.

This resulted in a lot of unnecessary work, where processes would be warmed up just to be killed shortly thereafter. Compare to the new approach: processes are chosen in newest-to-oldest order and therefore the most-warmed processes are replaced last, and little extra process-warming happens to processes that are just going to be replaced.

New Routing Algorithm

In Passenger 6.0.24 the order in which Passenger routes requests to app processes was completely overhauled. Previously, a process was chosen by least-busy, and then oldest-to-newest order; whereas, now processes are chosen in a much more considered fashion.

The first change was to introduce the concept of app generations. When Passenger is asked to restart an app-group, it increments a counter for that group. Then, when processes are spawned for that group, they are labeled with the value of the group's counter. In that way Passenger can keep track of which generation of the codebase they were spawned from, and use that knowledge to inform its routing.

While the actual implementation works in a more efficient manner, it can be helpful to imagine the new routing algorithm as a series of filters:

  • First, all completely-busy processes are rejected.
  • Then, only those remaining processes with the highest app generation are selected.
  • Then, only those remaining processes with the earliest start time (the oldest ones) are selected.
  • Then, of those remaining processes, the process with the lowest busyness is selected.

Compare that with the previous model:

  • First, all completely-busy processes are rejected.
  • Then, only those remaining processes with the lowest busyness are selected.
  • Then, of those remaining processes, the process with the earliest start time (the oldest one) was selected.

You will notice that not only was the concept of app generations added, but the priority of busyness and process age were swapped. In our designing of this feature we realized that using the warmer process when given a choice resulted in better performance than choosing the less-busy process; as long as the process had additional capacity available. Furthermore, by considering the app generation when routing requests, we can improve the ratio of requests served by a new app-codebase vs the old app-codebase, and speed up the transition. This is especially important when rolling out a bugfix update to your app.

Passenger Enterprise

These new features wouldn't have been possible without the support and collaboration of our Passenger Enterprise customers. Phusion Passenger is now even stronger in high traffic, fast paced environments and all of our users and customers benefit from that.

If you're interested in becoming a Passenger Enterprise customer as well, check out the full set of features and perks on our website.