Asp. NET compete PHP, who is the king of speed?

Source: Internet
Author: User
Tags empty file copy sql server driver mysql php class php and drupal zend
One of the most likely opponents of PHP in the field of web development, which has just made a historic breakthrough in the September programming language rankings, is the asp.net based on Microsoft. NET Technology. Recently, Microsoft's Joe Stagner published a series of articles on blogs comparing PHP and asp.net performance, causing a lot of responses from both programmers.

Joe said he would continue the test and look for a more appropriate way to reach conclusions that would be as valuable as possible to the actual project.

In general, the goal of performance testing is to try to prove that one side is quicker than the other, Joe said in his blog. I'm employed by Microsoft, and I write PHP and asp.net code. I'm here. NET before the advent of the use of PHP, two things I like.

So I can't say which is better. When I say good things about PHP, my Microsoft colleagues write to criticize me, and when I publish a preference for asp.net, my php friends will say that I am Microsoft's.

I did this test because everyone has a view of PHP's performance (Windows vs. Linux & 5.2 vs. 5.3), but no one can give you any specific data.

Asp. NET Competition PHP test environment is as follows:

All tests are run on the same machine (Toshiba Tecra M5 with 4G RAM and 60G 7200-turn drives).

The Ubuntu 9 and Windows Server 2008 Standard editions are installed on separate (but identical) hard drives.

Linux uses Apache2,windows to use IIS 7 as its own Web server.

Both sides of the operating system are fully patch or upgraded.

Both systems and runtimes do not perform additional performance enhancements.

From the experimental results, PHP performance in Linux and Windows have a few advantages:

Pure statement execution performs better on Windows.

function calls are faster on Windows.

object creation and access, for PHP 5.2来 said on Linux faster, but for PHP 5.3来 said it is windows faster.

Class library calls are much faster on Linux (such as encryption on Ubuntu is 3 to 5 times times faster than Windows).

Linux vs. Windows platform

Accessing file performance on Linux is slightly higher than Windows, but the performance of file replication on Windows is 60% slower than Linux, possibly because of high ACL security.

Accessing MySQL on Linux is a lot faster than Windows, and running PHP 5.3 on Windows is even worse (although this should be a bad implementation from the PostgreSQL below).

PostgreSQL's performance on two platforms is very close (1000 operating gaps within 0.06 seconds)-both PHP 5.3 and PHP 5.2,windows are slightly.

Windows PHP 5.2 Access to MS SQL Server is less performance than accessing MySQL on Linux (there is no SQL Server support for PHP 5.3 at this time).

For pure PHP performance, Linux is the same as Windows, which is not the deciding factor in choosing Linux or Windows as a deployment platform. If you are building an application, then PostgreSQL may be a better choice. Because it's excellent on two platforms.

