[racket] web server: module servlets

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Tue Sep 23 22:03:38 EDT 2014

On Tue, Sep 23, 2014 at 9:19 PM, George Neuner <gneuner2 at comcast.net> wrote:
> Hi Jay,
>
> On 9/23/2014 6:04 PM, Jay McCarthy wrote:
>
> On Tue, Sep 23, 2014 at 4:42 PM, George Neuner <gneuner2 at comcast.net> wrote:
>>
>> 1) Is there any way to speed up initial [module] servlet loading?
>
> This is why I recommend that new users use serve/servlet, which is
> much faster because it does not use namespaces or live loading.
>
>
> That's an option for a finished application ... if a web application ever
> really can
> be said to be finished ... but it's tough when you're developing.

Hi George,

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 guess the question is "where is all the time spent"?  Loading required
> modules
> from the library I suppose?

Yes.

> 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

>> 2) Debugging module servlets is a pain due to having to stop/restart
>> the server.  Is there some clever way to force the server to unload a
>> particular servlet but keep running?
>
> Doing this pretty much requires not following my advice in question 1,
> but the default server (used by the command line tool) allows you to
> go to "/conf/refresh-servlets" and unload/reload all the servlet code.
>
>
> That might help.  Does unloading & reloading affect a stateless servlet that
> isn't
> been changed?  More to the point, can you stop/restart the server and
> continue
> a stateless servlet?

Yes, that's the goal of stateless servlets :)

> 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


-- 
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.