millisami
millisami

Reputation: 10161

In a rails 3.1 app, can I compile and serve the static assets from just one server?

I'm running Rails 3.1 apps on 3 app servers (3 nodes). While deploying, the asset pipeline compiles the assets via capistrano hook on all 3 instances, the server load is too high.

On thing I can do is to precompile the assets locally and upload to the app servers.

In front of all, I'm running Nginx to distribute the requests among the clusters.

My question is Can I just compile the assets on just one server and serve it through that instance only?

This will reduce the compilation/uploading of assets on all the 3 app servers. Has anyone been deploying this way?

Upvotes: 1

Views: 289

Answers (1)

Richard Hulse
Richard Hulse

Reputation: 10493

The simplest way to solve this is compile locally, commit the files and upload without running the compile task.

Another is to compile locally, upload to whichever server you want, and set nginx to forward requests to just that server.

A third way is to upload the locally compiled assets to all three servers and let nginx load balance as before.

One thing you should do regardless is set nginx to add far-future headers for /assets and to set maximum compression. This reduces requests for those assets (due to client-side caching), and lowers the time to deliver then the first time they are requested.

Upvotes: 1

Related Questions