If your application must use MySQL, then choosing Windows requires early planning extensibility issues (personally think Sun is unlikely to optimize MySQL's performance for Windows).

PHP's first version of SQL Server driver is slower than MySQL or postpresql, but this should not be a problem. A second version of the drive is under development, which can lead to performance improvements.

In Joe's view, overall, the PHP and IIS teams have been very successful in performing performance, and the next step is to optimize the performance of the various Open-source programs (Drupal, WordPress, Joomla, and so on) for each platform.

However, in addition to file copy operations, ASP. NET's overall performance ahead of PHP (whether deployed on Linux or Windows):

The performance of accessing MySQL on Linux is slightly better than the performance of accessing SQL Server on Windows (using normal data types and SELECT statements). But the gap here can be almost negligible.

Asp. NET (C #) operations, such as object use, class library invocation, and so on, have a much higher performance than PHP. For the test results, Joe added:

I know some of my php friends and Linux guys are going to jump out and refute my tests and results.

I've been thinking about whether this performance comparison needs to add some advanced optimization options. But. NET aspects, such as multiple threads, asynchronous requests, and various caching methods can be used

Please note-I did not say "ASP." NET faster, so you should not use php! "I use the view that PHP is too simplistic to be a bit difficult for some advanced applications, just as ASP.net has a learning complexity early in the project.

For me, the most exciting part of PHP is not its language/platform, but the thousands of smart PHP developers, as well as a variety of excellent projects (such as Drupal, Joomla, WordPress, PHPBB, nuke, etc.).

You can think that PHP is on the same level of performance on Windows and Linux that I can now finally write a PHP class library for Windows that I've been looking forward to for many years.

Joe also exposes the test code. If you have doubts about the results of this test, he says, you can do the experiment yourself, or write your own test code to test it.

After the article was published, many netizens expressed their views on the test results. Joe basically replies to one of the main ideas:

"I use asp.net just because I like the Visual Studio IDE"--I personally think that Visual Studio is the most productive development tool. However, PHP has a good choice. I use Zend Studio,phped,komodo,delphi for PHP, which is pretty good. I hate eclipse, but Zend has also done a lot for PHP development in this area.

You should compare the performance of ASP--No, thank you. Old-style ASP and the current PHP and ASP.net gap is too big. Making this comparison seems to suggest using ASP to develop new projects, and I strongly recommend that you do so.

32-bit versus 64-bit system comparison

Comparison between 32-bit and 64-bit systems-the purpose of these tests is not to represent performance gaps on 64-bit systems. Next Test I will add 64-bit scene.

"PHP is ugly"--Oh, I don't agree. Legacy ASPs are much uglier. You can write very scary and ugly PHP code, or you can write ugly and scary C # or VB code. Also, you can write elegant C + + style PHP. It's all about developers ' skills.

You should use Apache on Windows to test--apache is a server on Linux, but I think if you don't use IIS 7 on Windows, you'll lose too much.

"Is there a way to speed up file replication performance without losing security in win2k8?" "--it doesn't seem to work. I think this involves the ACL system on the Windows Server. I might later test the performance of reading files through the data stream, and some things might improve performance. However, Web applications typically do not program to replicate a large number of files.

"PHP has always been, and always will be, a semi professional environment"--this Dog. There are many professional, high-quality applications on the PHP platform, as well as a lot of developers who I respect very much. Whether professional is a problem for developers, not PHP or asp.net.

"I don't think it's fair to compare php without opcode caching," he said. NET is compiled, and PHP needs to explain and ' compile ' the page every time--I agree that the test may not be complete, but I don't agree with that logic. The way I test PHP is the way it is downloaded and installed. My virtual host also does not have the Op-code cache installed. And in fact, ASP. NET does not mean that the test is not fair, because PHP is missing this feature-but this is a reasonable request, I am preparing a new test.

"It doesn't make sense to say that PHP is not a ' professional ' language, because almost all of the biggest sites are built in PHP"--that doesn't make sense, but it's also wrong to say that sites are "almost always" built in PHP. Some are, some are not.

If you have seen this data, I am naturally glad to have doubled confidence in asp.net. If I don't think. NET is a better choice for developing a Web application-at least not on other platforms, so I won't be working at Microsoft.

But...... If you ignore PHP because of this data, it is also a mistake and naïve behavior.

From a purely technical standpoint, I think. NET is far more powerful than PHP, but that doesn't mean PHP isn't strong enough. In my opinion, the power of PHP is embodied in numerous applications and the framework available.

About a week later, Joe disclosed the results of the second Test. Compared to the previous test, the second Test mainly has the following two changes:

Installed the Op-code cache for Linux and Windows, and rerun most of the tests.

Due to some dependency problems, the PHP 5.3 + APC test platform has become the Debain 5 operating system.

For the second Test and its results, Joe explained:

As a result, the performance gap between running PHP on Ubuntu and Debian can be negligible. Some of the entries have slightly improved performance, while others have a 25% improvement, but overall the effect is lower than I expected.

After using APC, some items run slowly, but I think this is just the error caused by the machine. Note that the table does not display the first result, it is refreshed two times, and is confirmed to be the result of a cache hit.

I think the test now is very fair.

Empty loop tests and empty function executions are important because they reflect the underlying consumption of a language or platform. This virgin page transfer performance overhead is an important consideration for performance consumption.

Some of my PHP friends agree with the accuracy of this test, but offer a very insightful addition:

Asp. NET performance leadership will not have any effect on me. PHP is my favorite, my application is fast enough. Yes, ASP. NET is relatively fast on the basis of performance, but my application can make up this part of the performance with excellent page implementation and JavaScript practice.

In addition, according to the results of the last experiment, when running PHP on the Windows platform, there are some performance problems in MySQL and file access, and many of Microsoft's teams have obtained relevant information from me. It is hoped that these data will be translated into tangible improvements.

Joe says he will collect test scenarios that are considered fairer and more meaningful. The following is the test project he planned:

Actual page test: loop, thermometer call and object operation is a kind of test, but the overall presentation of the page is another meaningful test.

Load test: Which environment can handle a larger number of requests at the same time.

In a load test, which side of the performance will fall faster.

In all cases, the performance of the 64-bit platform.

In China, PHP has also been tested on Linux and Windows platform performance. Infoq has reported that Microsoft has published a performance evaluation with Kangsheng in WordCamp's 2009 conference: Running PHP on Windows Server 2008 + IIS, from the average corresponding time, the number of requests processed per second, and data throughput and so much more convenient than the Linux + Apache hosting mode.



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.