# \[ANN\] NeverBlock support for ActiveRecord

**URL:** <https://www.ruby-forum.com/t/ann-neverblock-support-for-activerecord/146750>\
**Category:** Ruby\
**Created:** [August 25, 2008, 3:25am UTC](https://www.ruby-forum.com/t/ann-neverblock-support-for-activerecord/146750 "2008-08-25T03:25:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![oldmoe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/e274bd/32.png) [@oldmoe](https://www.ruby-forum.com/u/oldmoe)\
**Post date:** [August 25, 2008, 3:25am UTC](https://www.ruby-forum.com/t/ann-neverblock-support-for-activerecord/146750/1 "2008-08-25T03:25:32Z")

</div>

I gladly announce the first release of the NeverBlock PostgreSQL adapter  
for ActiveRecord.

The new adapter enables ActiveRecord to perform queries in parallel even  
in a single threaded Ruby1.9 application.

Benchmarking is showing very good results so far.

Read about it here:

> **[ActiveRecord meets NeverBlock](http://oldmoe.blogspot.com/2008/08/activerecord-meets-neverblock.html)**
>
> I happily announce the release of the first NeverBlock enabled activerecord adapter. The neverblock-postgresql-adapter . This is a beta rel...

The official announcement with sample code and installation link:

[http://www.espace.com.eg/neverblock/blog/2008/08/24/neverblock-and-activerecord-concurrent-db-access-without-threads/](http://www.espace.com.eg/neverblock/blog/2008/08/24/neverblock-and-activerecord-concurrent-db-access-without-threads/)

For more info regarding NeverBlock itself:

[http://www.espace.com.eg/neverblock](http://www.espace.com.eg/neverblock)

regards

oldmoe  
www.espace.com.eg  
[oldmoe.blogspot.com](http://oldmoe.blogspot.com)

---

<div class="post-metadata">

**Author:** ![oldmoe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/e274bd/32.png) [@oldmoe](https://www.ruby-forum.com/u/oldmoe)\
**Post date:** [August 25, 2008, 10:14am UTC](https://www.ruby-forum.com/t/ann-neverblock-support-for-activerecord/146750/2 "2008-08-25T10:14:07Z")

</div>

Muhammad Ali wrote:

> I gladly announce the first release of the NeverBlock PostgreSQL adapter  
> for ActiveRecord.
> 
> The new adapter enables ActiveRecord to perform queries in parallel even  
> in a single threaded Ruby1.9 application.

How does this differ from libpq’s (and, by association, the pg driver’s)  
native support for this?

-Erik

---

<div class="post-metadata">

**Author:** ![oldmoe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/e274bd/32.png) [@oldmoe](https://www.ruby-forum.com/u/oldmoe)\
**Post date:** [August 25, 2008, 11:46am UTC](https://www.ruby-forum.com/t/ann-neverblock-support-for-activerecord/146750/3 "2008-08-25T11:46:01Z")

</div>

Erik H. wrote:

> How does this differ from libpq’s (and, by association, the pg driver’s)  
> native support for this?

It builds on top of pg’s async interfaces. But allows you to use them in  
a semi transparent manner. Your code will look like usual (i.e. no  
callbacks for processing results), thanks to Ruby1.9 Fibers.

The async facilities currently found in pg require that you send the  
query, poll on the socket and may be run a call back after the data  
arrives

With NeverBlock you are able to write:

@user = User.find(:first)  
@user\_favorite\_hobbies = @user.hobbies.find(:conditions=\>[“favorite =  
true”])

NeverBlock will be doing the fiber pause/resume for you in the  
background.

regards

oldmoe  
www.espace.com.eg  
[oldmoe.blogspot.com](http://oldmoe.blogspot.com)

---

<div class="post-metadata">

**Author:** ![oldmoe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/e274bd/32.png) [@oldmoe](https://www.ruby-forum.com/u/oldmoe)\
**Post date:** [August 25, 2008, 3:19pm UTC](https://www.ruby-forum.com/t/ann-neverblock-support-for-activerecord/146750/4 "2008-08-25T15:19:38Z")

</div>

Muhammad Ali wrote:

> Erik H. wrote:
> 
> > How does this differ from libpq’s (and, by association, the pg driver’s)  
> > native support for this?
> 
> It builds on top of pg’s async interfaces. But allows you to use them in  
> a semi transparent manner. Your code will look like usual (i.e. no  
> callbacks for processing results), thanks to Ruby1.9 Fibers.

Wow, very cool!

-Erik

---

<div class="post-metadata">

**Author:** ![oldmoe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/e274bd/32.png) [@oldmoe](https://www.ruby-forum.com/u/oldmoe)\
**Post date:** [August 25, 2008, 4:28pm UTC](https://www.ruby-forum.com/t/ann-neverblock-support-for-activerecord/146750/5 "2008-08-25T16:28:25Z")

</div>

> How does this differ from libpq’s (and, by association, the pg driver’s)  
> native support for this?
> 
> -Erik

As far as I can tell, it uses libpq’s drivers but in a ‘reactor’ way to  
remain single threaded while handling multiple requests. It blocks the  
request’s fiber while that request is waiting for the database, and  
resumes it when the query returns. So it’s basically libpg +  
concurrency without threads. This has potential to be more scalable  
than using threads, at least I hope so.

-=R
