Lambda the Ultimate

inactiveTopic Developing Interactive Web Programs (Scheme Servlets)
started 12/13/2002; 2:55:20 PM - last post 12/17/2002; 12:36:47 AM
Ehud Lamm - Developing Interactive Web Programs (Scheme Servlets)  blueArrow
12/13/2002; 2:55:20 PM (reads: 1771, responses: 8)
Developing Interactive Web Programs (Scheme Servlets)
Matthias Felleisen. Developing Interactive Web Programs. Summer School on Advanced Functional Programming 2002. August 2002.

An HtDP-like tutorial on building PLT Scheme servlets.

We discussed this PLT project in the past, and linked to the papers published about the techniques used by the PLT web server, as well as to other continuation based approaches to web programming.


Posted to general by Ehud Lamm on 12/13/02; 3:06:32 PM

Alex Peake - Re: Developing Interactive Web Programs (Scheme Servlets)  blueArrow
12/13/2002; 4:19:41 PM (reads: 1357, responses: 0)
I may have missed something here, so please forgive me if I did, but it seems that the continuation based approach suggested only works on a single web server. Even fairly small companies have web farms, and there appears to be no suggested solution here for this situation (each web request hits a different server).

Alex

Jacob Matthews - Re: Developing Interactive Web Programs (Scheme Servlets)  blueArrow
12/13/2002; 5:45:46 PM (reads: 1334, responses: 1)
Alex --

that problem boils down to the problem of how to effectively marshall a continuation in PLT Scheme. "Automatically Restructuring Programs for the Web" by Graunke, Findler, Krishnamurthi, and Felleisen talks about that issue in the context of Web programs, and while it's oriented towards the idea that the marshalled continuation eventually goes to a hidden field on a web page, there's no reason it couldn't go to a database server shared by a web cluster instead.

I haven't asked, but I suspect the reason Felleisen doesn't discuss it in "Developing Interactive Web Programs" may well be because while "Automatically Restructuring Programs for the Web" sketches the problem's solution, there are a million little details and practical concerns that we haven't quite ironed out yet. Keep watching, though.

Ehud Lamm - Re: Developing Interactive Web Programs (Scheme Servlets)  blueArrow
12/14/2002; 1:21:11 AM (reads: 1347, responses: 0)
Well, the Automatically Restructuring paper talks about the underlying theory and programming language techniques, while these lecture notes are more concerned with what's actually implemeneted in the PLT web server.

To continue the PLs as OSes theme, I would think they'll publish more about running servlets on server farms, when the PLT web server supports such distribution, and hides the complexity from the programmer.

Jacob Matthews - Re: Developing Interactive Web Programs (Scheme Servlets)  blueArrow
12/15/2002; 12:06:29 PM (reads: 1217, responses: 1)
Ehud --

Flatt is doing the PLs as OSes theme, but he's actually the PLTer least involved in the web-language branch of the PLT's research. Besides, I'm pretty sure that the PLT is actually pursuing the "Restructuring" way to implement send/suspend, considering that I'm the one writing the next paper on the subject. :) (I guess I should've mentioned that I'm Findler's graduate student.)

We've been working on fully realizing the compiler in "Restructuring" since the paper came out, and we're reasonably close to actually having something to show for that work. Once the compiler materializes, having clusters of web servers that all handle requests for the same CGI program will just be a matter of installing the compiled program on each computer -- all program state will be provided to whatever server happens to get the request on each transaction, so there's nothing else to do. This possibility is actually mentioned in some obscure corner of "Restructuring," I believe.

Ehud Lamm - Re: Developing Interactive Web Programs (Scheme Servlets)  blueArrow
12/15/2002; 2:42:49 PM (reads: 1243, responses: 0)
Thanks for the info. I was kind of trolling for it...

Matthias Radestock - Re: Developing Interactive Web Programs (Scheme Servlets)  blueArrow
12/16/2002; 2:10:46 AM (reads: 1207, responses: 0)
It's worth mentioning that SISC (http://sisc.sourceforge.net) has been able to take advantage of J2EE appserver clustering for some time. It's an undocumented feature though, which might explain why few people know about it :) SISC continuations are Java-serializable and can be stored in Session objects. This allows appservers to persist them - Tomcat, for instance, does that and it allows the appserver to be restarted while retaining all active sessions. Other appservers use the same serialization mechanism to migrate sessions between servers in a clustered environment.

Avi Bryant - Re: Developing Interactive Web Programs (Scheme Servlets)  blueArrow
12/16/2002; 6:52:09 PM (reads: 1136, responses: 0)
Alex - even if you can't marshal continuations, you just have to make sure that all the requests for a session get sent to the same server in the farm (the Linux Virtual Server project, for example, provides this kind of session affinity).

Matthias R - has anyone done any work on continuation-based web apps with SISC? I've been keeping an eye on it with an aim to port some of the ideas from Seaside (http://beta4.com/seaside2), but haven't yet had the time.

Matthias Radestock - Re: Developing Interactive Web Programs (Scheme Servlets)  blueArrow
12/17/2002; 12:36:47 AM (reads: 1111, responses: 0)
> Has anyone done any work on continuation-based web apps with SISC?

I have :)

The contrib/servlets cvs module of SISC contains helper code, some documentation and a complete web app example.

There really isn't much to it. The main complication, from a application programmer's point of view, is that one must ensure that every object reachable from the continuation is serializable. All SISC objects are serializable, but many ordinary Java objects are not. Specifically, HTTPRequest, HTTPResponse etc are not. Having any of these in your lexical environment breaks k serialization. The way to handle these is to place them in thread-locals (for which there is a convenient interface in SISC), which also has the advantages that one doesn't have to pass them around all functions and that they can easily be populated with new values when the k gets invoked.

> even if you can't marshal continuations, you just have to make > sure that all the requests for a session get sent to the same > server in the farm

indeed. afaik, generally app servers will try to avoid migrating session state between servers in a clusters by employing precisely this strategy. So session state only gets migrated in the event of node failure and severe cases of load imbalance.