You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Stephen Riek <st...@yahoo.co.uk> on 2002/11/12 04:26:13 UTC

Performance of Separate Instance vs Singleton ?

I may be misunderstanding the Velocity architecture. When 
used as a singleton in a website where almost all pages/requests
use Velocity templates, would the Velocity engine then become
the limiting factor or bottleneck since there may be many 
simultaneous requests but only one Velocity Engine to handle
them ? 
The Separate Instance docs state that "New in version 1.2, the 
separate instance allows you to create, configure and use as 
many instances of Velocity as you wish in the same JVM (or web 
application.) "  This means that I could create, say, 10 Velocity
engines, but how do I direct the servlets to share these in 
much the same was as a database connection pool will be shared
between several threads ? 
Thank you very much,
Stephen




---------------------------------
Get a bigger mailbox -- choose a size that fits your needs.

Velocity and Piped IO

Posted by "technosf@speakeasy.net" <te...@speakeasy.net>.
Hello All,

I was wondering if anyone has experiance using template output as input to another process/stream? 

I am trying to use pipedIO, used pretty much as described in the Sun tutorials:

            PipedWriter pipeOut = null;
        	PipedReader pipeIn = null;      
  
	pipeOut = new PipedWriter();
            pipeIn = new PipedReader(pipeOut);

            PrintWriter out = new PrintWriter(pipeOut);

My procedure recycles a VelocityWriter on  'out', [trys to] merge the template, returning 'pipeIn'. In testing everything works fine if I recycle the VelocityWriter on StringWriter, but chokes on the PrintWriter, or anything else, instatiated on the PipedWriter. Death occurs at the merge.


Any thoughts?



Thanks in advance...

Martin 







--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Performance of Separate Instance vs Singleton ?

Posted by Stephen Riek <st...@yahoo.co.uk>.
Thanks for the confirmation and speedy reply, Geir. Set my mind at ease.
Stephen.
 "Geir Magnusson Jr." <ge...@adeptra.com> wrote:

On Monday, November 11, 2002, at 10:26 PM, Stephen Riek wrote:

>
> I may be misunderstanding the Velocity architecture. When
> used as a singleton in a website where almost all pages/requests
> use Velocity templates, would the Velocity engine then become
> the limiting factor or bottleneck since there may be many
> simultaneous requests but only one Velocity Engine to handle
> them ?

No - it just means that any usages of Velocity w/in the same JVM will 
share the same instance, which really boils down to the same 
configuration and resources (such as cached templates...). [This 
doesn't apply when using Velocity in a servlet 2.2+ container where the 
velocity jar is in each webapp, and there is more than one webapp, but 
this is a fine point...]



> The Separate Instance docs state that "New in version 1.2, the
> separate instance allows you to create, configure and use as
> many instances of Velocity as you wish in the same JVM (or web
> application.) " This means that I could create, say, 10 Velocity
> engines, but how do I direct the servlets to share these in
> much the same was as a database connection pool will be shared
> between several threads ?

No need. The reason why you would do this is to keep those 
webapps/servlets from using the same set of cached templates, or if you 
wanted each to have a different configuration.

There are places where access is synchronized to resources, but 
compared to the cost of processing requests or rendering, the overhead 
of such serialization should be negligeable.

-- 
Geir Magnusson Jr 203-355-2219(w)
Adeptra, Inc. 203-247-1713(m)
geirm@adeptra.com


--
To unsubscribe, e-mail: 
For additional commands, e-mail: 





---------------------------------
Get a bigger mailbox -- choose a size that fits your needs.

Re: Performance of Separate Instance vs Singleton ?

Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On Monday, November 11, 2002, at 10:26 PM, Stephen Riek wrote:

>
> I may be misunderstanding the Velocity architecture. When
> used as a singleton in a website where almost all pages/requests
> use Velocity templates, would the Velocity engine then become
> the limiting factor or bottleneck since there may be many
> simultaneous requests but only one Velocity Engine to handle
> them ?

No - it just means that any usages of Velocity w/in the same JVM will 
share the same instance, which really boils down to the same 
configuration and resources (such as cached templates...).  [This 
doesn't apply when using Velocity in a servlet 2.2+ container where the 
velocity jar is in each webapp, and there is more than one webapp, but 
this is a fine point...]

> The Separate Instance docs state that "New in version 1.2, the
> separate instance allows you to create, configure and use as
> many instances of Velocity as you wish in the same JVM (or web
> application.) "  This means that I could create, say, 10 Velocity
> engines, but how do I direct the servlets to share these in
> much the same was as a database connection pool will be shared
> between several threads ?

No need.  The reason why you would do this is to keep those 
webapps/servlets from using the same set of cached templates, or if you 
wanted each to have a different configuration.

There are places where access is synchronized to resources, but 
compared to the cost of processing requests or rendering, the overhead 
of such serialization should be negligeable.

-- 
Geir Magnusson Jr                                   203-355-2219(w)
Adeptra, Inc.                                       203-247-1713(m)
geirm@adeptra.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>