On Thu, Mar 3, 2011 at 8:38 AM, Raymond Feng <enjoyj...@gmail.com> wrote: > Nice! > We can also extend the activation/deactivation scheme to support one of the > following (can be customized via web.xml): > 1) Pre-start the node when the web app starts and stop it when the web app > stops (what we have today) > 2) Lazy-start the node when the 1st HTTP request comes in and stop it when > the web app stops > 3) Start/stop the node for any given HTTP request (need to figure out how to > deal with concurrent requests) > 4) Start the node triggered by a HTTP request and stop it when it goes idle > for a period > Thanks, > Raymond > ________________________________________________________________ > Raymond Feng > rf...@apache.org > Apache Tuscany PMC member and committer: tuscany.apache.org > Co-author of Tuscany SCA In Action book: www.tuscanyinaction.com > Personal Web Site: www.enjoyjava.com > ________________________________________________________________ > On Mar 3, 2011, at 7:59 AM, Jean-Sebastien Delfino wrote: > > Hi all, > > Recently I've been experimenting with ways to speed up the bootstrap > of the Java runtime to support mass virtual hosting. > > I thought I'd share my findings here. > > Here's a summary of the use case: > - you're hosting hundreds or thousands of apps, published under > corresponding virtual hosts > - you can't pre-declare, pre-load and pre-start them all > - you need to activate an app when you get a request for it > - and clean up its resources after the request has been processed. > > and the mechanisms I experimented with: > - bootstrap the part of the runtime that's independent of any app, once > - load the app composite on the first request for it > - cache the app composite model > - activate/deactivate its components + start/stop them for each request > - do that for each HTTP request handled by our ServletHost > > The good news is that supporting that only involves a few little > tweaks to our usual runtime node startup sequence. > > I'm planning to share that experiment with the community for review there: > http://svn.apache.org/repos/asf/tuscany/sandbox/sebastien/java/vhost/ > > and hoping to help generate ideas to better address this type of use case. > > I'm really busy at work this week but will try to commit this code > when I find some time over the weekend. > -- > Jean-Sebastien >
I've committed a few prototypical utility functions to help bootstrap a runtime, deploy a contribution, build it, activate and start its components. The idea is that they could be used instead of NodeFactory and Node.start to prepare the Composite model and a CompositeContext for a particular app or virtual host and only activate and start its components when a request hits them. For details see SVN revision r1078641 [1], this change in EmbedTestCase.java [2]: - node = node(nf, deploy(contrib, comp)); - node.start(); + cc = start(activate(build(deploy(contrib, comp), ec), ec), ec); and EmbedUtil.java [3] for the new bootstrapping functions. Hope this helps [1] http://svn.apache.org/viewvc?view=revision&revision=1078641 [2] http://svn.apache.org/repos/asf/tuscany/sandbox/sebastien/java/vhost/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/EmbedTestCase.java [3] http://svn.apache.org/repos/asf/tuscany/sandbox/sebastien/java/vhost/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/EmbedUtil.java -- Jean-Sebastien