• 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 ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Java Servlets Performance Issues

Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was wondering about the Java Servlets perfomance issues. Some people say that a GUI written in java is slower to load than GUI written in C++ over the Web( it may be also true as an application). This may be true for an Applet, but I am not sure whether that is the case with Java Servlets.
I have Java Web Server installed and the Console to manage this sever does take some time to load to my machine which also has the JWS.
Where can I find documentation relating to such issues and comparison between C++(cgi-bin) and Java (cgi-bin applicaion) and also
Java Servlets as a tool for internet computing. I do know a little bit performance related issue that java Servlets provide over C++.
Thanks in advance
Posts: 23787
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The interesting thing about performance and GUI's is that C++ is currently going about as fast as it can go. Over the next five years you might be able to squeeze another 5% out of it. With Java, there is a massive world of optimization that has barely been tapped. I think that current speeds are comparable. Five years from now Java might be several times faster.
Servlets: The key to servlets being faster than than C or C++ CGI has a lot to do with servlets already being loaded in memory and are pre-initialized. Then the functionality speed is generally comparable. Some servers can be configured to have the C/C++ CGI in memory already, but they still have to go through all of their initialization.
Posts: 7001
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for asking this. It's almost an (unintentional) trick question. and actually has little to do with the performance of servlets.
Sun's Java Web Server (JWS) uses an applet to administer the server, and this applet is downloaded to the browser the first time each session that you want to change something. I don't know of any other servers which use this method, and I think it's a real design mistake.
If you look at the size of the applet which is downloaded, you will notice that it's huge. It was over 650K in JWS 1.0, and I doubt that it has got much smaller since. Downloading this enormous lump is what makes accessing the admin facilities of JWS so slow.
There is a much better solution which demonstrates the power of servlets and is used by most other servers. Configuration using standard web pages and forms, generated and processed by servlets is very quick and efficient.
The transfer of servlet generated web pages is exactly as fast as transfer of static web pages. It depends on the network between the two machines rather than the method used to generate the pages.
In the general matter of servlet performance, there are a lot of overheads which make web application performance hard to measure. Using the CGI interface, whatever the language the CGI program is written in, tends to be relatively slow compared with a solution built in to the server. All CGI requests require the starting of a new process and loading then initialising at least one program from disk before any useful work can be done. In the case of interpreted languages (Perl, Shell scripts, Awk, Python, Java etc.) the CGI call also needs to load and validate the code to be interpreted. This makes using such languages in CGI calls the slowest of all. Calling compiled C code using CGI is bit faster, but not much, usually.
If the language interpreter can be built in to the server, then most of this overhead disappears and the speed of the languages begins to make more of a difference. The fastest method is probably to write and compile C programs using the native API of the server (Apache modules, NSAPI, ISAPI, WAI etc.). This has the problem of being very server-specific, though.
Almost as fast is to build in an interpreter for one of the interpreted languages into the server, or at least a way of executing code in a continually running interpreter. This is used by almost all web servers which support servlets in one form or another. Apache Jserv, for example has a compiled Apache module which sends commands to a separate but continually running servlet engine. Java Web Server (and all pure-Java web servers) execute servlets directly.
It's only when you are comparing like for like (say C/NSAPI against Servlets in JWS) that language speed issues become important.
Even then, there are other delays which may make the comparison pointless. Any form of net traffic, input/output or database access can easily swamp any performance calculations, as the servlet or plugin can spend nearly all its time waiting for another resource.
The most important thing is the design of your software. A well-written Servlet can be far faster than a poorly written C or C++ program, however it is invoked. Java makes complex topics like network access and multi-threading very easy to use, so it's generally much easier to design a Java program well.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic