PHP versus ASP.NET – Windows versus Linux
How does IMPLEMENTATION Performance Compare ?
Usually, when someone creates benchmarks, they are trying to prove that their thing is faster than someone else's thing.
I’m PAID by Microsoft to write BOTH PHP and ASP.NET Code. I was doing PHP before .NET shipped. I love them both.
This makes it hard for me to say anything good about either one. When I confer a preference for something in PHP, my Microsoft peers send me flame mail and when I confer a preference for something in ASP.NET, my PHP friends come out of the woodwork to call me a Microsoft shill.
I started building and running these tests because everyone had opinions about comparative PHP performance (Windows versus Linux & 5.2 versus 5.3), but no one had any solid data.
So, I decided to collect some empirical evidence of my own.
Before you look at them, let m e provide some method details and context.
All tests were run on the SAME Machine.
A Toshiba Tecra M5 with 4 Gig of ram and a 60 Gig 7200 RPM Hard Drive.
Ubuntu 9 and Windows Server 2008 Standard were natively installed on 2 separate (but identical) hard drives.
The web servers were Apache2 on Linux and IIS 7 on Windows.
Both operating systems were fully patched / updated.
No Operating System or Development Runtime performance enhancements were added.
I wasn’t investigating how much speed an expert could custom tailor the tests to on a specific platform.
Yes, I could implement PHP Byte Caching, or for ASP.NET I could use Page Caching, Partial Page Caching, SQL Cache Dependency, Multi Threading, etc.
Both Windows and Linux Implementations of PHP will benefit from PHP Byte Code caching.
My goal was to determine the relative speed of THE IMPLEMENTATION.
I found the results both interesting and unexpected.
PHP on Linux Versus PHP on Windows…..
I really though one would just be faster than the other, but I was wrong. Some things are faster on Windows, other are faster on Linux.
- RAW statement execution seems faster on Windows.
- Function Calls were faster on Windows
- Object Creation / Access was faster on Linux with PHP 5.2 but faster on Windows with 5.3
- Library calls were faster on Linux. (Example: Encryption 3-5 times faster on Ubuntu.)
- File Access is faster on Linux by a small percentage, except for file copy operations which was as much as 60% slower on Windows probably due to the ACL advanced security.
- MySQL access with Linux is faster by more than a little and on Windows, MySQL access deteriorates in version 5.3 (This seems to be poor implementation, see PostgreSQL below.)
- PostgreSQL performance is very close on both platforms (within 6/100 of a second for 1000 Operations) – It’s faster on Windows and faster still on Windows with PHP 5.3
- MS SQL Server access from PHP 5.2 on Windows is marginally slower than MySQL access on Linux. (PHP 5.3 not yet supported at the time of this writing.)
So what does all that mean ?
- We can probably say that in terms of raw execution – performance on Linux versus Windows is probably a wash (more or less equivalent) so that the performance of PHP itself becomes a moot factor in choosing Linux or Windows for PHP application deployment.
- If you are building an application, or running an application that supports it, PostgreSQL might be a better database choice since it performs pretty much the same on Windows and Linux.
- If you are running an application that locks you in to Sun Microsystems’ MySQL and you want to run it on Windows, your should do scale planning. (My personal guess is that it’s unlikely that Sun will markedly improve MySQL performance on Windows. )
- Version 1 of the PHP Driver for SQL Server (V2 is in the works) is somewhat slower than MySQL or PostpreSQL but probably not enough to discourage use where diverse developer access is desired. (v2 ot the driver will improve performance. )
By and large I think the PHP team and the Microsoft IIS team have accomplished good raw performance equivalence across platforms. (Now we just need to get the Open Source Application teams (Drupal, WordPress, Joomle, etc.) to do performance optimization on both !)
PHP versus ASP.NET Raw Performance …..
By now you have cheated and looked at the spread sheet.
Yes, ASP.NET is universally faster than PHP (on Windows and on Linux) with the exceptions of File Copy and Attribute operations.
MySQL Access from PHP on Linux is a TINY bit faster than SQL Server access on Windows (assuming common data types and SELECT statements) but probably not enough to matter.
ASP.NET (C#) operations, object use, library calls, etc. are SIGNIFICANTLY faster that the PHP equivalents.
I know my PHP friends and the Linux dudes (and dude-etts) will probably come out of the wood work to refute my tests and results :)
I’ve always thought that if high end performance options were part of your needs requirements, then .NET programming has some advanced options “out of the box” like multi-threading, asynchronous requests, and a number of caching options.
NOTE – I’m not saying “ASP.NET is Faster so you shouldn't choose PHP !!!! I’ve always contended that the affable simplicity of PHP had some drawbacks for certain advanced applications. (Just as the early learning complexity of ASP.NET can have it’s drawbacks. )
To me (your mileage may vary) the exciting thing about PHP is not the language / platform so much as it is what thousands of clever PHP Developers have done with it (Drupal, Joomla, Wordpress, PHPBB, Nuke, etc.)
In any event, it’s nice to now have some data that PHP performance on Windows and Linux are “in the same ballpark”.
Now I can start writing those Windows specific PHP libraries I’ve been dreaming about for years !!
Posted in: General asp.net | Tags: asp.net php windows linux implementation performance compare windows versus linux sql server postgresql ms sql server mysqlCOMMENT WARNING
- I know some will be incensed by these tests. You are welcome to comment and disagree, but if you can't be polite I’ll simply delete your comments and block your IP address.
- If you dislike the results and want to refute them – DO THE WORK. Accompany your dissent with DATA. Take my code or write your own and argue with FACTS.
55 screening questions for Windows admin
- What is Active Directory?
- What is LDAP?
- Can you connect Active Directory to other 3rd-party Directory Services? Name a few options.
- Where is the AD database held? What other folders are related to AD?
- What is the SYSVOL folder?
- Name the AD NCs and replication issues for each NC
- What are application partitions? When do I use them
- How do you create a new application partition
- How do you view replication properties for AD partitions and DCs?
- What is the Global Catalog?
- How do you view all the GCs in the forest?
- Why not make all DCs in a large forest as GCs?
- Trying to look at the Schema, how can I do that?
- What are the Support Tools? Why do I need them?
- What is LDP? What is REPLMON? What is ADSIEDIT? What is NETDOM? What is REPADMIN?
- What are sites? What are they used for?
- What’s the difference between a site link’s schedule and interval?
- What is the KCC?
- What is the ISTG? Who has that role by default?
- What are the requirements for installing AD on a new server?
- What can you do to promote a server to DC if you’re in a remote location with slow WAN link?
- How can you forcibly remove AD from a server, and what do you do later? • Can I get user passwords from the AD database?
- What tool would I use to try to grab security related packets from the wire?
- Name some OU design considerations.
- What is tombstone lifetime attribute?
- What do you do to install a new Windows 2003 DC in a Windows 2000 AD?
- What do you do to install a new Windows 2003 R2 DC in a Windows 2003 AD?
- How would you find all users that have not logged on since last month?
- What are the DS* commands?
- What’s the difference between LDIFDE and CSVDE? Usage considerations?
- What are the FSMO roles? Who has them by default? What happens when each one fails?
- What FSMO placement considerations do you know of?
- I want to look at the RID allocation table for a DC. What do I do?
- What’s the difference between transferring a FSMO role and seizing one? Which one should you NOT seize? Why?
- How do you configure a “stand-by operation master” for any of the roles?
- How do you backup AD?
- How do you restore AD?
- How do you change the DS Restore admin password?
- Why can’t you restore a DC that was backed up 4 months ago?
- What are GPOs?
- What is the order in which GPOs are applied?
- Name a few benefits of using GPMC.
- What are the GPC and the GPT? Where can I find them?
- What are GPO links? What special things can I do to them?
- What can I do to prevent inheritance from above?
- How can I override blocking of inheritance?
- How can you determine what GPO was and was not applied for a user? Name a few ways to do that.
- A user claims he did not receive a GPO, yet his user and computer accounts are in the right OU, and everyone else there gets the GPO. What will you look for?
- Name a few differences in Vista GPOs
- Name some GPO settings in the computer and user parts.
- What are administrative templates?
- What’s the difference between software publishing and assigning?
- Can I deploy non-MSI software with GPO?
- You want to standardize the desktop environments (wallpaper, My Documents, Start menu, printers etc.) on the computers in one department. How would you do that?
- What do you do to install a new Windows 2003 DC in a Windows 2000 AD?