# Mongrel hangs when idle

**URL:** <https://www.ruby-forum.com/t/mongrel-hangs-when-idle/179359>\
**Category:** Rails\
**Created:** [November 23, 2009, 1:01pm UTC](https://www.ruby-forum.com/t/mongrel-hangs-when-idle/179359 "2009-11-23T13:01:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![murraj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f6c823/32.png) [@murraj](https://www.ruby-forum.com/u/murraj)\
**Post date:** [November 23, 2009, 1:01pm UTC](https://www.ruby-forum.com/t/mongrel-hangs-when-idle/179359/1 "2009-11-23T13:01:49Z")

</div>

Hello All,

This issue has been raised by so many people in this forum and in the  
web before.  
But i am not sure, whether all of those got fixed the issue.

My application is running in  
1)rails 2.2.2  
2)ruby 1.8.6 (2008-08-11 patchlevel 287) [x86\_64-linux]  
3)MySQL 5.1.30-ndb-6.3.20-cluster-gpl MySQL Cluster Server (GPL)  
4)Apache/2.2.3 + mongrel\_cluster(1.0.5)

The mongrel is hanged when it is idle for some time.  
I don’t get any errors in the logs.

When i googled about this, i found the Mongrel FAQ page -  
[http://mongrel.rubyforge.org/wiki/FAQ](http://mongrel.rubyforge.org/wiki/FAQ) which says to set  
ActiveRecord::Base.verification\_timeout = 14400. when i added this in  
environment.rb i got warning as below:

DEPRECATION WARNING: ActiveRecord::Base.verification\_timeout= has been  
deprecated and no longer has any effect.

So the above solution failed.

I tried so many trials like increasing MySQL interactive\_timeout to a  
high value, updating the mysql gem etc… But no luck.

After so many trials and search i found that this issue rises only in  
production mode. That is when config.cache\_classes is set to true

In my stage environment also i am having the same configuration as my  
production(rails, ruby, mysql, apache and mongrel\_cluster). That is  
config.cache\_classes is set to true.

So, when config.cache\_classes = true, the mongrel hangs up after a long  
idle time. When its is set to false, everything is O.K

I doubt whether this(config.cache\_classes = true) is the cause of the  
issue.  
I am not sure whether DB connections are also cached if  
config.cache\_classes is set to true.

Please help me in solving the issue.

Any of your suggestions will be very helpful to me.

Thanks in advance

Murugaraj B.

---

<div class="post-metadata">

**Author:** ![murraj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f6c823/32.png) [@murraj](https://www.ruby-forum.com/u/murraj)\
**Post date:** [November 24, 2009, 5:48am UTC](https://www.ruby-forum.com/t/mongrel-hangs-when-idle/179359/2 "2009-11-24T05:48:52Z")

</div>

Hi Muruga R.

```
    Though I am not sure I have once read somewhere that you can 

```

setup a cron job to access say your home page every 5 or 10 minutes so  
to wakeup it on these regular intervels.But the above I read to avoid  
delay in loading first page after some time of idleness. But in your  
case it is hanging  
As an example crontab -e

\*/5 \* \* \* \* curl -s http://www.your\_domain.com /dev/null

```
  Please check right syntax for this

```

Sijo

---

<div class="post-metadata">

**Author:** ![murraj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f6c823/32.png) [@murraj](https://www.ruby-forum.com/u/murraj)\
**Post date:** [November 24, 2009, 5:59am UTC](https://www.ruby-forum.com/t/mongrel-hangs-when-idle/179359/3 "2009-11-24T05:59:24Z")

</div>

Sijo k g wrote:

> Hi Muruga R.
> 
> ```
> Though I am not sure I have once read somewhere that you can 
> 
> ```
> 
> setup a cron job to access say your home page every 5 or 10 minutes so  
> to wakeup it on these regular intervels.But the above I read to avoid  
> delay in loading first page after some time of idleness. But in your  
> case it is hanging  
> As an example crontab -e
> 
> \*/5 \* \* \* \* curl -s http://www.your\_domain.com /dev/null
> 
> ```
> Please check right syntax for this
> 
> ```
> 
> Sijo

Hello sijo,

Thank you for your suggestion.  
I am already using the cronjob you mentioned.

Anyway i need a permanent solution for this.

Thank you once again.
