Skip to main content

Chapter 8: Continuation Servers

14 replies [Last post]
invalidname
Offline
Joined: 2003-06-09
Points: 0

Chapter 8 introduces Continuation Servers: "A new class of web servers called continuation servers is starting to make some real noise. A continuation server uses a programming construct called the continuation to keep enough information about a request to be able to completely reconstruct the context. In technical terms, a continuation saves the execution environment, including the call stack. In practical terms, using continuations in a web server lets the server maintain context for you, freeing you to program in a more natural way."

What's the big deal? "When you've got an application that spans multiple computers with synchronous request/response communication, you often want to suspend control until the remote system responds. When you need to scale this solution, suspending control while you wait frees the system to handle other requests. The system can conveniently resume your application without disruption when the remote system responds, simply by calling a continuation."

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
rickcarson
Offline
Joined: 2004-03-04
Points: 0

> Close. The O'Reilly editor (me) picks them, from an
> RSS feed ...

Which raises the interesting question, how and/or why is an O'Reilly editor in charge of the java.net front page? Is it by invite? Does O'Reilly host the java.net site?

I ask this not in a tin foil hat conspiracy kind of way, but out of genuine interest. I'd thought it was Sun pulling the strings from behind the curtain, not O'Reilly.

Also, at one point I was interested in posting an article or two to various O'Reilly sites (ummm... www.oreillynet.com and others in the mac sphere of things), but couldn't see where to send them. It made me wonder how the articles were submitted, eg do they request them specifically or some other method? Or are you entirely the wrong person to ask?

invalidname
Offline
Joined: 2003-06-09
Points: 0

> Which raises the interesting question, how and/or why
> is an O'Reilly editor in charge of the java.net front
> page? Is it by invite? Does O'Reilly host the
> java.net site?

java.net is a collaboration between Sun, O'Reilly, and CollabNet. Check out the logos at the bottom of the front page. Generally speaking, O'Reilly provides editorial content, and Collab handles the project space.

> Also, at one point I was interested in posting an
> article or two to various O'Reilly sites (ummm...
> www.oreillynet.com and others in the mac sphere of
> things), but couldn't see where to send them. It
> made me wonder how the articles were submitted, eg do
> they request them specifically or some other method?
> Or are you entirely the wrong person to ask?

For a java.net article proposal, e-mail me ("cadamson" + "@" + "oreilly.com"). For O'Reilly Network sites like MacDevCenter, see the "Contact Us" link at the bottom of www.oreillynet.com to find that site's editor.

--Chris

rickcarson
Offline
Joined: 2004-03-04
Points: 0

> One more question... what's the criteria for getting
> a forum thread "pinned" to the java.net main page? I
> consistently see these threads on there each day.
> Many have no replies, so the most obvisou choice of
> f high activity isn't it. This would be something
> useful to know if I have a thread that I want
> everyone to see. Does anyone know what the criteria
> is?
>
> Thanks
> Erik

I don't know for sure, but I suspect someone at Sun and/or one of the Java.net moderators picks them. At one stage, I suspected the candidate might have been John Reynolds. If so I suspect he has a preference for controversy and debate, due to his many "devil's advocate" style posts (aka stirring the hornet's nest).

Bruce Tate for example is highly articulate (or whatever the online equivalent of that is, possibly 'well written'), and makes good reading. Even if I spend half my time wondering what colour excrement is on his planet. Of course hopefully we realise that since some of Bruce's stuff that we agree with other people are querying the colour of, that the whole thing must be highly subjective.

Of course, since this is the Internet, subjective opinions stated as facts = 'lively debate'.

The question then is... do 'lively debates' build a community?

I picked up Robert Kyosaki's (of "Rich Dad/Poor Dad fame") "10 things entrepreneurs should know before they quit their day job", and flicked through it. He was talking about Mission, and how the side that believes in their mission the most will always win (in relation to wars between countries and competition between corporations).

I suspect that building a community is more about a bunch of people all having the same mission (and believing in it strongly) than enjoying a good flamewar... er... I mean 'philosophical discussion'.

Hence the success of Linux - with it's incredibly strong mission (even if they never sat down and nutted out a 'mission statement', or worse yet, hired a PR firm to come up with one for them *shudders*).

invalidname
Offline
Joined: 2003-06-09
Points: 0

