Arun
Arun

Reputation: 885

In ruby, if muliple HTTP request comes for single action/method then how ruby handles each and every request?

In ruby, if muliple HTTP request comes for single action/method then how ruby handles each and every request?

I don't know exactly, I heard that java uses multi thread concept. Is ruby uses the same or anything else? If it uses to create process for every request then this thing eat the cpu process.

Upvotes: 1

Views: 436

Answers (5)

user362541
user362541

Reputation: 121

Ruby itself is a single threaded programming language so it cannot take multiple request at the same time. But you can open multiple processes on your server to handle multiple request. When you want to know how it performs we need to calculate the throughput of the server. When you have very large number of request thats where people goes for cloud computing techniques like amazon.

Upvotes: 0

Reactormonk
Reactormonk

Reputation: 21700

I recommend reading http://yehudakatz.com/2010/08/14/threads-in-ruby-enough-already/, it explains most of it.

Upvotes: 0

klew
klew

Reputation: 14967

In Rails process takes care of only one request. If you have only one Rails process than all other requests would have to wait until first one is finished and so on.

Some time ago people were using Mongrel Cluster to have many Rails processes so each can handle one request at a time. Now I think that the most popular is Passenger - it can start dynamicaly more Rails processes is there is a need.

Upvotes: 0

shingara
shingara

Reputation: 46914

There are only one process to answer to this request. It's why you have a proxy system in front like 1 Nginx and 2 thin process behind. One request is handle by thin and return this result.

After there are system like EventMachine to improve CPU using. By example if you process wait some IO, EventMachine handle an other ruby thread during with waiting.

Upvotes: 0

tvanfosson
tvanfosson

Reputation: 532495

This is really a function of the web server you use, not the language. I would expect that it would use some combination of processes and/or threads within processes to handle each request. Look at your particular web server's documentation for more details.

Upvotes: 1

Related Questions