# Non blocking http request

**URL:** <https://www.ruby-forum.com/t/non-blocking-http-request/176119>\
**Category:** Rails\
**Created:** [September 24, 2009, 11:30pm UTC](https://www.ruby-forum.com/t/non-blocking-http-request/176119 "2009-09-24T23:30:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nextpulse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/71c47a/32.png) [@nextpulse](https://www.ruby-forum.com/u/nextpulse)\
**Post date:** [September 24, 2009, 11:30pm UTC](https://www.ruby-forum.com/t/non-blocking-http-request/176119/1 "2009-09-24T23:30:49Z")

</div>

Any one know if it is possible to do a non-blocking http request  
within Ror?

I looked at Net::HTTP, nothing obvious.

In my code, I want to fire off a http request (and not care about the  
return or wait for it) and continue with the rest of the work.  
I know I can use backgroundrb etc - but that seems an overkill.

Any help appreciated.

thanks.

---

<div class="post-metadata">

**Author:** ![nextpulse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/71c47a/32.png) [@nextpulse](https://www.ruby-forum.com/u/nextpulse)\
**Post date:** [September 25, 2009, 12:04am UTC](https://www.ruby-forum.com/t/non-blocking-http-request/176119/2 "2009-09-25T00:04:12Z")

</div>

Seriously, checkout delayed\_job. It’s super easy to implement, and is  
anything but overkill. Here’s the URL for the project:

> **[GitHub - collectiveidea/delayed\_job: Database based asynchronous priority...](https://github.com/collectiveidea/delayed_job)**
>
> Database based asynchronous priority queue system -- Extracted from Shopify - GitHub - collectiveidea/delayed\_job: Database based asynchronous priority queue system -- Extracted from Shopify

… and as an added bonus, Ryan B. covers it in a Railscast. Here’s  
the  
URL for the Railscast:

> **[\#171 Delayed Job - RailsCasts](http://railscasts.com/episodes/171-delayed-job)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.

Cheers,  
Tim

On Thu, Sep 24, 2009 at 4:27 PM, nextpulse [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Any help appreciated.
> 
> thanks.
> 
> >

–  
Tim L.  
Coroutine LLC  
516 Tennessee St., Suite 215  
Memphis, TN 38103  
office: 901.312.8818  
mobile: 901.490.5325  
[http://www.coroutine.com](http://www.coroutine.com)

---

<div class="post-metadata">

**Author:** ![nextpulse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/71c47a/32.png) [@nextpulse](https://www.ruby-forum.com/u/nextpulse)\
**Post date:** [September 25, 2009, 12:55am UTC](https://www.ruby-forum.com/t/non-blocking-http-request/176119/3 "2009-09-25T00:55:07Z")

</div>

I agree with Tim on this.

I am working on a new feature in one of my applications that entails  
calling a long running process.  
I wrote the application to do it synchronously at first to make sure  
everything was working.

Then I installed/setup delayed\_job, modified my controller to call  
@myobject.send\_later :my\_method and my call was now asynchronous.

Total time to convert from synchronous to asynchronous: \< 15 minutes.

---

<div class="post-metadata">

**Author:** ![nextpulse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/71c47a/32.png) [@nextpulse](https://www.ruby-forum.com/u/nextpulse)\
**Post date:** [September 25, 2009, 7:28pm UTC](https://www.ruby-forum.com/t/non-blocking-http-request/176119/4 "2009-09-25T19:28:01Z")

</div>

Thanks for the info.  
delayed\_job is a great piece but its just an overkill for what i  
wanted.  
I wanted something simple - not just from an implementation standpoint

- but resource too (not add any extra load etc).

“Keep in mind that each worker will check the database at least every  
5 seconds.”

For those who are interested, a solution was to use ruby system  
(’…&’). I fire it off (and forget) and let the OS mange it. (If  
needed, you can also manage the queues via ruby Process)
