• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Slowness issue

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a java swing application that uses a servlet to connect to Tomcat which in turn holds all of my business logic. I need to send data in the request from the user input and the way that I am doing this is converting my java object into XML via XStream and then into a string which includes it as a parameter in a PostMethod. From within Tomcat, the String is then converted back to XML which then grabs the object from it and begins processing. There are times when the application gets slow (possible from a load of users) and I can't determine the cause. In my business logic, I set some code that times each piece and it doesn't seem as if it takes too long. I am wondering if the problem lies within the request getting to the server? Is there not enough of bandwidth that can handle these requests? What is the best way to diagnose this? Any help would be great and please let me know if any more information is needed.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is a true thing that XML is time consuming both in creation and parsing. Furthermore all those tags make XML a bit of a memory and bandwidth hog.

There are many reasons to use XML but speed is not one of them.

Depending on your user load to make measurements does make it hard to figure out what is causing the slow down. Is there any way you can set up a test case with a simulated user load?

If this was my problem and it turns out XML is the root cause, I would consider making that Java data object Serializable and send serialized objects back and forth.

Bill
 
Greg Abel
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could this be related to a bandwidth issue? I have 3 load balanced Tomcats and the CPU stays relatively low as does the memory. Should I keep an eye on the upload speeds?
 
Saloon Keeper
Posts: 27807
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One thing that can really nail you on webapps that consume XML is that there's basically 2 (3) ways to handle incoming XML.

One way is to to read it all in and build a DOM document. That gives you a full 2-dimensional view of all the XML data, but it eats a lot of memory and you cannot use it until the entire XML document has been read in and parsed.

Another way is to use the SAX parser and handle elements as they come in. You can discard or distill data as needed. DOM parsers usually use SAX to build the DOM, incidentally.

A third way is to use STaX, which is sort of an inside-out SAX parser. STaX, like SAX, processes data as a stream, but SAX basically requires you to save details and assemble it yourself, whereas STaX is more a matter of defining what the assembled data is going to look like and making the parser assemble it from the raw XML.

So one thing that might help is to use one of the non-DOM (linear) parsers.

Another option that might help in conjunction with that is to investigate "chunked" HTML data transmission from the Swing app.

There are some good tools that can give an idea of how much time it takes to send and receive data from a webapp. One of the primary ones I use is the network tab on the Firebug browser plug-in.
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Greg Abel wrote:Could this be related to a bandwidth issue? I have 3 load balanced Tomcats and the CPU stays relatively low as does the memory. Should I keep an eye on the upload speeds?



Hmm - if you are not really burning CPU time and memory, how about database access? Does your process have to talk to a database?

Unless you are on a really slow network connection, I would not worry about bandwidth. Transmission time is likely to be very fast compared to XML parsing time. How big is one of your XML encoded data objects?

Bill
 
reply
    Bookmark Topic Watch Topic
  • New Topic