> I don't know for sure, but I suspect someone at Sun
> and/or one of the Java.net moderators picks them. At
> one stage, I suspected the candidate might have been
> John Reynolds. If so I suspect he has a preference
> for controversy and debate, due to his many "devil's
> advocate" style posts (aka stirring the hornet's
> nest).

Close. The O'Reilly editor (me) picks them, from an RSS feed that shows all forum posts in reverse chronological order of posting. And yes, I do have an affinity for controversy and debate, though I also try to pick out messages that solve problems and feature those.

I'm not as interested in how long a conversation has been going (indeed, I'll try to pick a good thread starter whenever I can), but how well it will stand alone on the front page, and whether it will interest readers enough to lead them to the forum.

Keeping things interesting is part of building a community, which is what we hope the forums are doing. Drop me a line [cadamson at oreilly.com or invalidname at dev.java.net] if you think this is or isn't working.

--Chris

evickroy
Offline
Joined: 2004-07-23
Points: 0

Personally, I don't think this thread is worthy of much discussion, but that's just might opinion of course. I only came here because it consistently appears on the front page, and eventually begged the question of how?
I was guessing that Bruce was some community leader in java.net land and had some pull... it appears that the guess was pretty close. ;)

Erik

Noman khan

How does the continuation servers help in developing a workflow managment system where the "workflow" can be changed at anytime?
Where we have to change the workflow,without going into mess of coding?

rickcarson
Offline
Joined: 2004-03-04
Points: 0

Dalma looks interesting. Clearly continuations have a kind of advantage where you want to pause in the middle of a function or method.

However, are continuations really so relevant for the Web?

Do they, for instance, have a significant advantage over storing the state in some kind of object graph, and then persisting the graph to the session?

After all, with a web request I will get to the end of the method anyway, I could just make the last thing an instruction to persist the state to the session, and the first thing of the new request is to pull that state out of the session.

This would alleviate the drudgery of sending the state down to the client (via hidden fields in the html or whatever).

On most web projects I've worked on, the Session was regarded as a limited resource, and in general the rule of thumb was not to shove too much into it if we could help it.

From the links and comments about continuations, it sounds as though the amount of stuff being stored in the session would be a lot more with continuations than the state persistence.

I suspect that there would be a number of trade-offs, and my first question would be how scalable is the use of continuations? Is this only for low traffic situations, or is this for heavy duty prime time as well?

Notably, Paul Graham's use of continuations was (allegedly) later rewritten in Java. Could scalability have been one of the major reasons for this?

liliagephardt
Offline
Joined: 2010-06-09
Points: 0

Hello everyone! I'm happy to see that all you Java fans got to dissecting the continuation servers. Not may people know about them and even less understand why these servers represent the future of web hosting. Can't wait to get them up and running at work.

____________

Lilia Gephardt | VPS server

gbevin
Offline
Joined: 2003-06-12
Points: 0

