[racket] web server: module servlets

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Thu Sep 25 13:04:44 EDT 2014

On Thu, Sep 25, 2014 at 12:51 PM, George Neuner <gneuner2 at comcast.net> wrote:
> 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:
>> Could a server  pre-load the commonly used webserver modules and make
>> them available to new module servlets, or does the custodian
>> implementation make doing that difficult/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?
>

Your assumption about the purpose of this is not correct. Anything in
the servlet-namespace will be shared between all servlets, and thus
not loaded per-servlet.

>> 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 of continuations, but some planned functionality will use them
>> extensively and it certainly would help if debugging didn't always mean
>> starting over setting up conditions in the application.
>
> 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.
> George
>



-- 
Jay McCarthy
http://jeapostrophe.github.io

           "Wherefore, be not weary in well-doing,
      for ye are laying the foundation of a great work.
And out of small things proceedeth that which is great."
                          - D&C 64:33

Posted on the users mailing list.