What is it all about?

NeverBlock is a Ruby library 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.

How is that achieved?

Neverblock builds on two main concepts, Ruby1.9 Fibers (or Coroutines, read about them here) and evented, non-blocking IO. It builds on top of those to provide developers with IO access libraries that can totally hide the complexities of the evented model and add concurrency support to your applications.

You can check the benchmarks to get a taste of what NeverBlock can do.