# RoR and Threads

**URL:** <https://www.ruby-forum.com/t/ror-and-threads/57066>\
**Category:** Rails\
**Created:** [April 6, 2006, 10:14pm UTC](https://www.ruby-forum.com/t/ror-and-threads/57066 "2006-04-06T22:14:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pete\_Palmer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ebca7d/32.png) [@Pete\_Palmer](https://www.ruby-forum.com/u/Pete_Palmer)\
**Post date:** [April 6, 2006, 10:14pm UTC](https://www.ruby-forum.com/t/ror-and-threads/57066/1 "2006-04-06T22:14:21Z")

</div>

Hi,

Anyone who has seen my posts so far will know straight away that I’m new  
to Ruby. The kind help and advice I’ve received here has been invaluable  
to me and is greatly appreciated! I wish all programming communities  
were this friendly! 🙂

Anyway, on to the question…

I started off on PHP which didn’t require any real multi-threading  
techniques - at least for me - and was more to do with making sure two  
people didn’t update the same bit of the database…

I moved to Java which was a whole different ball game - threads and  
related issues abounded…

But now that I’m working with RoR - I’m wondering how exactly threading  
works in this environment. I want to use a couple of Mongrels as the  
backend - and I’m writing the software as per the “Aguile” book.

Basically, am I likely to get tripped up by any thread related issues?  
One of the applications I’m porting does a lot of HTTP requests - and  
the threading on that (this was in Java) was pretty fiddly - and I want  
to make sure I’m doing it right in Ruby if I am going to port a live  
application to it 🙂

Any help or advice would be greatly appreciated as always!

Cheers,

Pete

---

<div class="post-metadata">

**Author:** ![Pete\_Palmer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ebca7d/32.png) [@Pete\_Palmer](https://www.ruby-forum.com/u/Pete_Palmer)\
**Post date:** [April 6, 2006, 10:54pm UTC](https://www.ruby-forum.com/t/ror-and-threads/57066/2 "2006-04-06T22:54:02Z")

</div>

Pete Palmer wrote:

> 

From one fellow Java developer to another, with RoR you don’t worry  
about threads–much the same way as with PHP. You let the environment  
handle those details.

Ruby does have “psuedo threading” similar to Java’s “green threads” from  
the past, but Ruby or Java I would have to wonder if there is something  
that can be done differently to avoid the threading issue all together.  
Without much info on your project, this is about as much guidance as I  
can give you.

---

<div class="post-metadata">

**Author:** ![Pete\_Palmer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ebca7d/32.png) [@Pete\_Palmer](https://www.ruby-forum.com/u/Pete_Palmer)\
**Post date:** [April 6, 2006, 11:13pm UTC](https://www.ruby-forum.com/t/ror-and-threads/57066/3 "2006-04-06T23:13:53Z")

</div>

Hi,

Well users can use a page on my server to request and display a page on  
another server. On Java I used the apache httpclient library to do it.  
In theory hundreds of people could be requesting hundreds of different  
pages at the same time.

I just wanted to be sure that if I use the http library in Ruby and  
“pretended” that threading didn’t exist, my application wouldn’t end up  
in a big heap in the corner 🙂

---

<div class="post-metadata">

**Author:** ![Pete\_Palmer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ebca7d/32.png) [@Pete\_Palmer](https://www.ruby-forum.com/u/Pete_Palmer)\
**Post date:** [April 7, 2006, 6:03am UTC](https://www.ruby-forum.com/t/ror-and-threads/57066/4 "2006-04-07T06:03:10Z")

</div>

Ruby has threads but rails is single-threaded. Rather than using a  
thread to handle each  
request, you run multiple instances of your app behind a fastcgi pipe to  
a web server.  
This also means that their is no “application context” as in Java.

b
