[plt-scheme] plt-web-server configuration

From: Dave Gurnell (d.j.gurnell at gmail.com)
Date: Tue Oct 28 11:42:14 EDT 2008

> Since you've implemented in PLT, is it really off topic?
>
> Have you documented the philosophical difference in your approach to  
> the PLT web server? It sounds interesting.


The main difference is between programming with one servlet versus  
programming with multiple servlets, which is one of shared resources.  
I'm treading water at the edge of my PLT depth here - please correct  
me, anyone, if I'm wrong about the technical bits.

The Web Server (WS) goes out of its way to ensure that servlets are  
kept separate. By default, each servlet is loaded into its own private  
namespace, which means it gets its own private copy of all the code it  
loads. The state in one servlet's namespace cannot be affected by  
changes made in another servlet's namespace. Note that it is possible  
to modify the web server's default configuration to introduce some  
overlap to the namespaces.

All this namespace stuff is a Good Thing if you're running a server  
that has servlet code contributed by different author, because each  
author can write their own servlet without worrying about what the  
others have written. On the other hand, if you're writing all the code  
yourself this may not be such a large advantage for you.

For the stuff we do at Untyped, where we run one web application out  
of a WS and write everything ourselves, we don't need multiple  
servlets. We released Instaservlet as a quick way of producing a web  
server configuration where all requests to any URL are sent to a  
single servlet.

We end up with a situation where all of our requests (for all URLs)  
arrive at a single servlet. Dispatch is essentially a souped-up regexp  
pattern matcher that looks at the URL in the request and chooses a  
procedure to run. Procedures take the place of servlets, and obviously  
they all run in the same namespace.

If you do use multiple servlets, you can use the regular WS dispatcher  
to do some of this job for you. The WS dispatcher can be configured to  
pass requests to servlets and static content in any way you want:

     http://docs.plt-scheme.org//web-server/dispatchers.html

That's the difference in approach. The difference in terms of coding  
convenience is another thing entirely. I haven't really made much of a  
case for writing Instaservlet or Dispatch here, but that's mostly  
because they provide other conveniences that are outside the scope of  
the discussion. I'll refer people to the docs for more information:  
particularly the Overview and Quick Start sections in the Dispatch  
manual (always got to squeeze a plug in):

     http://planet.plt-scheme.org/package-source/untyped/dispatch.plt/1/5/planet-docs/dispatch/index.html#(part._intro)

     http://planet.plt-scheme.org/package-source/untyped/dispatch.plt/1/5/planet-docs/dispatch/index.html#(part._quick)

Cheers,

-- Dave



Posted on the users mailing list.