# How to set a time-limit for mongrel?

**URL:** <https://www.ruby-forum.com/t/how-to-set-a-time-limit-for-mongrel/121298>\
**Category:** Rails\
**Created:** [November 26, 2007, 5:11pm UTC](https://www.ruby-forum.com/t/how-to-set-a-time-limit-for-mongrel/121298 "2007-11-26T17:11:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andreas\_Kappler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d78d45/32.png) [@Andreas\_Kappler](https://www.ruby-forum.com/u/Andreas_Kappler)\
**Post date:** [November 26, 2007, 5:11pm UTC](https://www.ruby-forum.com/t/how-to-set-a-time-limit-for-mongrel/121298/1 "2007-11-26T17:11:47Z")

</div>

Hi,

we have a problem with a small-sized Rails application. It is  
currently in productive use, and sometimes the customer reports  
unavailability of the application.

Today I could watch one of these occasions live and connect to the  
server while the application was down. Both mongrel servers were using  
100% cpu and a wast amout of memory, they seemed to be blocked by some  
large operation (probably a bug in some report generating  
functionality of the application)

I don’t see any chance to fix the bug soon, so my question is, how can  
I set a time-limit on those mongrel servers?

The configuration:

- Linux Debian
- Apache mod\_proxy
- 2 Mongrel servers

Somehow mongrel should be restarted, when one request takes more time  
than 1 minute. I don’t see a way to do this. Any help would be greatly  
appreciated.

- Andi

---

<div class="post-metadata">

**Author:** ![Andreas\_Kappler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d78d45/32.png) [@Andreas\_Kappler](https://www.ruby-forum.com/u/Andreas_Kappler)\
**Post date:** [November 26, 2007, 5:46pm UTC](https://www.ruby-forum.com/t/how-to-set-a-time-limit-for-mongrel/121298/2 "2007-11-26T17:46:17Z")

</div>

> I don’t see any chance to fix the bug soon, so my question is, how can  
> I set a time-limit on those mongrel servers?

I don’t have the answer, so this isn’t a very helpful post! Back in my  
.asp days, we’d set a Server.Timeout to a given number of seconds.  
This sort of thing would work for you.

On [mongrel.rubyforge.org](http://mongrel.rubyforge.org), there’s some stuff about “Ability to specify  
a timeout throttling setting and a max number of concurrent  
connections with additional attempts at cleaning dead threads out”.

---

<div class="post-metadata">

**Author:** ![Andreas\_Kappler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d78d45/32.png) [@Andreas\_Kappler](https://www.ruby-forum.com/u/Andreas_Kappler)\
**Post date:** [November 26, 2007, 7:20pm UTC](https://www.ruby-forum.com/t/how-to-set-a-time-limit-for-mongrel/121298/3 "2007-11-26T19:20:38Z")

</div>

1. Look at your code. Find out what’s causing the mongrels to misbehave.  
More often than not it’s a code problem.

2. Are you using RMagick? That’s caused me some problems.

3. Use Monit. There are some great resources for mongrel + monit. You  
can  
use monit to stop / restart mongrels after various conditions occur.

[http://www.igvita.com/blog/2006/11/07/monit-makes-mongrel-play-nice/](http://www.igvita.com/blog/2006/11/07/monit-makes-mongrel-play-nice/)

[http://software.pmade.com/blogs/ramblings/2006/12/27/mongrel-cluster-and-monit](http://software.pmade.com/blogs/ramblings/2006/12/27/mongrel-cluster-and-monit)

---

<div class="post-metadata">

**Author:** ![Andreas\_Kappler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d78d45/32.png) [@Andreas\_Kappler](https://www.ruby-forum.com/u/Andreas_Kappler)\
**Post date:** [November 27, 2007, 8:20am UTC](https://www.ruby-forum.com/t/how-to-set-a-time-limit-for-mongrel/121298/4 "2007-11-27T08:20:12Z")

</div>

Thanks for your answers.

I will try monit, it sounds promising.
