[plt-scheme] PLT Web Server Memory Use

From: Henk Boom (lunarc.lists at gmail.com)
Date: Fri Dec 26 11:11:10 EST 2008

2008/12/26 Jay McCarthy <jay.mccarthy at gmail.com>
> Yes, every time you were getting a request, you were creating a whole
> bunch of closures and hash tables underneath those library calls. One
> curious thing is that the servlet cache created in the first example
> was never used, because a different servlet-dispatcher would be used
> each time.

Right, thanks for the information.

>> The second thing, wouldn't it be useful to have something like the
>> following included in the standard web server set of dispatchers?
>> (define (make-limit-dispatcher num inner)
>>  (let ((sem (make-semaphore num)))
>>    (lambda (conn req)
>>      (call-with-semaphore sem
>>        (lambda () (inner conn req))))))
>> This is a simple way of limiting the number of concurrent servlet
>> instances running at once, and also helps to keep the memory use down.
> I could add it. It _is_ 5 lines and really only one line matters. I
> think I will add it to the FAQ.

It looks like it doesn't work. I added print statements before and
after the call to inner using dynamic-wind, then used a servlet which
takes a couple of seconds to run. If, in Firefox, I go to the servlet
and hit refresh two times quickly, it looks like the servlet starts
twice but only finishes once. Do this enough times and the semaphore
runs out, stalling the server. What causes this behaviour? Does it
have to do with how the web server handles abandoned connections?


Posted on the users mailing list.