[plt-scheme] Memory management of web-server
Hello,
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
consumption.
The first seems easy enough to do. I can write something along the lines of:
(let loop ()
(let ((shutdown (serve ...)))
(sleep ...) ;; for some period
(shutdown)
(loop)))
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?
Thanks,
David