Skip to content
No description or website provided.
Ruby JavaScript
Find file
New pull request
Latest commit 9add02d @jjb note about heroku
Failed to load latest commit information.
app have the controller do stuff.
config thin and threads!
db first commit
doc first commit
lib first commit
log first commit
public first commit
script first commit
test first commit
vendor first commit
Gemfile thin and threads!
Gemfile.lock thin and threads!
Procfile procfile
Rakefile first commit first commit note about heroku

A tiny example of a rails app serving requests asynchronously.

relevant things to look at

  • mycontroller_controller.rb
  • application.rb (config.threadsafe!)
  • Procfile

how to run the server

synchronously: bundle exec thin start

asynchronously: bundle exec thin start --threaded

how to observe synchronous vs. asynchronous behavior

compare behavior when refreshing and When running without threads, fast will always have to wait for slow. When running with threads, you can refresh fast with wild abandon while waiting for a request to slow to finish.

how to benchmark

ab -n 1000 -c 10

Threaded mode is successfully asynchronous, but serves fewer requests per second.

does it work asynchronously on heroku?


open questions

  1. Is anyone in the world doing this in production?
  2. How does thin decide how many threads to create?
  3. What is the space complexity of each thread?
  4. Why is threaded slower? (MRI 1.9.2 and 1.9.3)

discussion elsewhere

Something went wrong with that request. Please try again.