# Scalability in RoR ! Please reply ASAP

**URL:** <https://www.ruby-forum.com/t/scalability-in-ror-please-reply-asap/90000>\
**Category:** Rails\
**Created:** [March 24, 2007, 9:32pm UTC](https://www.ruby-forum.com/t/scalability-in-ror-please-reply-asap/90000 "2007-03-24T21:32:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hardik\_Shah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ecb155/32.png) [@Hardik\_Shah](https://www.ruby-forum.com/u/Hardik_Shah)\
**Post date:** [March 24, 2007, 9:32pm UTC](https://www.ruby-forum.com/t/scalability-in-ror-please-reply-asap/90000/1 "2007-03-24T21:32:54Z")

</div>

Hi all,

I am right now developing the customized web portal in RoR framework  
and using MySQL as database.

I am facing the problem in terms of no. of users it can support.I am  
hostong the application on a normal desktop configuration server which  
is 80GB HDD and 1GB RAM.Now,as soon as it reaches around 100 users,the  
CPU usage becomes 100% and the server stops responding.

Now,I am not able to figure out whether it is a problem of  
1)Not using the connection pooling mechanism correctly in RoR  
2)Not using the higher capacity server  
3)Something else

Please post your feedback on this scalability issue.It will be very  
helpful to me and my company.

Regards,  
Hardik Shah

---

<div class="post-metadata">

**Author:** ![Hardik\_Shah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ecb155/32.png) [@Hardik\_Shah](https://www.ruby-forum.com/u/Hardik_Shah)\
**Post date:** [March 24, 2007, 10:01pm UTC](https://www.ruby-forum.com/t/scalability-in-ror-please-reply-asap/90000/2 "2007-03-24T22:01:56Z")

</div>

What server OS are you running? What server are you using, as well as  
what database and the versions?

---

<div class="post-metadata">

**Author:** ![Hardik\_Shah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ecb155/32.png) [@Hardik\_Shah](https://www.ruby-forum.com/u/Hardik_Shah)\
**Post date:** [March 24, 2007, 11:43pm UTC](https://www.ruby-forum.com/t/scalability-in-ror-please-reply-asap/90000/3 "2007-03-24T23:43:06Z")

</div>

Hi Todd,

Thanks for the reply.Here are the details u asked.

Server OS :- Red Hat Enterprise Linux  
Language :- Ruby 1.8.4  
Framework :- Rails Framework 1.1.6  
Database :- MySQL 5.0.24  
Web Server :- Apache 2.0.46 with Fast CGI 2.4.0 / mod\_fast CGI  
2.4.2.1

-Hardik

---

<div class="post-metadata">

**Author:** ![Hardik\_Shah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ecb155/32.png) [@Hardik\_Shah](https://www.ruby-forum.com/u/Hardik_Shah)\
**Post date:** [March 28, 2007, 5:21pm UTC](https://www.ruby-forum.com/t/scalability-in-ror-please-reply-asap/90000/4 "2007-03-28T17:21:19Z")

</div>

Thanks Tood,

I am forwarding ur details to my development team.I will update you  
with the results they get by following the process mentioned by you.

-Hardik

---

<div class="post-metadata">

**Author:** ![Hardik\_Shah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ecb155/32.png) [@Hardik\_Shah](https://www.ruby-forum.com/u/Hardik_Shah)\
**Post date:** [March 24, 2007, 11:59pm UTC](https://www.ruby-forum.com/t/scalability-in-ror-please-reply-asap/90000/5 "2007-03-24T23:59:07Z")

</div>

Ok,  
If you’re already done all of this, I apologize. To be honest, I’m  
new at  
Ruby on Rails, however I’ve been developing enterprise level J2EE Apps  
(minimum 10 web nodes in a cluster) for several years now. Here are  
some  
steps you can take to evaluate where the problem is.

1. Run the ‘top’ command, and see where you processor is spending the  
most time. Is it in wait or idle state, most likely its in wait.
2. Check your Memory and Swap in top, see if you’re maxing out your  
RAM. Swapping causes a lot of performance issue since you’ll be  
writing to  
disk
3. Check which process takes the most % of your CPU time. In my  
experience with ROR, its been the database.

If you database is spending the most time there are 3 options I can give  
you.

1. Evaluate and profile your code. If you have a lot of associations  
such  
as has\_many, or belongs\_to, ROR will issue a query for each of these  
associations as the page is loading. You can improve performance by  
early  
fetching each one. Take a look at the ActiveRecord API here  
[ActiveRecord::Base](http://api.rubyonrails.org/classes/ActiveRecord/Base.html). Look for the  
“:include” option.
2. Are you connecting to mysql via TCP IP or socket? If you’re  
connecting  
with TCP/IP, try using a socket.
3. If none of this helps you may want to separate your web node from  
your  
MySQL Node. This isn’t cheap, so your best bet is to make the code more  
efficient.

Hope this helps,  
Todd
