NeverBlock: Non-Blocking Database Adapters
NeverBlock is a library, using Ruby 1.9 fibers that allows developers to write non-blocking, concurrent code in a transparent manner. Meaning that you will keep coding in your traditional ways while you get the benefit of non-blocking IO operations.
Traditionally, a Ruby application would block whenever it requests an IO operation. This can be solved by running code in multiple threads but this comes at a cost, mainly:
1. The high overhead of threads on the execution time.
2. The complexities of the thread safety and synchronization requirement.
Another approach was to use an event based model to achieve concurrency. While these performed better they suffered from other problems, mainly:
1. The twisted model of program flow where all your code is split between callbacks.
2. The complexity of mapping an existing application to fit the above model.
NeverBlock takes a stab at the above defficencies by providng a system that has:
1. Much lower overhead on CPU and memory.
2. Much reduced synchronization complexities.
3. A Normal program flow model.
4. The Ability to adapt existing applications with little or no effort.
The first database to profit from NeverBlock was Postgres. And now, just a few days later, NeverBlock added support for MySQL as well, using the new MySQLPlus driver. MySQLPlus builds on top of the original Ruby MySQL driver but adds asynchronous query processing support and threaded access support.
There’s also another project aiming to bring asynchronous operations to Ruby’s MySQL connection called Asymy.
NeverBlock is basically the combination of Fibers, EventMachine and Postgres or MySQLPlus drivers. So the answer is yes, if you apply some small patches to it, so if you enjoy the EventMachine style of staged programming it would work with 1.8.x even.
Note that MySQLPlus already works as a thread friendlier drop in replacement for the 1.8.x MySQL drivers. It also happens to work with NeverBlock and 1.9, which is its original goal.
Related Posts
Tags: Asymy, multiple threads, mysql, NeverBlock, non-blocking, Parallel Programming, ruby
Viewed: 127 views

