Hi, as the author of the RIFE framework (http://rifers.org) I'd like to clarify our view on continuations. They are extremely handy for what I call 'islands of functionality'. These are clearly delimited flows that need several steps to be completed before a whole action can be consider done (wizards, configuration steps, ...). The main benefit is that you can just rely on the constructs of your programming language to declare the flow for you (if-else, while, switch, ...). This also gives you the possibility to debug flows with any Java debugger (http://rifers.org/theater/debugging_continuations).

It's quite easy to keep the variable state limited by doing memory intensive work in helper methods, without pulling the large memory structures into the local scope where a continuation is active.

I don't think that continuations are a good fit for the entire flow of a website, but you should rather use them where they make sense and tie those parts together with other means of flow/state handling that's closer related to the web medium.

evickroy
Offline
Joined: 2004-07-23
Points: 0

> They are extremely handy for what I
> call 'islands of functionality'. These are clearly
> delimited flows that need several steps to be
> completed before a whole action can be consider done
> (wizards, configuration steps, ...). The main benefit

This sounds a lot like "Transactions".

One more question... what's the criteria for getting a forum thread "pinned" to the java.net main page? I consistently see these threads on there each day. Many have no replies, so the most obvisou choice of high activity isn't it. This would be something useful to know if I have a thread that I want everyone to see. Does anyone know what the criteria is?

Thanks
Erik

whartung
Offline
Joined: 2003-06-13
Points: 0

> > They are extremely handy for what I
> > call 'islands of functionality'. These are clearly
> > delimited flows that need several steps to be
> > completed before a whole action can be consider
> done
> > (wizards, configuration steps, ...). The main
> benefit
>
> This sounds a lot like "Transactions".

Yea, perhaps from a 30,000 foot view.

But he's talking from both a user experience point of view as well as a system development and maintenance point of view.

Simply, with a continuation server you can write code like this (paraphrasing, I've never used one personally):

function forumPost(...)
{
posting = showPostFormPage();
while (session.getUser() == null) {
login = showLoginPage();
if (login.action() == "Register") {
newUser = null;
while (newUser == null) {
register = showRegisterPage();
if (register.action() == "OK") {
newUser = registerUser(register.form());
}
}
session.setUser(newUser);
} else if (login.action() == "Login") {
currentUser = loginUser(login.form());
if (currentUser != null) {
session.setUser(currentUser);
}
}
}
postMessage(session.getUser(), posting.form());
}

It's a contrived example, but the point is that you just write your pageflows like you would any other code. The framework handles things like back buttons and what not for you. Plus, the entire pageflow is quite clear, it's all laid out in one place.

That's the benefit of continuation servers. You don't write your entire web site as one huge application, but rather, like he said, little islands of functionality that are knitted together.

invalidname
Offline
Joined: 2003-06-09
Points: 0

Mid-way through the chapter, Tate summarizes the pros and cons of continuation servers:

"You've seen the primary benefit: you can look at a web application as one big piece, instead of coordinating lots of little requests. That's incredibly powerful. Continuation servers have some other capabilities as well. The Back button problem becomes much easier to solve, because if the Back button is not disabled, you can just revert the application state to the last continuation, or any previous continuation. To disable the Back button, you simply tell the browser and delete past continuations. Threading also becomes trivial, because each thread can work on a private continuation, each with an application's own resources. You don't have to worry about serializing access to a shared session.

Continuation servers work best for applications that have complex state management issues and sophisticated control flows between pages. The continuation server simplifies navigation dramatically by letting you maintain application state between pages.

Continuation servers do have a few problems:

* The servers typically attach identifiers to URLs, and some don't like ugly URLs (though web sites like Amazon.com use them).

* You must guarantee session affinity , meaning that after an initial request in a user's session, the same machine must serve the user for every subsequent request. You could overcome this problem with a distributed continuation cache, but just as distributed HTTP sessions are a problem, distributing a continuation cache may not be completely practical.

* Continuations are more expensive than other session management techniques. I've seen little practical evidence that this has been a problem in production deployments. Still, some believe this approach will not scale as well as traditional web apps. Research on partial continuations will probably solve this problem eventually.

To me, the powerful advantages dwarf the potential disadvantages. It's possible, even likely, that a continuation server in some language will garner enough popularity to serve as a catalyst. Respected programmers Dave Thomas, Glenn Vanderburg, and David Heinemeier Hansson have all pointed to the continuation server as an important technology to watch. [i]Hackers and Painters[/i] author, Paul Graham, used continuations in web applications with devastating effect at Viaweb, on an application that eventually became Yahoo! Store. He's also a proponent of continuation servers."

kohsuke
Offline
Joined: 2003-06-09
Points: 0

Sorry for a shameless plug, but the application of continuation is also useful outside web servers. I'm developing a workflow engine that uses continuation behind the curtain to allow programmers to write long-running operations (workflows) easily. See https://dalma.dev.java.net/

leouser

hmmm, interesting. I wonder if C#'s generator resembles python's generator. A generator in python is:
def generator_example():
...for z in xrange( 100 ):
......yield z

where upon yield the value of z is returned. The yield keyword turns the generator_example function into an iterator like construct.

I guess I find myself wondering how do you manage a continuation? Is there an explicit continuation object? Say if I my system decides that continuations 100-236 which have been abandoned by their users needs to be purged, how will it operate with those continuations?

My experience with generators is that their nice to have, but not essential. Continuations sound similar but there doesn't appear, from what Ive read so far, any internal mechanisms to act upon your continuationess. Or is that supposed to be part of their value, their hiddenness? They almost sound like a marriage between regular threads and green threads.

leouser