Opened 12 years ago

Closed 12 years ago

#434 closed task (fixed)

Rails FCGI processes need to be restarted periodically to save resources.

Reported by: john@… Owned by: steve@…
Priority: blocker Milestone:
Component: admin Version:
Keywords: Cc:

Description

As a possible fix for the current resource problems we need to tell the FCGI processes to quite after N requests have been served. This most likely involves adding a counter to dispatch.fgi and calling exit! when the limit is reached, which should result in fcgi starting a new process to take the old one's place. IRC discussion about this follows:

08:59 < mcknut> http://weblog.textdrive.com/article/175/rails-optimizing-resource-usage[[BR]] 08:59 < SteveC> yeah we're not in development mode
08:59 < SteveC> next
08:59 < SteveC> :-)
08:59 < mcknut> oh, you turned that off?
08:59 < SteveC> yeah to see if it was better. it was but not good enough
08:59 < mcknut> ah
08:59 < LA2> Steve, if this is essentially fcgi, do you have a way to return a response and then kill the process?
09:00 < SteveC> that was my next option, you can periodically graceful the processes
09:00 < SteveC> but they get so much traffic they dont seem to pause long enough to get gracefulled so I have to kill them, which loses the process queue
09:01 < mcknut> "put a counter in the CGI wrapper, if you reach the count service the current request then exit"
09:01 < mcknut> dispatch.fcgi most likely, apparently
09:01 < SteveC> makes sense
09:01 < SteveC> then have fcgi auto-reload on crash
09:01 < LA2> in classic Perl fcgi, your script implements the main loop itself, so you can write out the response to this query, and then say "die" to kill any memory leaks, rather than taking the next turn in the loop (fetching the next request)
09:01 < mcknut> yeah, which apparently it does
09:02 < mcknut> (auto-reloading)
09:02 < SteveC> I could auto-die after 500 map requests or something
09:02 < LA2> or after the process eats X megs of memory
09:03 < SteveC> does someone fancy summarising this as a ticket as I have to get ready for a flight? I think at least nickb will take a look
09:04 < SteveC> should be as simple as
09:04 < SteveC> COUNT = 0
09:04 < SteveC> in environment.rb
09:04 < SteveC> COUNT += 1
09:04 < SteveC> if COUNT > 500
09:04 < SteveC> exit
09:04 < SteveC> end
09:04 < SteveC> in the map call handler
09:04 < mcknut> ok, I'll do it
09:04 < SteveC> or
09:04 < SteveC> exit[[BR]] 09:04 < SteveC> not exit
09:04 < SteveC> then just test it works like it says it should
09:05 < SteveC> and I'll deploy
09:05 < mcknut> I'll make a ticket and ping nick

Change History (1)

comment:1 Changed 12 years ago by nickblack1@…

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.