test Environment:
Ubuntu 14.04 with i5-3230m
Tomcat 8.0.5 with 64bit jre1.7.0_55
PHP 5.5.8 with Zend Opcache V7.0.3-dev
test Script: Displays the current server time
Java tomcat:t.jsp
<%@ page session= "false" pageencoding= "UTF-8" contenttype= "text/html; Charset=utf-8 "%><! DOCTYPE html>
PHP CLI server:t.php
<?php header (' Content-type:text/html;charset=utf-8 ');? ><! DOCTYPE html>
TASKSET-PC 1 ' pgrep java ' binds Java processes to CPU1
Taskset-p ' pgrep Java ' to view CPU usage after binding
Taskset-c 1 php-s 127.0.0.1:8081-t/png/www/bind PHP process to CPU1 and start
Taskset-p ' pgrep php ' to view CPU usage after binding
Warm yourself up First:
Curl-i http://127.0.0.1:8080/t.jsp
Curl-i http://127.0.0.1:8081/t.php
bind siege to CPU0, concurrent 100, for 10 seconds, to test Java Tomcat:
Taskset-c 0 siege-c100-t10s http://127.0.0.1:8080/t.jsp
java Tomcat load CPU usage (%CPU) for Java processes:
Pidstat-p ' pidof Java ' 1
Java Tomcat Pressure measurement system CPU idle rate (%idle):
SAR 1
bind the siege to CPU0, concurrent 100, for 10 seconds, to load the PHP CLI Server:
Taskset-c 0 siege-c100-t10s http://127.0.0.1:8081/t.php
PHP CLI Server CPU Utilization (%CPU) for PHP process:
Pidstat-p ' pidof php ' 1
CPU Idle rate (%idle) of the PHP CLI Server during pressure measurement:
SAR 1
Java Tomcat vs PHP CLI Server test data comparison:
|
Java Tomcat
|
PHP CLI Server
|
Memory consumption before test (MB)
|
93.4
|
20.0
|
Memory consumption after test (MB)
|
185.2
|
20.5
|
Process CPU usage (%CPU, the smaller the better)
|
Approx. 300%
|
Approx. 95%
|
System CPU Idle value (%idle, the bigger the better)
|
Approx. 7%
|
Approx. 46%
|
Number of processing requests per second (Transaction rate, the bigger the better)
|
5376
|
6878
|
Description: i5-3230m Dual Core Four thread,%CPU maximum value can reach 400%.
PHP has built a web Server from 5.4.0 to facilitate phper testing and development, and Linux is a single-threaded application, so the CPU usage of the PHP process is always under 100%.
And Tomcat is a multithreaded Java application, CPU consumption is very strong, high peak even 330%!
PHP test after the memory only up 0.5MB, and Java process memory up 1 time times, memory fluctuation is very large, up to 180 MB, PHP memory consumption of more than 9 times times!
PHP CLI Server has more processing requests per second than Java Tomcat1500, while memory and CPU usage is much smaller than Java Tomcat, is Java too low-energy, or PHP very fast?
Java Tomcat vs PHP CLI Server performance Comparison