I've been using Xalan, but I wonder if anyone with experience can tell me if there is a superior transformer out there. Xalan is great, but one thing I've noticed is this- if I hit it with a bunch of calls at once, performance degrades rapidly. I can't really understand why. A page that takes 50ms to render will suddenly take over a second to render, if I refresh the page just 4 or 5 times rapidly in a row. That's not 4 or 5 times slower, but over 20 times slower! I don't know what could cause such dramatic performance decline, possibly some heavy synchronization internally to Xalan...but I doubt that. If anyone has an idea on how to increase performance under load, I'd greatly appreciated it!
We had the same problem when we used Oracle parser and we cached the parsed XSL, but all the instances using the same Transformer.
Transformer is nor thread-safe, I think, you must cache the templates and just return a new
Transformer tr = template.newTransformer();
for every client.
I hope this helps....
We use Xalan and I have been using what Jose has suggested, no issues to far. One thing that did help us was making the XSL private static string. It never changes.
I'm using a new transformer each time, but I still have the problem. It seems if I refresh the page rapidly, even for a short period of time, some requests to Xalan get "stuck", for several minutes even! And occassionally it gets into a situation where the garbage collector keeps kicking in over and over until I start seeing OutOfMemoryErrors. I have made sure that this is happening inside the transform method.
This situation usually does not occur during load testing, even with over 100 virtual users hitting the box--but it does happen consistently when I rapidly refresh the page. Something is not being handled propery internal to Xalan, and this even occurs on the latest release.
Nevermind, it seems the problem I am having isn't related to Xalan (although that's were my threads went to die...for some reason). Something apparently screws up with the request or the writer from the request if you refresh the same page multiple times without letting the pages load. I changed the code to write the output of the transformation to files instead of a writer from the request, and there were no problems no matter how many times I refreshed. I ended up with hundreds of files after testing... however with no problems to report. I still don't know why it was dying inside of transform, but now it seems that it is not a problem with Xalan.