1

Possible Duplicate:
Is Sinatra multi threaded?

I have a web service that requires running on Ruby 1.8.7. Currently I'm using Sinatra with Thin to host the service.

I did a test to submit two requests: "A" and "B". If I submit only A, which is just a "helloworld" request, I get the result back immediately. If I send request B first, which takes more time and resources than request A, I receive results for A and B about the same time. It seems like Sinatra handles them synchronously.

Is there a way to make Sinatra multithreaded?

Community
  • 1
  • 1
HNGO
  • 335
  • 1
  • 5
  • 20
  • I use daemon to run it as windows service. The script to run run is: myclass.run! :host => 'localhost', :port => 8000, :server => 'thin' – HNGO Oct 05 '12 at 19:06
  • You might want to look at this question: http://stackoverflow.com/questions/6278817/is-sinatra-multi-threaded – matt Oct 06 '12 at 00:58

2 Answers2

1

Thin is multithreaded but you need to tell it how many servers to start: thin start --servers 3. Otherwise it won't have enough workers to serve your requests. See Usage in the docs.

Robert K
  • 30,064
  • 12
  • 61
  • 79
  • This is a nice workaround but it's not a complete solution. The `--servers n` argument starts `n` daemons listening on `n` _different_ ports. If I understood OP correctly the goal is to make a daemon listening on a _single_ port asynchronous. – Jan Oct 05 '12 at 19:08
  • Yes, that's what I meant Jan. Sinatra-synchrony does a pretty good job but I have to stay with Ruby 1.8.7 for some reasons... – HNGO Oct 05 '12 at 19:20
  • @user858931, could you update the question to make it clear? – Jan Oct 05 '12 at 19:26
1

You might want to look at async-sinatra.

Kashyap
  • 4,696
  • 24
  • 26