Prev | Current Page 473 | Next

Brad Ediger

"Advanced Rails"

At the
moment, nginx seems to be the best front end for Rails applications.
* http://blog.codahale.com/2006/11/07/pound-vs-pen-because-you-need-a-load-balancing-proxy/
Rails Deployment | 319
Asset hosts for static files
There is yet another way to serve static files. Rather than intercepting requests for
static files at the proxy, you can define an asset host, or another server from which
static files will be served. The Rails image_path and similar helper methods will then
use that host to reference files in the public directory. Configuration is simple:
config.action_controller.asset_host = "http://assets.example.com"
But this can be inefficient: browsers limit the number of concurrent connections to
one host, so the download speed can actually be limited by the connection rate,
which is often governed by the user??™s upload speed.* This can be solved by increasing
the number of DNS names from which assets are served, as the restrictions operate
based on names, not IP addresses. In Rails 2.0, the configuration looks like this:
config.action_controller.asset_host = "http://assets-%d.example.com"
This will distribute asset requests across assets-0.example.com, assets-1.example.com,
assets-2.example.com, and assets-3.example.com. Just point all of those DNS names
at your asset server, and you gain the benefit of increased concurrency without
changing any client settings.


Pages:
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485