Tornado friends,
Thanks for the good thoughts.
My solution to the problem of RAM accumulation in long running process
is to kill forks that use more than (eg) 20% of their starting RAM
with:
def on_finish(self):
if resource.getrusage(resource.RUSAGE_SELF).ru_maxrss > 1.2 *
START_RU_MAXRSS:
sys.exit(1)
Where I define the global START_RU_MAXRSS on spin up.
Since I exit with a non zero signal, tornado is kind enough to restart
a fork for me.
In order to have this work past the default of 100 restarts, I added a
max_restarts parameter to netutils.start and modified one line in
process.fork_process to read:
if max_restarts and num_restarts > max_restarts:
raise RuntimeError("Too many child restarts, giving up")
So that when I start my server like this:
server.start(options.forks,max_restarts=None)
it spawns new forks forever.
It seems kind of bad to use sys.exit(1) like this but it works great
so far!
Cheers,
Joe
http://SportsDataBase.com