Ray, the following patch changes the code to use ThreadLocal storage
instead of synchronization. Can you apply it, rebuild and let us know
the results? Alternatively I'd be happy to email you an updated
axis.jar if you are not building the code yourself.
mike
-----Original Message-----
From: Sutton, Ray [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 09, 2003 2:15 PM
To: '[EMAIL PROTECTED]'
Subject: RE: Performance Issues with AXIS & Axis Response Time appears
linear with load
In answer to Mike, no haven't got that far yet, in light of Robert's
reply I will probably look for another work around.
In answer to Robert, Thanks in my haste I forgot to check the java docs!
Thanks
Ray Sutton
Systems Engineer
-----Original Message-----
From: Mike Perham [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 09, 2003 12:59 PM
To: [EMAIL PROTECTED]
Subject: RE: Performance Issues with AXIS & Axis Response Time appears
linear with load
The Xerces code is very similar. What's the effect if you take the
synchronize out and rerun your performance tests? Do you have any
numbers or graphs?
-----Original Message-----
From: Sutton, Ray [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 09, 2003 1:32 PM
To: '[EMAIL PROTECTED]'
Subject: RE: Performance Issues with AXIS & Axis Response Time appears
linear with load
Hello,
Not sure if you're seeing the same problem as me (see thread RE: Axis
Response Time appears linear with load) but here's what I discovered in
case it helps.
I'm seeing traffic backup behind a synchronized call in
org.apache.axis.XMLUtils at line 317 (entire method follows)
public static Document newDocument(InputSource inp)
throws ParserConfigurationException, SAXException, IOException
{
DocumentBuilder db;
synchronized (dbf) {
db = dbf.newDocumentBuilder();
}
db.setEntityResolver(new DefaultEntityResolver());
db.setErrorHandler( new ParserErrorHandler() );
return( db.parse( inp ) );
}
Now dbf is an instance of "javax.xml.parsers.DocumentBuilderFactory"
which is an abstraction layer around the chosen XML parser in my case it
resolves to "org.apache.crimson.jaxp.DocumentBuilderFactoryImpl" the
method called under the synchronized block is:
public DocumentBuilder newDocumentBuilder()
throws ParserConfigurationException
{
DocumentBuilderImpl db = new DocumentBuilderImpl(this);
return db;
}
The constructor for DocumentBuilderImpl is doing a fair amount of work,
time constraints prevent me looking any deeper but I don't see any
obvious need for synchronization of this process.
What I suspect is that the good folks that develop Axis have
synchronized this because they can make no assumption about the
implementation that javax.xml.parsers.DocumentBuilderFactory abstracts.
If this is the case then I seems to me that the sync belongs in the DBF
implementation not its caller.
My personal instinct, unless anyone knows a good reason not, would be to
remove this specific synchronization point.
Thanks
Ray Sutton
Systems Engineer
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Sent: Friday, October 03, 2003 2:09 PM
To: [EMAIL PROTECTED]
Subject: Performance Issues with AXIS
Importance: High
Hi,
We are using Apache AXIS 1.1 to support a web service that returns
images. The images are base-64 encoded and embedded within the XML. What
we are seeing is very slow response times with AXIS when it tries to
construct the SOAP XML.The size of the images are in the range 50-100KB.
We are not sure if the large amount of data is the cause of the problem
or if we should be doing something else to overcome this problem ?
Thanks
Suket
The information in this electronic mail message is sender's business
Confidential and may be legally privileged. It is intended solely for
the addressee(s). Access to this Internet electronic mail message by
anyone else is unauthorized. If you are not the intended recipient, any
disclosure, copying, distribution or any action taken or omitted to be
taken in reliance on it is prohibited and may be unlawful.
The sender believes that this E-mail and any attachments were free of
any virus, worm, Trojan horse, and/or malicious code when sent. This
message and its attachments could have been infected during
transmission. By reading the message and opening any attachments, the
recipient accepts full responsibility for taking protective and remedial
action about viruses and other defects. Galileo International is not
liable for any loss or damage arising in any way from this message or
its attachments.
The information in this electronic mail message is sender's business
Confidential and may be legally privileged. It is intended solely for
the addressee(s). Access to this Internet electronic mail message by
anyone else is unauthorized. If you are not the intended recipient, any
disclosure, copying, distribution or any action taken or omitted to be
taken in reliance on it is prohibited and may be unlawful.
The sender believes that this E-mail and any attachments were free of
any virus, worm, Trojan horse, and/or malicious code when sent. This
message and its attachments could have been infected during
transmission. By reading the message and opening any attachments, the
recipient accepts full responsibility for taking protective and remedial
action about viruses and other defects. Galileo International is not
liable for any loss or damage arising in any way from this message or
its attachments.
Index: src/org/apache/axis/utils/XMLUtils.java
===================================================================
RCS file: /home/cvspublic/ws-axis/java/src/org/apache/axis/utils/XMLUtils.java,v
retrieving revision 1.84
diff -u -r1.84 XMLUtils.java
--- src/org/apache/axis/utils/XMLUtils.java 18 Jul 2003 12:40:40 -0000 1.84
+++ src/org/apache/axis/utils/XMLUtils.java 9 Oct 2003 19:36:40 -0000
@@ -111,7 +111,7 @@
private static final String saxParserFactoryProperty =
"javax.xml.parsers.SAXParserFactory";
- private static DocumentBuilderFactory dbf = getDOMFactory();
+ private static ThreadLocalDocumentBuilderFactory dbf = new
ThreadLocalDocumentBuilderFactory();
private static SAXParserFactory saxFactory;
private static Stack saxParsers = new Stack();
@@ -123,6 +123,13 @@
initSAXFactory(null, true, false);
}
+ // DocumentBuilderFactory is not guaranteed to be thread-safe
+ private static class ThreadLocalDocumentBuilderFactory extends ThreadLocal {
+ protected Object initialValue() {
+ return XMLUtils.getDOMFactory();
+ }
+ }
+
/**
* Encode a string appropriately for XML.
* @param orig the String to encode
@@ -285,9 +292,7 @@
public static Document newDocument()
throws ParserConfigurationException
{
- synchronized (dbf) {
- return dbf.newDocumentBuilder().newDocument();
- }
+ return
((DocumentBuilderFactory)dbf.get()).newDocumentBuilder().newDocument();
}
/**
@@ -300,10 +305,7 @@
public static Document newDocument(InputSource inp)
throws ParserConfigurationException, SAXException, IOException
{
- DocumentBuilder db;
- synchronized (dbf) {
- db = dbf.newDocumentBuilder();
- }
+ DocumentBuilder db = ((DocumentBuilderFactory)dbf.get()).newDocumentBuilder();
db.setEntityResolver(new DefaultEntityResolver());
db.setErrorHandler( new ParserErrorHandler() );
return( db.parse( inp ) );