If you are interested in learning more about how your organization can transition from Rails to Phoenix please contact the Elixir/Phoenix experts at DockYard!
? Eight year old Rails application (~50 models, ~40 controllers) Rewrite in Elixir/Phoenix began in 2014 Before: 150 AWS Instances Log-jammed responses Multiple engineers per app Multiple complex caching strategies
? Eight year old Rails application (~50 models, ~40 controllers) Rewrite in Elixir/Phoenix began in 2014 Results: 1/15th of the servers previously required 10ms - 30ms avg response times Largest average spike 400ms Largest outlier spike 800ms About one engineer per app No caching
? Ruby/Rails • Ruby 2.3 / Rails 4.2.5.1 with ActiveRecord • Fronted by a Redis cache that combines Perforated and Readthis • Content serialized with ActiveModelSerializers, unused with a warm cache • Tuned to fetch as little data as possible from the database • All associations are preloaded • All content is cached as strings, no marshalling or serialization is performed • All data is generic, not customized to the current user • The request is paginated to 100 primary records, without a limit on side loads • The payload is a hefty 160k, un-gzipped http://sorentwo.com/2016/02/02/caching-what-is-it-good-for.html
? Elixir/Phoenix • Elixir 1.2.1 / Phoenix 1.1 • No entity cache • All fields are fetched from the database, SELECT * • All JSON responses are serialized on the fly, directly in views • Includes customized data based on the current user • The request isn’t paginated at all, there are 250 primary records • The payload is a massive 724k, un-gzipped http://sorentwo.com/2016/02/02/caching-what-is-it-good-for.html
? “These response times are not characteristic of either system, they are at the extreme upper limit. Even so, serving up 2.5x the records with 4.5x the data, without any caching, the Phoenix API response times are 1.5x-2.5x faster.” — Parker Selbert http://sorentwo.com/2016/02/02/caching-what-is-it-good-for.html Rails Phoenix response time (ms)
? Eight year old Rails application (~50 models, ~40 controllers) Rewrite in Elixir/Phoenix began in 2014 Results: 1/15th of the servers previously required 10ms - 30ms avg response times Largest average spike 400ms Largest outlier spike 800ms About one engineer per app No caching
end Rails Router Phoenix Router defmodule HuhApp.Router do use HuhApp.Web, :router resources "/profiles", HuhApp.ProfileController, only: [:show] get "/profiles/:id/reviews", HuhApp.ProfileController, :reviews end
Profile.find(params[:id]) end end Phoenix Controller defmodule HuhApp.ProfileController do def show(conn, %{"id" => id}) do profile = Repo.get(Profile, id) render conn, "show.html", profile: profile end end
do |t| t.string :name t.timestamps end end end Phoenix (Ecto) Migration defmodule HuhApp.Repo.Migrations.CreateProfile do use Ecto.Migration def change do create table(:profiles) do add :name, :string timestamps end end end
? Order of magnitude performance Avoid having to wrap all code in caches Implementing features costs less money and requires less engineering support Optimizes for long-term developer happiness Takes about a week to re-train Rails developers Its going to change the world