Please welcome our newest regular GJ blogger: The Blackdood
Ooooo! fight! fight! fight!.
This is a fight that has been going on for as long as I can remember. Some say Java is too heavy, some say PHP is too light. I'm here to tell you how it is.
To be fair, I was first a Perl programmer, and that didn't last long. I then moved to PHP3. I was a PHP developer up until about a year ago, straight through PHP5. Now, I develop for both. I have managed teams of both PHP developers and Java developers, and developed large scale applications in both.
PHP has come a long way since the days of version 3. The new object model is a step in the right direction, and OO programming is no longer as big of a performance hog. As a result, a ton of PHP frameworks have started popping up. The one I've used the most is Symfony ( http://www.symfony-project.com), it's basically a port of RoR. The Java framework I am using is WebWork ( http://www.opensymphony.com/webwork/).
This is the first article of many to come. This first one will cover VERY basic performance results, and we'll get more detailed as time goes on and users request. What I will be focusing on is ACTUAL development with, not the actual benchmark results
Now, let's get the numbers out of the way. I did some minor benchmarking, but we all know that benchmarks don't really prove much as it can EASILY be swayed in one direction or another. These are just very basic operations, not going to benchmark the frameworks because that's unfair. I'll explain why later.
I tested : Apache Webserver + mod_php5 and Zend vs Resin 3.0.19 w/ JDK5 on a Dual Core Intel Mac 1.5 gigs of RAM.
For testing I used ab (apachebench) which comes default with every apache installation. Basically a "dumb" client that hits a URL as fast as it can.
The command was:
ab -c 50 -n 10000
Which means, do 50 requests at a time, and complete 10,000 requests. This test isn't exactly the best because it's not really doing anything. Really only testing who can loop faster. Results are interesting though.
The scripts:
JSP:
PHP<%
for(Integer i =0; i < 10000; i++)
{
out.println((i % 10));
}
%>
PHP Results:
for($i =0; $i < 10000; $i++)
{
echo $i % 10;
}
?>
260.68 requests per second. Took 38 seconds to service 10000 requests (50 concurrent users at a time)
/resin/webapps/benchmarks jgagner$ ab -c 50 -n 10000 http://localhost/~jgagner/benchmark1.php
This is ApacheBench, Version 1.3d <$Revision: 1.73 $> apache-1.3
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Finished 10000 requests
Server Software: Apache/1.3.33
Server Hostname: localhost
Server Port: 80
Document Path: /~jgagner/benchmark1.php
Document Length: 10000 bytes
Concurrency Level: 50
Time taken for tests: 38.361 seconds
Complete requests: 10000
Failed requests: 0
Broken pipe errors: 0
Total transferred: 101834793 bytes
HTML transferred: 100161954 bytes
Requests per second: 260.68 [#/sec] (mean)
Time per request: 191.80 [ms] (mean)
Time per request: 3.84 [ms] (mean, across all concurrent requests)
Transfer rate: 2654.64 [Kbytes/sec] received
Connnection Times (ms)
min mean[+/-sd] median max
Connect: 0 19 28.6 4 166
Processing: 9 171 102.5 163 1117
Waiting: 0 170 102.9 162 1116
Total: 9 190 101.8 173 1117
Percentage of the requests served within a certain time (ms)
50% 173
66% 208
75% 233
80% 250
90% 298
95% 386
98% 490
99% 543
100% 1117 (last request)
JSP results:
Wow, amazing isn't it!? Remember kids, benchmarks don't always tell the whole story. We'll find out why next episode. If you have any comments or suggestions you may write me, jerome AT blackdood DOT com.1010.61 requests per second, or 9.85 seconds to service 10,000 requests (50 at a time)
/resin/webapps/benchmarks/WEB-INF jgagner$ ab -c 50 -n 10000 http://localhost:8080/benchmarks/benchmark1.jsp
This is ApacheBench, Version 1.3d <$Revision: 1.73 $> apache-1.3
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Finished 10000 requests
Server Software: Resin/3.0.19
Server Hostname: localhost
Server Port: 8080
Document Path: /benchmarks/benchmark1.jsp
Document Length: 20000 bytes
Concurrency Level: 50
Time taken for tests: 9.895 seconds
Complete requests: 10000
Failed requests: 0
Broken pipe errors: 0
Total transferred: 202307479 bytes
HTML transferred: 200116165 bytes
Requests per second: 1010.61 [#/sec] (mean)
Time per request: 49.47 [ms] (mean)
Time per request: 0.99 [ms] (mean, across all concurrent requests)
Transfer rate: 20445.42 [Kbytes/sec] received
Connnection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 1.5 0 26
Processing: 5 49 44.8 46 618
Waiting: 2 48 44.8 45 617
Total: 5 49 44.7 46 618
Percentage of the requests served within a certain time (ms)
50% 46
66% 49
75% 51
80% 52
90% 60
95% 86
98% 203
99% 313
100% 618 (last request)
Holla back, youngin.
Blackdood