Scale up a Rails Application

To scale your Rails Application do the following:

  1. Develop your application just like you know it
  2. Enhance your controllers with calls to the Scales API
  3. Write a scale up file that initially fills the cache

In detail this looks like this: After you developed your app, it needs to make sure that each resource that is usually returned right to the requestor, is also stored in the cache. It can do this with the help of the Scales API that is pretty straight forward.

Normal Rails Controller

Scaled Rails Controller

Finally, you need to make sure that the scales framework initially knows what to put in the cache. This is done using a scaleup file that simply calls all urls that exist, exactly once:


That's all there is to do!

Run Scales using the Rails Application

Scales consists of three modules: The Server, the Cache and the Worker. You just set up the Rails application the worker uses, now you need to do the following:

Start a Cache

Scales is using redis, so make sure to have on running.

Start a Server

After the installation of the gem you have a scales-server executable. Just start it with:

scales-server -p 80

Start a Worker

Every request that needs to hit the application because it's not a pure reading request is redirected to a worker. To start your worker with the previously prepared rails app do the following:

cd railsproject
scalify .

This starts a worker using the rails application

Initially fill the Cache

Finally you're ready to use a full Scales system for the first time. The last step you have to do now is to initially fill the cache with the help of the scaleup file:

cd railsproject
scale up
Fork me on GitHub
Scales is made by Thomas Fankhauser for