ASP. NET competition PHP, who is the king of speed? (1)

Source: Internet
Author: User
Tags sql server driver drupal

PHP, which has just made a historic breakthrough in the programming language ranking in September, is probably the most powerful opponent in the Web development field, namely ASP. NET Based on Microsoft. NET technology. Recently, Microsoft's Joe Stagner published a series of articles on the Performance of PHP and ASP. NET, which caused a lot of responses from programmers on both sides. Joe said he would continue this test and look for a more appropriate way to draw conclusions that are as valuable as possible for the actual project.

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 PHP and ASP. NET code at the same time. 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 views 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 run Toshiba Tecra M5 with 4 GB memory and 60 GB 7200 RPM hard drive on the same machine ).

◆ Ubuntu 9 and Windows Server 2008 Standard versions are installed on independent but identical hard disks.

◆ Apache2 for Linux and IIS 7 for 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 on Windows is better.

◆ 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 in 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 Windows, and running PHP 5.3 on Windows is worse. However, from the perspective of PostgreSQL below, this should be due to poor implementation ).

PostgreSQL's performance on the two platforms is very close to the gap of 1000 operations within 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 opinion, the PHP and IIS teams have achieved great success in terms of execution performance. Next we need the open-source program teams Drupal, WordPress, Joomla, and so on) 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 ):

The performance of accessing MySQL on Linux is slightly better than that of accessing SQL Server on Windows using common data types and SELECT statements ). However, the gap is almost negligible.

ASP. NETC #) 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.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.