Pergunta

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

Foi útil?

Solução

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top