posted 25 years ago
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.