Alvin These figures don't surprise me a great deal. There are several factors at work here: *JVM performance( Servlets always have to contend with the performance of the JVM they are run on. Some of the new JVMs, eg: Htospot do make a substantial difference to performance. *Architecture* PHP remember perfoms a much more restrictive task, it is essentially a template processing language and not a generic tool for designing any kind of web based application. Some of the advantage of servlets comes from this flexibility. *Your test environment* I haven't done these kinds of test myself but similar tests were done by Michal Mosiewicz with Apache Jserv and Apache mod_perl and they showed that servlet were quicker than mod_perl. I was incredibly surprised by that but as Michal pointed out to me at the time use the right tool for the right job. It may be that servlets scale better than PHP, it looks like you're only throwing 20 simulataneous connections at your test bed, I work on a servlet based project for BT where we throw over 100 simultaneous conenctions at our system. *General performance* There is also the issue of per-connection creation. Admittedly this is a problem for all web tools but with Java's machine abstraction it helpds to have neat tricks to get out of things. For example, could you not create the GeorgianCalendar at init() rather than per connection and have some sync'ed code to update it and pull info out? Things like this this _might_ have a significant effect. Hope that helps. Nic Ferrier Tapsell-Ferrier Ltd www.tapsellferrier.co.uk >>> "Alvin, lau" <[EMAIL PROTECTED]> 7/10/99 4:33:23 PM >>> hi, I wrote a page with php and servlet and tried to compare their performance. I tried all the methods (using connection pool, even cache the whole page), to improve to the performance of servlet, but it still slower than php. I read a lot of articals about servlet, and they all say that servlet is faster than cgi. Can anyone tell me why? ps:I cannot post the source code here, exceeds 300 lines. check out my page for more detail. http://achilles.stachanov.com/~alvin/lab/phpvsservlet/ ( I put all the source code there). result (tested with suse linux 6.1, blackdown jdk1.1.7, jserv 1.0b5, mysql, mm jdbc driver , php3 and jmeter(random delay with gaussian distribution, average delay=300, dalay deviation=100.0)): 1, just display a date: php->average 175 ms, servlet->average 178 ms 2, Get data from mysql and format a new page: php->average 175 ms, servlet->average 241 ms (why average time of php does change?????) 3, Using Connectionpool, servlet->average 232 ms servlet (Use StringBuffer first, and then pw.println(buffer.toString())->average 220 ms servlet (cache the whole page) -> servlet 185 4, change the no of threads in JMeter to 20, php->average 190 ms, servlet->average 546 ms .....Why????? What wrong? Anyone did this type of test before? Is it the problem of jdk, jserv or.....? How can I improve the preformance? If I have to use linux, is that mean I better use php? Php is easy to use and runs faster. alvin ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
