John Bachir
John Bachir

Reputation: 22751

How is my single-threaded Rails app handling concurrent requests?

I have a single-threaded Rails app running on thin in single-threaded mode on Heroku Cedar.

While I do a huge POST request (a file upload) that takes more than a minute, I can do other GET requests at the same time.

Heroku support assures me that their routing layer is not storing the request and then sending it all at once (which is the behavior of many proxies, such as nginx). They insist that my app is handling concurrent requests.

What's going on here?

Upvotes: 5

Views: 2161

Answers (1)

Sergio Tulentsev
Sergio Tulentsev

Reputation: 230521

Thin is built on top of EventMachine, which provides event-based IO.

This means that Thin does async receiving of your POST request, while serving GET requests in the meanwhile. When POST data is uploaded, Thin then goes on to pass it to Rails (where it is processed synchronously and blocks other requests until finished).

Upvotes: 6

Related Questions