Wynn Netherland changelog.com/posts

That app is Phat

We all know the Rails Can’t Scale line to be bunk, but that doesn’t mean we stop looking for ways to speed up Rails apps.

Mike Perham says his apps are Phat, and yours can be, too. Phat is a Rails app pattern that employs a single Thread, multiple Fiber model in Ruby 1.9 to async-ify an otherwise vanilla Rails app behind Thin.

Phat uses rack-fiber_pool, Mike’s Rack Middleware to execute each request in a Fiber. Phat also configures Fiber-enabled async libraries including em_postgresql, memcache-client, and em-resolv-replace to achieve some impressive scalability:

# Asynchronous DNS lookup
require 'em-resolv-replace'
require 'rack/fiber_pool'
# Pull in the evented memcache-client.
# You'll need to configure config.cache_store as normal.
require 'memcache/event_machine'

Rails::Initializer.run do |config|
  config.cache_store = :mem_cache_store
  # Run each request in a Fiber
  config.middleware.use Rack::FiberPool
  # Get rid of Rack::Lock so we don't kill our concurrency
  config.threadsafe!
end

[Source on GitHub] [Mike’s Blog Post]


Discussion

Sign in or Join to comment or subscribe

Player art
  0:00 / 0:00