[plt-scheme] Memory management of web-server

From: David Van Horn (dvanhorn at cs.uvm.edu)
Date: Tue Dec 7 16:10:38 EST 2004


My PLT web server application has burned the house down twice now by consuming 
all of the available memory on it's host, causing back-up failures to occur 
(this is not the best way to become popular with sys admins).  In an effort to 
prevent such catastrophes, I'd like to implement a periodic restart for the 
server, and utilize the memory accounting features for bounding memory 

The first seems easy enough to do.  I can write something along the lines of:

(let loop ()
   (let ((shutdown (serve ...)))
     (sleep ...) ;; for some period

Of course, this program has to run in finite space, but it seems like it should.

The latter is more difficult.  First, I haven't been able to get the 3m 
version of mzscheme working, but assuming I do get it working, I don't see how 
to use `custodian-limit-memory' to restart the server once the threshold has 
been crossed.  One approach, that doesn't require the precise collector, is to 
have a thread that calls `current-memory-use' on a regular basis and restarts 
the server whenever it exceeds some bound.

Are there better ways to do this?


Posted on the users mailing list.