Question

I understand that Thin is built on top of EventMachine, which provides async IO. If I am using a rack framework like RoR or Sinatra and do some DB call (without using any special libraries), does that block the main event loop (given I am using Thin as a web server)?

Thanks

Was it helpful?

Solution

Yes it does.

Standard DB clients are made on top of Ruby's TCPSocket which will block main thread while it waiting response.

You should use patched clients which will replace TCP Connection to EM::Connection. Some of them are presented in EventMachine library itself

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top