JT Hopple LLC

Mysql/Ruby Thread Blocking

JeremyProgramming, Ruby, Tips Digg!

It appears that the Mysql/Ruby library blocks all threads for the current process when executing a query. If you are running a multi-process web application this is not an issue, but for a multi-threaded application that has long-running queries this can be problematic.

I have a simple reporting service written with the Merb framework. In Merb, which is thread-safe, you can handle multiple requests concurrently by setting use_mutex to false in the config/merb.yml file. This works great until you have a long running mysql query and it forcefully blocks ALL threads in the process. During this query your Merb app (that you thought was multi-threaded) is blocking all other threads thanks to the mysql library.

0 Comments

Post a comment