Looks like I was overloading the mongrels with connections...I took down the number of connections allowed in HAProxy and it looks like the problem went away. So, thanks!
This has uncovered a new problem though, one that's truly baffling me: - Start up mongrel instances. Everything is awesome. Site is fast, life is good. - Wait 30-40 minutes. - Observe that updates and inserts in the database (postgres) are becoming slow. And by slow, I mean 30-40 seconds for a simple insert or update where it previously took less than 0.1 seconds. Load on DB server itself remains nominal; less than 2 on an 8 core box. No error messages of importance that I can see. Inserts and updates from other sources (script/console, psql) are fast. This started happening just after switching from fcgi to mongrels. Could it be something is different about how it handles database connections? Was I relying on some kind of bug before? E On Sat, May 31, 2008 at 7:11 PM, Brian Weaver <[EMAIL PROTECTED]> wrote: > Emmett, > > Contrary to what Zed's message seems to imply, there is nothing > inherently wrong with codling like: > > a = FIle.open("blah.txt") > a.write("hi!") > a.close() > > You simply need to understand that if any error occurs during > a.write(...) or a similar call then a.close will not be invoked. If > you use error handling like > > a = FIle.open("blah.txt") > begin > a.write("hi!") > ensure > a.close() > end > > then you will ensure that the file is actually closed regardless of an > exception. Of course a block like that is kind of ugly, so it's better > to do what Zed suggested and actually associate a code block with the > open call. This means that even if the block faults the file is > closed; it's just a cleaner syntax. > > Here are some links that kind of explains it too: > > http://www.meshplex.org/wiki/Ruby/File_handling_Input_Output > > http://www.math.hokudai.ac.jp/~gotoken/ruby/ruby-uguide/uguide25.html<http://www.math.hokudai.ac.jp/%7Egotoken/ruby/ruby-uguide/uguide25.html> > > -- Brian > > On Thu, May 29, 2008 at 5:02 PM, Zed A. Shaw <[EMAIL PROTECTED]> wrote: > > On Thu, 29 May 2008 13:07:27 -0700 > > "Emmett Shear" <[EMAIL PROTECTED]> wrote: > > > >> I just switched to Mongrel, and it's been working much better than my > >> previous lighttpd/fastcgi setup. So thanks for the awesomeness. > >> > >> My current problem: once or twice an hour, I get following error in > >> production > >> > >> Mongrel timed out this thread: too many open files > >> > >> I never get it in testing or on our staging server. Any ideas what would > >> cause that? It doesn't *appear* particularly correlated with load to me, > but > >> I'm only receiving notifications after the fact so I can't be sure. > > > > A couple things cause this. One is that the mongrel is overloaded with > > too many connections so it can't accept any more. > > > > If there's isn't that much load on the server, then it's more likely > > that you are leaking an open file here or there. If you are doing code > > like this: > > > > a = open("blah.txt") > > a.write("hi") > > a.close() > > > > Then you are probably leaking files. Look for that, and then translate > > to the block form: > > > > open("blah.txt") {|a| a.write("hi") } > > > > That's probably the #1 mistake people make from other languages. > > > > -- > > Zed A. Shaw > > - Hate: http://savingtheinternetwithhate.com/ > > - Good: http://www.zedshaw.com/ > > - Evil: http://yearofevil.com/ > > _______________________________________________ > > Mongrel-users mailing list > > Mongrel-users@rubyforge.org > > http://rubyforge.org/mailman/listinfo/mongrel-users > > > > > > -- > > /* insert witty comment here */ >
_______________________________________________ Mongrel-users mailing list Mongrel-users@rubyforge.org http://rubyforge.org/mailman/listinfo/mongrel-users