A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service
Joe said in his blog that in general, the purpose of performance testing is to try to prove that one party is faster than the other party. I am employed by Microsoft and write both PHP and ASP. NETCode. I used PHP before. net. I like it very much.
Therefore, it is difficult for me to tell which one is better. When I talk about PhP, my Microsoft colleagues will write a letter to criticize me. When I post comments that tend to be ASP. NET, my PHP friends will say that I am the trust of Microsoft.
I did this test because everyone has their own opinions on PHP performance (Windows vs. Linux & 5.2 vs. 5.3), but no one can give clear data.
The test environment for ASP. net php is as follows:
* All tests are run on the same machine (with 4 GB memory and 60 GB hard drive Toshiba tecra M5 ).
* Ubuntu 9 and Windows Server 2008 Standard versions are installed on independent (but identical) hard disks.
* Apache2 is used in Linux, and IIS 7 is used in Windows as their respective web servers.
* The operating systems of both parties have completed patches or upgrades.
* No additional performance enhancement is performed on both systems and runtime.
From the experiment results, PHP has different performance in Linux and Windows:
* Pure statement execution performs better on Windows.
* Function calls are faster on Windows.
* Object creation and access are faster for PHP 5.2 on Linux, but faster for PHP 5.3 on Windows.
* Class library calls are much faster on Linux (for example, encryption on Ubuntu is 3 to 5 times faster than that on Windows ).
Comparison between Linux and Windows Platforms
The file access performance in Linux is slightly higher than that in windows, but the file replication performance in Windows is 60% slower than that in Linux, probably because of the advanced ACL security.
Accessing MySQL on Linux is much faster than that on Windows, and running PHP 5.3 on Windows is worse (but from the perspective of postgresql below, this should be due to poor implementation ).
PostgreSQL's performance on the two platforms is very close (the gap between 1000 operations is less than 0.06 seconds)-whether it is Php 5.3 or PHP 5.2, Windows performance is slightly better.
On Windows, the performance of PHP 5.2 to access ms SQL Server is slightly inferior to that of MySQL on Linux (at this time, SQL Server for PHP 5.3 is not supported ).
For pure PHP Execution performance, Linux and Windows are almost the same, which will not be the decisive factor for choosing Linux or windows as the deployment platform. If you are building an application, PostgreSQL may be a better choice. Because it performs well on both platforms.
If your application must use MySQL, you need to plan the scalability before selecting windows (I personally think Sun is unlikely to optimize MySQL performance for Windows ).
The SQL Server Driver in the first PHP version is slower than MySQL or postpresql, but this should not be a problem. The drive of the second version is under development, which will improve the performance.
In Joe's view, the PHP and IIS teams have been doing very well in terms of execution performance. Next, we need teams of open-source programs (Drupal, WordPress, joomla, etc) optimized the performance of each platform.
However, in addition to file replication, ASP. NET outperforms PHP in terms of performance (whether deployed on Linux or Windows ):
Access to MySQL on Linux is slightly better than access to SQL Server on Windows (using common data types and select statements ). However, the gap is almost negligible.
ASP. NET (C #) operations, such as object usage and class library calls, have far higher performance than PHP. For this test result, Joe added:
I know some of my PHP friends and Linux guys are about to jump out and refute my tests and results.
I have been thinking about whether to add some advanced Optimization Options for such performance comparison. However,. Net also supports multithreading, asynchronous requests, and various caching methods.
Please note -- I didn't say "ASP. NET is faster, so you shouldn't use PHP !", In my opinion, PHP is too simple to make it difficult for some advanced applications, just like ASP. NET will have learning complexity in the early stage of the project.
For me, the most exciting thing about PhP is not its language/platform, but thousands of smart PHP developers, and a variety of excellent projects (such as Drupal, joomla, WordPress, phpBB, nuke, etc ).
So we can think that the performance of PHP on Windows and Linux is at the same level. Now I can write PHP class libraries for Windows that I hope for many years.
Joe also published the test code. He said that if you have doubts about the test results, you can perform the experiment yourself or write your own test code for testing.
After the article was published, many netizens expressed their views on the test results. Joe basically replied to the main points one by one:
"I only use ASP. NET because I like Visual Studio ide" -- I personally think Visual Studio is the most productive development tool. However, PHP has a good choice. I use Zend studio, phped, Komodo, Delphi for PHP, and these are all very good. I hate eclipse, but Zend also makes a lot of extensions for PHP development.
Compare ASP performance-no, thanks. There is a big gap between the old ASP and the current PHP and ASP. NET. It seems that ASP is recommended to be used to develop a new project. I strongly recommend that you do not do this.
Comparison between 32-bit and 64-bit Systems
Comparison between 32-bit and 64-bit systems-these tests are not designed to reflect performance gaps in 64-bit systems. In future tests, I will add 64-bit scenarios.
"PHP is ugly"-oh, I don't agree. Old ASP is much more ugly. You can write terrible and ugly PHP code, and write ugly and terrible C # Or VB code. Similarly, you can write an elegant C ++ style PHP. This is only related to developers' skills.
Apache on windows should be used for testing-Apache is a Linux server, but I think that if you do not use IIS 7 on windows, too much will be lost.
"Is there a way to speed up file copy performance without compromising security in win2k8 ?" -- It does not seem to work. I think this involves the ACL system on the Windows server. In the future, I may test the performance of reading files through data streams, and the performance of some things may be improved. However, web applications generally do not program to copy a large number of files.
"PHP has always been, and it will always be a semi-professional environment. On the PHP platform, there are many professional, high-quality applications, and many highly respected developers. Whether it is professional is a problem for developers, not PHP or ASP. NET.
"I think PHP without opcode cache is unfair ,. net is compiled and executed, and PHP needs to explain and 'compile 'the page each time. I agree that this test may not be complete, but I do not agree with this logic. The Method for Testing PHP is the same as that for downloading and installing PHP. No op-code cache is installed on my VM. In fact, adding this feature to ASP. Net does not mean testing is unfair because PHP lacks this feature-but this requirement is reasonable and I am preparing a new test.
"It is unreasonable to say that PHP is not a 'professional 'language, because almost all of the largest websites are built using PHP."-this is not true, however, it is also wrong to say that those sites are "Almost all" built with PHP. Some are, some are not.
If you see this data, I am naturally very happy to have more confidence in ASP. NET. If I don't think. Net is a better choice for developing Web applications-at least not on other platforms, then I won't work at Microsoft.
But ...... If you ignore PHP because of this data, it is also a wrong and naive behavior.
From a purely technical perspective, I think. NET is far more powerful than PHP, but this does not mean PHP is not powerful enough. In my opinion, the power of PHP is embodied in a large number of applications and available frameworks.
About a week later, Joe published the results of the second test. Compared with the previous test, the second test has the following two major changes:
The op-code cache is installed for Linux and Windows, and most tests are re-run.
Due to some dependency problems, the testing platform of PHP 5.3 + APC has become the debain 5 Operating System.
For the second test and its results, Joe explains:
From the results, the performance gap between running PHP on Ubuntu and Debian is negligible. The performance of some items is slightly improved, while that of some items is 25%, but the overall performance is lower than I imagined.
After APC is used, the running of some items slows down, but I think this is only the error caused by the machine. Note that not the first result shown in the table is refreshed twice, and the result is obtained when the cache hits.
I think the current test is very fair.
Empty loop tests and empty function execution are very important because they reflect the basic consumption of languages or platforms. This is an important consideration for performance consumption outside of performance overhead such as page transmission.
Some of my PHP friends also agree on the accuracy of this test, but I am very insightful to add:
In addition, according to the results of the previous experiment, when running PHP on the Windows platform, there were some performance problems with MySQL and file access. Many Microsoft teams obtained relevant information from me. We hope this data can be converted into practical improvements.
Joe said he will collect test scenarios that everyone thinks are more fair and meaningful. The following are the testing projects he planned:
* Actual page test: cyclic, cold/hot calls, and object operations are a type of test, but the overall presentation of the page is another meaningful test.
* Load Testing: Which environment can process more requests at the same time.
* In the Server Load balancer, the performance of the Server Load balancer is decreased faster.
* In various situations, what is the performance of the 64-bit platform.
PHP performance tests on Linux and Windows platforms have also been conducted in China. At the wordcamp CHINA 2009 Conference, Microsoft announced the performance evaluation results of its cooperation with Kang shengchuangxiang: Running PHP on Windows Server 2008 + IIS, from the average time, the number of requests processed per second and the data throughput are much more convenient than the Linux + Apache hosting method.
Start building with 50+ products and up to 12 months usage for Elastic Compute Service