[racket] web server: module servlets

From: George Neuner (gneuner2 at comcast.net)
Date: Thu Sep 25 12:51:56 EDT 2014

Hi Jay,

On 9/23/2014 10:03 PM, Jay McCarthy wrote:
> The command-line tool is basically deprecated and only provided for
> backwards compatibility. There is a huge amount that it can't do at
> all and it hasn't been the primary way that we recommend using the Web
> server for a very long time.

I'm not using the plt-web-server app - I created a minimal application 
that set up the environment: directories, ports, etc. and a start 
function that just returns a 404 if called.  My server sits behind 
Apache and only handles servlets, which I would like to be demand load 
modules so they can be added to and updated easily. That's why I am 
interested in being able to unload servlets on command, though not 
necessarily all of them at once (although that also is helpful).

> > Not really knowing much about Racket's internals he naively asks:
> >Coulda server  pre-load the commonly used webserver modules and make
> >themavailableto new module servlets, or does the custodian
> >implementation  make doing thatdifficult/impossible?
> This is the purpose of the make-servlet-namespace argument of
> configuration-table->web-config@ but there is no option in the
> configuration file for that argument.
> http://docs.racket-lang.org/web-server-internal/Web_Servers.html?q=servlet-namespace#%28def._web-config._%28%28lib._web-server%2Fweb-config-unit..rkt%29._configuration-table-~3eweb-config~40%29%29

The namespace facility seems designed more for user written modules than 
for library modules.

My analysis may be off-base as I have very little experience working 
directly with custodians, but it seems that when a dynamic servlet is 
first loaded, its custodian spends a lot of additional time (re)loading 
library modules that already exist in other custodians. [ Though I can't 
tell exactly what's happening, I can see a lot of disk activity when I 
think I'm loading a 5KB servlet. ]  Reasonably I would have expected 
that after loading/linking the first servlet, the libraries common to 
the servlets would be already in memory. But loading additional servlets 
is no quicker [ and causes a similar disk hit ] so clearly I don't 
understand what is happening internally with the custodians.

If a Racket library is deliberately put into the servlet-namespace, does 
that streamline linking?

> > My application so far is based on stateful servlets and AJAX ... stateful
> > mainly because it's easier for me to understand.  Currently there is
> >little use ofcontinuations, but some planned functionality will use them
> >  extensively and it certainly wouldhelp if debugging didn't always mean
> >starting over setting up conditions in theapplication.
> This comment/question is related to questions 4 and 5 from the FAQ:
> http://docs.racket-lang.org/web-server/faq.html?q=servlet-namespace#%28part._update-servlets%29

That link leads to a "troubleshooting" page 8-).  I didn't consider the 
issue to be a "problem" per se - I already knew that restarting a 
stateful servlet would lose saved state.  Most of my existing servlets 
are one-shots that don't save any state, but they are written using the 
stateful language.  Only a few use continuations and not extensively (so 
far).  I was just thinking ahead to stuff that will need to use 
continuations more extensively.

Thanks for putting up with my questions.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140925/7c368b80/attachment.html>

Posted on the users mailing list.