NOTE: This is “Misfit Data” – While I do work for Microsoft, this data is NOT “official Microsoft” data and is not endorsed or ratified by Microsoft in any way. I built and ran these tests because I was personally curious about comparative performance.
If these test results cause you dizziness, vomiting, or other undesired side effects, please discontinue use immediately and consult your physician.
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.
[ You can CLICK HERE to see the result spreadsheet. ]
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 !!
COMMENT 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.
You can look at the code here.
- PHP Perf Test – MySQL
- PHP Perf Test – PostgreSQL
- PHP Perf Test – SQL Server
- ASP.NET Perf Test
- SQL Database Setup
Anyway – hope some of you find this interesting.
Now let the frenzy begin !!





















RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Pingback from PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ? : Misfit Geek
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Pingback from PHP versus ASP.NET ??? Windows versus Linux ??? Who???s the fastest ? | ASP Scribe
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Pingback from PHP versus ASP.NET ??? Windows versus Linux ??? Who’s the fastest … | Webmaster Tools
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Pingback from PHP versus ASP.NET ??? Windows versus Linux ??? Who’s the fastest …
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Pingback from PHP versus ASP.NET ??? Windows versus Linux ??? Who’s the fastest …
"I know some will be incensed by these tests. You are welcome to comment and disagree, but if you can be polite I’ll simply delete your comments and block your IP address."
I guess I will have to be impolite to comment here
.
I assume you the versions of Ubuntu & Windows that were used were 32bit.
Is that correct?
Joe,
Thanks for this article. I found it most helpful, as I too am a "switch hitter" in that I develop projects in both ASP.net and PHP/MySQL. I agree that the folks who developed Drupal, Joomla and WordPress have done a great job using PHP to accomplish this.
If I had to choose, I would utilize ASP.net simply because I like the Visual Studio IDE experience. I’ve used Zend Studio and Eclipse and haven’t quite had the same success. My clients ultimately dictate what programming language to use based on their server environment. I’ve seen a lot of articles about how it’s better to focus on .Net or PHP but not both. However, I disagree because ultimately I need to meet client’s needs which might require the use of ASP.net for one project, and PHP for a different one.
Thanks Again!
"ASP.NET is universally faster than PHP (on Windows and on Linux)"
This is music to my ears. All these days, I was a bit guilty of not honing my PHP skills and bowed to .NET. Tonight it’s a good night sleep.
Great Joe.
Joe, thanks for the article and for sharing the tests you’ve made.
I have quite similar experience…
I have started working on PHP but ended up with ASP.NET because simply I feel the power which is above PHP.
I have personally made only few of the tests for which you already provided more detailed explanation and tests on your results spreadsheet and I don’t have anything to say except to strongly agree with the results you have achieved.
Anyway, I still love both ASP.NET & PHP because both these give me opportunity to work and accomplish great things, even though, I have always preferred ASP.NET before PHP.
Cheers
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Pingback from PHP versus ASP.NET ??? Windows versus Linux ??? Who’s the fastest …
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Pingback from PHP versus ASP.NET ??? Windows versus Linux ??? Who’s the fastest … | MySQL Security
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Pingback from PHP versus ASP.NET ??? Windows versus Linux ??? Who???s the fastest ? | I love .NET!
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Pingback from Seo Swap | | PHP versus ASP.NET ??? Windows versus Linux ??? Who’s the fastest ??? » Seo Swap |
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Pingback from Windows | All Days Long
Joe,
Thanks for the effort. Any chance you could compare mono against php as well?
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Pingback from PHP versus ASP.NET ??? Windows versus Linux ??? Who’s the fastest …
Beforehand i’d like to say that i’m not a fanatic, and, i’ve also tested alot of thing you already did, in different version along the last years.
I often find this comparisons to be a bit biased towards the expertise of the person testing it, if one is more proeficient with windows then the tests tend to favour windows, if the tester is more proeficient with linux it favours linux etc.
Thing is most of the time, people disregard several importan aspects while testing, making a test in a standard out of the box install of linux/apache/php/mysql/postgresql vs windows/iis/mysql/postgresql is not quite accurate, the hardware for starters should be the same, then, both operating systems / software should be configured for maximum performance (since that’s what a sane person would do in a production environment) and only then compare results. For instance, have you installed a PHP accelerator like APC ? or have you optimized Apache ? the same applied to windows obviously.
Out of the box benchmarks worth just that…
Good effort though.
Best regards
Just wanted to know what implementation of PHP you are using on windows: FastCGI or ISAPI?
Nice one. Is there a way where you can compare ASP with ASP.NET because many people like me have the doubt that Microsoft is killing ASP in the upcoming servers.
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
PHP vs ASP.NET, Linux vs Windows
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
PHP Vs. ASP.net on Linux and Windows
Thanks for performing tests. These are quite useful.
There are few things I would like to know like how PHP in IIS configured, if FastCGi than version of FastCGI. Are OSes 32-bit or 64bit?
It would be better if Ubuntu with PHP 5.3 is also tested.
Have you ever tested asp.net on windows and linux?
–
Thank you
Sharique
PHP is ugly like hell. ASP.NET RULZ!!! Long live .NET. Long live C#
Hi Joe,
I would have loved to seen how classic ASP performed against it’s big brother ASP.Net on Windows Server 2008.
Andrew
interesting!
Hi friends,
I am using ASP.Net and never known to php and dont even like to be switched as I am quite comfort on windows platform. But as a freelancer when I see online projects, I always found php products are many more than ASP.Net. So I think as I freelancer I have less opportunity.
This is very painful. As ultimate object of learning ASP.Net for me is to earn money.
What you think.
Thanks & Best Regards
Jay Khatri
I have in the past worked with ASP with MSAccess/SQL Server, PHP with MYSql and ASP.NET with SQL Server.
I also did some simple tests back when ASP.NET was v1.1. I noted that with ASP and PHP, PHP was generally faster. With ASP.NET and PHP, .NET was faster but not greatly. This was before I really knew what I was doing too.
I like all 3, although if given a choice I would always go the .NET route. I never used visual studio – I was using Macromedia/Adobe Homesite for coding. I now use Studio 2008 exclusively for coding although Homesite had some nice touches I still consider superior to any other editor, particularly its extensibility via JScript and user-defined forms.
I probably would use PHP over ASP, but ASP.NET over PHP. I really dislike MySQL as it does weird things sometimes with queries and prefer stored procedures on SQL Server.
Thanks for doing this Joe. I rememeber attending a Mix ’08 IIS session where they were showing PHP test on IIS 7 showed signigicant perf increases over Apache. They said it was because IIS 7 provides a true multithreaded web server for PHP. I am not a LAMP person by any means, but that made sense because my LAMP friends always talk about scaling as adding more servers, ie more hardware. Can you speak to this sometime?
I always knew that… asp.net rox!
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Pingback from Dew Drop – August 6, 2009 | Alvin Ashcraft’s Morning Dew
Sharique,
Good questions. First, I didn’t test 5.3 becuase the Ubuntu package manager doesn’t include 5.3. I tried building 5.3 from source but it kept failing and the only pre built binaries I could find for 5.3 were Beta.
The OS versions were both 32 bit. Given that the test were single user and the macine wasn’t running anything else, I suspect tests would not be effected by 64bit.
The Windows 08, IIS 7, FastCGI was fully updated.
Joe
thank goodness .. backs up the assertion that one should chose the right tool for the right job. end of argument.
Adding a XAML/SilverLight comparison would be a good idea.
Good Article
Lloyd
A magazine to which I contribute articles recently did a PHP on win vs. Lin article and found that PH ran better on Linux than Windows. I was quite surprised by that knowing that PHP with FastCGI does have a number of optimizations on IIS7. Can you please take a look at let us know your thoughts on these results? The article is available at: pcquest.ciol.com/…/109070402.asp
Nice, I always thought asp.net was slower than php.
Now, I see, with good development practices, you can have a great performance at asp.net too.
Congratulation, excelent article
Vinod – this is typical of the stuff I found when I did my initial search. It’s simply a declaration that one is faster than the other. No share code or methodology. In my opinion that makes the article meaningless.
Is there a way to improve the performance of the file copy test on Win2k8 ASP.Net 2 without compromising security?
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Pingback from PHP versus ASP.NET ??? Windows versus Linux ??? Who???s the fastest ? | rapid-DEV.net
Let’s suppose for the moment that your numbers are in the general ballpark. (I think they probably are.) In an economically-challenged country like the USA, is this the question that really matters? To really make the two stand apart, isn’t it TCO that counts? Isn’t this the answer that CIOs are looking for?
To factor that all in, you’ve got to consider a gazillion things, like the development environment, RAD vs. RUP, startup hardware costs (must consider #users served over x amount of time, not just #users served at a snapshot in time), startup software costs, ongoing licensing costs, ongoing maintenance costs, developer availability, code comprehensibility, security costs, and on and on. This means that for different environments, the choice may vary. For the freelancer, it may be one choice, while the 10,000 employee enterprise IT staff may need a completely different choice (or choices.)
So, who’s going to step up and pull those numbers out of their hat? PHP vs .NET? Not my question, I can learn to code in anything, frankly. To have money or not to have money, that is the question. ‘Cuz that’s where the business is ultimately going to go, and that’s what I want to learn. Personally, I’ve seen firsthand the hidden costs of both Java and .NET in an Fortune 500 environment, and .NET still has my focus. Haven’t messed with PHP much yet; no incentive to do so. Make me see the value in the switch…
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Thank you for submitting this cool story – Trackback from DotNetShoutout
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Thank you for submitting this cool story – Trackback from progg.ru
Just to provide some numbers from my experience: I saw a team of 20 experienced developers from India (no 1st-timers) rewrite 50% of an existing application in 1 year for a cost of about $1M. Single request times were 2-3 seconds per page, when the existing system was under .5 seconds per page. It choked badly when they cranked up the user load in testing.
I could have easily redone the entire application by myself in .NET in the same amount of time, and guaranteed better response times. Assuming they finished the app in another year (I left the company disgusted with their choice, which I advised against), the total cost would be approaching $2M, for something I could have done for about 1/20th the cost with faster performance in .NET. Now you know why I prefer it. I have no reason to believe that PHP will be any better, especially given Joe’s numbers.
Granted, you could argue that the India team had a vested interest in running up the cost, but isn’t that what we are talking about here? TCO? They also had a vested interest in getting good response times to prove themselves valuable. I talked with them, they were smart guys. But the technology they used was very inadequate for the task, and the TCO was poorly calculated up front. And 40,000 end users paid a price as well. PHP may not suffer from the performance problem, but what about the TCO? That’s crucial.
ASP.NET: "Whose your daddy?!"
LAMP: "I’ll never join you!"
ASP.NET: "If you only knew the power of the .NET side."
LAMP: "My professor told me enough. He told me PHP was faster!"
ASP.NET: "No, I am your father."
LAMP: "No… No… That’s not true… That’s impossible!"
ASP.NET: "Search your feelings, you know it to be true"
LAMP: "NOOOOOOOOOOO!"
Hey Joe great article I was going to send you an email asking you about this om the same lines I,m a novice self taught novice
wannabe the gov. here in Canada has released a pile of training money for anyone affected by the recession I qualify for training money the only accredited courses I can find in B.C. Canada are open source drupal PHP and so on I wold like to learn ASP.NET with some credits since I have a passion for and have invested so much time I on ASP.NET Microsoft rules you guys are a great team so I have a two part question
1, if I do the PHP thing will it help me be better ASP.NET developer in the long run basically how much is related
2, Where could I get the equivalent training in ASP.NET in this part of the world
mildly interesting comparison. like always developers will find ways to make any platform shine or slow down using any random anti-pattern. what i would like to see is a good comparison on architecture in terms of how productive can i get. short term and long term. i have just started to play a bit with php to get a feel for what it can do since i dont have asp.net on my mac except virtually. i miss so many nice features from .net that i feel one quickly has gotten used to having. like linq and where are my telerik components ??
you mean i have to code all ajax code myself in php??
what is the key advantage of using php (technically not on price- price is irrelevant in this discussion) the whole infrastructure seem so bare. and what about mvc or some scaffolding structure like rail? seems it does not exist for php or only in tiny corner or php universe. would help to make an informed decision on using php for anything… my initial php trials tell me im better off learning objective-c on mac than web development, if im going to do any mac dev at all, since there is nothing that let me be as productive as i am in .net.
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Pingback from Windows Hosting or Linux Hosting? Which runs PHP Faster?
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Pingback from codegeeks » PHP versus ASP.NET ??? Windows versus Linux ??? Who???s the fastest ?
@Jay Khatri, Its true that PHP has more freelance projects. And I am glad that .NET doesn’t have them. You know why? Because those projects are piece of shi*t. I can tell 90% of them will never go live..they are cheap projects for some cheap people a way of making quick money. But .NET have big projects..that PHP devs can only dream of..In our country; an avarage .NET developer earns two to three times salary than an avarage PHP developer of same experience. So its easy to see the difference on basis of financial benefits.
I wont go comparing between these two. Because comparing .NET platform with PHP would be like comparing an ocean with my reservoir.
PHP has always been, and will always be, tailored to semi-professional environments. Anyone who does not get that… well does not get that.
Great tests Joe we appreciate your efforts. My though is that sometime you can afford a few milliseconds of performance loss to save you wallet. At the bottom of the chart i would add.
Ubuntu 9 (PHP 5.2)+ MySQL Win Server 08 ASP.NET 2 + MSSQL
FREE – (color green) $$$$ – Thousands – (color pink)
PHP is dead. Long live PHP!!!
I don’t think it’s fair to compare PHP without an opcode cache (like APC). It is included as part of the PECL, so it is a part of the PHP environment.
You can’t compare an opcode cache to page caching. .Net has the benefit of using bytecode, while PHP has to parse the file and "compile" for each page request. So you deny PHP the advantage that .Net has.
I know you can’t setup every type of caching solution. But adding APC would only put PHP on equal ground, since .Net already has something similar in the form of compiled byte code.
I make things in asp.net while I dabble in php. I use php projects (drupal, etc…) because they are free, numerous and quite often, though not always, of high quality. I know php enough to get around and to hijack the good ideas and put them in asp.net.
Hands down the reason I use asp.net is because of the IDE. PHP’s IDEs are jokes with no punchlines; they really, really suck. The second reason I asp.net is that the Windows technology stack is cohesive and well documented (Ubuntu is a great tack for the Linux community). On the other hand the Free stack seems to remain perpetually unfinished, unpolished and all the pieces to the puzzle are laying all over the place and documented in gibberish. It gives me motion sickness to think of starting from scratch on a Free stack.
Just one doubt, you said ubuntu 9 vs Window$ 2008 SERVER, wich flavour exactly of ubuntu 9.04? Desktop? or Server?
Please tell us!
Good tests Joe. Why no Perl comparison too?
@opus131. I call BS. "semi-professional", such a condescending attitude. If you don’t care to write code in PHP, say it. But don’t be a jerk about it.
I believe with the speed of hardware, and it’s relatively cheap cost, the difference in speeds with most things (.Net, PHP, Perl) are negligible. I think @nollkoll eluded to this, but the real question is your IT’s productivity. Given a given RFP spec for a project, can an experienced PHP, Perl, Ruby/Rails, Objective-C/{J} or .Net developer finish the project in the same time and have it operate in relatively the same speed?
I’m not sure if that question’s even answerable without a flame war. It’d be expensive to put on and I think it’d take some work to do fairly. But for me, that is the ultimate question.
For the record, I’ve written Objective-C, PHP, Perl and asp/vb/c#/.Net. Different tools for different jobs (employers, too). Each has it’s own rewards and each has it’s own irks. As long as someone’s willing to pay me a good buck I’ll write in, or learn, whatever language and/or framework they need me to write in for them.
"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"
For Sure, PostgreSQL is better with PHP.
MySql backup and restore features are very bad.
It’s all about business, if you keep your mind as a developer go ahead and cry like a baby "Mommy I want ASP.net" or "Mommy I want PHP", but if you are a professional software engineer you have to be technical in your choice, and manage the variables of your project, this is not a soccer game.
Custom Applications # ASP.NET
$CMS -> PHP
Regards.
Good Post!
Speed of execution of a web scripting language is so rarely a performance bottleneck that this discussion isn’t even worth having. For nearly every non-trivial web site, the bottleneck is at the network and database level, not in the speed of execution of the business logic and presentation script.
Cost/performance is a much more meaningful metric for all but the most trivial applications. And if you get around to doing that kind of test, you should probably account for the fact that it typically takes hours to set up and configure a Windows server (while most Linux sysadmins can do it in under 10 minutes).
Saying that PHP isn’t a "professional" language is just dippy, since nearly all of the largest web sites in the world today were built with PHP.
Not tweaking performance on both systems was a good choice for this test. Not everyone knows how to get the best performance out of their systems/code. Most developers I have come across don’t even care about performance. It’s really sad.
Why didn’t you use Zend Page Cache to negate that effect to bring it to an equal footing with ASP.NET?
Joe,
can you share which tools you used to do the benchmarks?
Thanks you solved my problem, becaz currently i am working in both PHP and ASP.NET and even in JSP. but personally i enjoy programming in ASP.NET and in JSP becaz becaz i love JAVA and C#.
People seriously want a comparison of ASP.NET to Classic ASP?! Compiled vs Interpreted! That’s why ASP.NET spanks PHP. You’ll never get me to go back to old school ASP… I’LL DIE FIRST!
Great tests! Long live .NET, long live C#!!!
Thanks Joe!
Scriptstar You are right.. Now I dont feel guilty when I see any PHP open source tools or web sites. .NET is the best.-:)
Nice work! It would be nice if you could add Mono 2.4 performance numbers.
I like asp.net/mvc, c#, visual studio, iis, sql server and windows server, and i have followed ms over 10 years, but when i plan to start a small business, i find i have not enougth $ to buy the ENVIRONMENTs, although maybe i can use the illegal soft of visual studio, sql server and windows server, but if i do so in my OWN business, i feel very sorry and uncomfortable, if i use the illegal soft, maybe some day, before i have made some money, i have lost my future.
as a c# developer, i really dislike the ugly php, but maybe i have to make a decision to use LAMP.
sigh…
if some day during my life, i luckly see the asp.net/mvc can fully run on linux/unix, or the ENVIRONMENTS are cheap enough for beginning companies, i will be happy.
<comment>if some day during my life, i luckly see the asp.net/mvc can fully run on linux/unix, or the ENVIRONMENTS are cheap enough for beginning companies, i will be happy<comment>
Mono now supports asp.net/mvc. Use mono and you will be.
I’m working with PHP at work exclusively (my boss is obsessed with the whole LAMP thingie). What can I say… this is the most annoying, weird, ugly, bugged bunch of crap. And some of the "great" open source projects? God! Typo3, osCommerce, blah blah… most of these projects are perfect examples of heavy spaghetti, anti-pattern software.
For my side projects, i’m not touching this so called "programming language".
(Who the hell will name a function mysql_real_escape_string? woot!)
Interesting, thanks. I would like to see a similar comparison for ASP.NET MVC vs. Ruby on Rails vs. Python/Django. -Chris
PS: Regarding your side-effects warning: What should one do if his erection lasts more than four hours?
@Will
Cause they don’t know how to use it properly mate. Guy even had problem with proper installation of PHP 5.3 on ‘Ubuntu’.
Well if you’d spent some time on the real, debian based linux server (-> yes I know, there’s no point and click
:D:D )and apply proper framework like CodeIgniter or ZF + mod_deflate you would notice difference in speed/development.
Shame all .NET developers are negative to language which makes websites more maintainable (yeah, even designer can do change & develop his skills without paying $$$ to anyone).
@Ozzy -> for last 4 years I’ve seen worst so called ‘custom tags’ from ASP.NET Developers, like <BETTER_NAVIGATION_GOES_HERE> or <CONTENT_BOT_L>. Right ….’encryption’ & ‘securing the code’ …but why is in the way that html will output it and be invalid.
Same stuff goes to VIEW_STATE -> what a piece of shit (sometimes so massive string, that’s ridiculous), like the session couldn’t be stored anywhere else but on website itself, right?
Costs: well no discussion here. Linux done well once will server years. Hosting is cheaper. Basically you’re paying for electricity & no licensing fees. RAD stands in LAMP for what it should be. RAD in .NET makes things not maintainable really.
@Exo
ViewState can be turned off on per control, per page, etc. basis. Not a big deal here. If you’re the dev, it is up to you to decide what storage you’ll use – viewstate, session, etc. And the html output… I can provide you with 100s php sites which do not validate at all too.
"Shame all .NET developers are negative to language which makes websites more maintainable".
I’m not exactly .NET dev. As I said, i’m working with both PHP and C#. Was working on C++ and Delphi projects. And recently started some Python. Among these, PHP is the worst thing i’ve touched ever. And ppl were laughing on VB6?
Oh, PHP sites are more maintainable? Out designers still have hard time to understand why the hell we’re using a weird templating language (Smarty) over another templating language (PHP).
To all: sorry for this offtopic reply.
@Ozzy
True, not every page, regardless to the language validates. But not every language works against you in this matter.
AFAIK quite experienced developers had a problem to agree sessions between ASP & .NET after turning ViewState.
I think PHP is more maintainable. Syntax isn’t weird as long as you have no programming preferences/fixations (it seems to me you have some strong ones).
Designer we’re able to pick our code after ~month and changing it as they want it.
Smarty can be weird if you don’t understand template engine principles. Template engine syntax is then really useful & powerful at same time. But when you understand the principles, know what you exactly want, have plenty of time & money there’s nothing against writing your own one.
And please do not even compare Masterpage to Smarty or ZendView -> KO would be instant.
I’ve seen many voices about controls. Well Zend, Code Igniter & symphone are offering same amount of reusable libraries.
After all I think we both have some strong preferences Ozzy :>
ASP.net rules
@Exo
I think you’re missing a point here: "But not every language works against you in this matter." ASP.NET is not a programming language at all. C# is
Pick up ASP.NET MVC and voila, you have the full control over your HTML output
"AFAIK quite experienced developers had a problem to agree sessions between ASP & .NET after turning ViewState"
Ermmm, this is a bit lame. You can’t share sessions easily between two PHP apps running on the same machine too. Have you tried to share session between WordPress and osCommerce for example?
"And please do not even compare Masterpage to Smarty or ZendView -> KO would be instant."
Eh? Mate, what are you talking about? What have these 3 in common? A mistery…
As you’re mentioning Symphony, I think it is the best thing in the PHP world.
"Smarty can be weird if you don’t understand template engine principles."
IMO, the point was: why someone would use a templating engine over another templating engine
@Ozzy
You’re right – it is messy. Especially when all PHP frameworks are extending language, while ASP is something completely different to C#. Comparison then is bit out of ‘range’, don’t you think ?
"You can’t share sessions easily between two PHP apps running on the same machine too. Have you tried to share session between WordPress and osCommerce for example?"
Yeah, damn easy via memcache, using ‘session_set_save_handler()’. Hard isn’t it ?
Btw. ever hear about Masterpage ‘semi-template engine’ ? If you were, you’d know what I’m speaking about.
Symphony, ZF & CI are three best for RAD in PHP.
Oh the mighty memcached! Yes, it is very simple: run a memcached server, modify the code to use it properly, pray so that it will not loose your session data. Yes, very simple.
"…while ASP is something completely different to C#…"
Mate, stop it. It seems you’re completely clueless here.
Memcache… No check for validity. No referential integrity. Memcache doesn’t have locks. Memcache is not atomic. There is no authentication. In shared hosting, everyone on that host can read/write to your memcache instance.
What a joke!
PHP is the ugliest ans slowest thing in the recent world history. The logic behind its existence is still escaping me
Btw, are there any similar tests comparing Ruby vs Python or Java vs C#? (i mean, real programming languages)
I think ASP.NET is far better platform than PHP and an asp.net developer is a lot more productive than a PHP developer. What makes PHP important is all these existing open source applications. And if you end up using one of these existing apps, asp.net looses all the productivity advantage.
If you want a real programming language you do it in assembly, not on those ruby/python/java/c# thingies there… (see where am going?)
I think it’s all bollocks and it’s bad for you.
Joe,
Now when you got testing PC, tests, all the infrastructure in place, would you please walk an extra step and test
Win + ASP.NET + MySQL
Win + ASP.NET + PostgreSQL
It would be also nice to test Mono ASP.NET on Ubuntu and Win
Can you do it for the community please?
Why didn’t you include the postgres on windows perf? Would be interesting to say the least.
Joe,
Where’s the code you used to test database connections from ASP.NET to SQL,MySQL, and PostgreSQL ? I’d like to run some of these tests. Did you use the MySQLConnector?
Also, you’ve got the class code you used to call framework functions for PHP, but can you provide the page you made to call those? Thanks! Very interesting.
oops, I meant you’ve got the class for ASP.NET but not the page like you have in PHP.. thanks if you can provide that.
Hi, This sounds interesting. Though I have never been onto PHP but as still. Can you also put some more effort in comparing Java and ASP.NET. I have recently tried Java but still I feel that micorsoft technologies are simpler and easy to implement. Long Live Microsoft
Kashif Imran. I would like to be sure if you are more productive in asp.net than PHP (Have you ever tried a PHP MVC framework "CaePHP, CodeIgniter, Symfony, Zend") I can certanly say that for really simple application ASP.NET is way faster to develop than PHP or Rails but when the things start to get more complicated I would not choose ASP.NET I would go for Rails (Ruby) or Django (Python). Iam not sure if this comparisons PHP vs ASP.NET help. I know JAVA is faster than Ruby but I have seen JAVA applications converted to Rails, and Rails was faster, the way you code determines the speed of your application a lot and I can tell you that Ruby can give you a lot of happiness, (Happy programmer is more productive).
Rails is good for complicated applications? I would say the exact opposite.
–> My comment was deleated becuase I can neither read or be polite and I’m only here to whine becuase I’m too lazy to add value.
. and becuase it contained technically innacurate presumtions/
- I’m just mad that ASP.NET is so much faster than PHP
–> My comment was deleated becuase I can neither read or be polite and I’m only here to whine becuase I’m too lazy to add value.
–> My comment was deleated becuase I can neither read or be polite and I’m only here to whine becuase I’m too lazy to add value.
@gargamel
Honestly, get the sources, optimize PHP as you like, call Zend for help, run the tests and come report the results. OK?
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
.NET Fun With the ?? Operator in C#: if { } or ?? – Which is Faster? Documenting source code Dictionary<T>
–> My comment was deleated becuase I can neither read or be polite and I’m only here to whine becuase I’m too lazy to add value.
This benchmark is nonsense!
i think this isn’t a good test..
php vs asp.net on mono… linux ..
then see what is faster..
Thank you for running the comparison and having the boldness to publish your results.
Hello!
I’m not a developer I’m a user. to me PHP sites universally have better performance than ASP.NET Powered ones. maybe bcz of FF
Thanks a lot!
We had a lot of discussions about which technology should be used in a new project. Since you made you sources public even my boss accept it!
@gargamel
You can run all the tests on your machine (both php and .net)? Then we can compare percentages…
–> My comment was deleated becuase I can neither read or be polite and I’m only here to whine becuase I’m too lazy to add value.
Both are good and both let you earn money, which is most important.
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Pingback from PHP and Community | Postcards From My Life
This cannot be accepted as a fair, non-partisan measure. For one thing, you may have selected tests that, at some level of implementation, favor asp.net. I’m sure the same thing could be done with PHP.
Not meaning to be too skeptical here, but one wonders if MS really is serious about its overtures to the open-source community given these types of contrived comparisons touted by an MS employee who purports to be "neutral" (i.e., "I love them both"). Smile. Nod. Wink.
@vdd said, "We had a lot of discussions about which technology should be used in a new project. Since you made your sources public even my boss accepted it!"
Hey, VDD – if your company uses comparisons like these to make decisions about real-world web solutions, you might want to keep your resume updated.
Just sayin’
Way to go "dave" or should I say anonymous coward
(My term for posters who lack the courage to provide a real name and contact information.
YOu managed to call me dishonest and incompetant in the same commnet – which also proves you didn’t READ teh orriginal post.
You are typical of the internet warrior who whines becuase they don’t like the RESULTS. Since you can’t provide opposing data you make stuff up.
Cheat, Bias, hand taylored.
Thankfully – you are not representative of the PHP community. I’ve been emailing with Andi Gutmans (ZEND and co-Inventor of PHP) who has had some interesting suggestions for a next set of benchmarks.
Keep watching for those !!!
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Pingback from PHP vs ASP.NET « Blog, what blog?
Hey Joe I read your stuff and do your videos and try to fallow your suggestions all the time everything I’ve done of or should I say copied your lead has worked exactly like you said it would great work you’ve brought me and I assume allot of other people a long way in this game we call development and I’m sure if PHP was faster you folks at Microsoft would start working on making ASP.NET faster so I don’t know why Dave would think you would jimmy the test KEEP UP THE GOOD WORK JOE!!!!!!
ASP: DateTime NextWeek = new System.DateTime().AddDays(7);
PHP: $secNextWeek = time() + (7 * 24 * 60 * 60);
Just because PHP doesn’t seem to have a similar AddDays() function you don’t need to calculate (7 * 24 * 60 * 60) in every loop iteration.
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Overall I’ve been pretty impressed with the reactions to my first round of PHP/Linux/Windows/ASP.NET performance tests. I’d like to comment of the comments   First, while I appreciate the enthusiasm of my .NET friends, the point of my exercise
Thanks Joe, This is really interesting stuff and may help someone to show to their client to go for .NET
Good post Thanks for sharing it
Puru
Good post Thanks for sharing it
Puru
good post
Puru
Do Windows servers stay up for a couple of years without a reboot like Linux & FreeBSD?
Last time I tried a Windows server, it encountered a "STOP ERROR" after just a week!
"# 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. )"
That is FUD, you are spreading. 5.3′s mysql driver has better performance, measured on Linux. We got comments from user that they like the speed of the new driver (compared to libmysql, which is used with 5.2). We did not have any Windows users complaining, so far. You are the first and your results will be taken into consideration, so we will set a Windows system for testing trying to check the results.
Andrey
Andrey,
It’s not FUD – the times speak for themselves – the performance of MySQL access on Windows SUCKS !
.. and logic suggests that Sun is less than compleatly interested in it’s performance on Windows.
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Pingback from Programming news: ASP.NET beats LAMP and WIMP in performance test | Programming and Development | TechRepublic.com
Thanks for sticking your head out. I’m happy to see someone ‘promoting’ the thought that maybe personal skills DOES matter after all
– the dev env/language wont do it for you
I think that too many decisions are taken in our industry on personal belief and rumours, which many of these comments and on similar tests show.
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Pingback from PHP and Community – techPortal
First, a scripted language against a compiled one, the fact that you are even trying to compare the two makes me think you shouldn’t be in the benchmarking business at all.
Second, making wild statements like ‘ASP.NET is universally faster than PHP’ without providing explicit details on how to duplicate the results that you posted, shows you are not a very trust worthy source.
Third, I challenge someone to use your own code examples with any server configurations they desire to contradict your findings, and I challenge you to post those results.
Hi Sam, I see that you can’t read since your comments don’t comply with my requsts.
I also see from your web site that you are a PHP developer so I understand your rant.
I posted all the details and the code to duplicate my tests (I guess you were so upset at PHP perfarmance that you missed that.)
How about – instead of whining "I don’t believe thye thing I know is slower than the thing I don’t know" you actually download the code and run some tests yourself.
2 remarks :
- To the author : running PHP without an opcode cache is like running ASP.Net in debug mode… it’s just "not-done". Use an opcode cache and then compare performance of real applications, not a bunch of loops. You’ll notice PHP beats ASP.Net on most levels.
I would still prefer PHP over ASP.Net if it were slower… speed is just a small factor.
- To Apfel : from PHP 5.3.0 onwards :
ASP: DateTime NextWeek = new System.DateTime().AddDays(7);
PHP: $secNextWeek = new DateTime()->add(new DateInterval("P7D"));
Wim,
In fact, my LAMP host does not include op-code caching.
Also, I often find ASP.NET applications in production that are running in debug mode.
However THIS staement by you "I would still prefer PHP over ASP.Net if it were slower… speed is just a small factor."
Is the important one – for you, a performance difference of this amount doesn’t matter.
And – I agree !
> I’ve been emailing with Andi Gutmans
>(ZEND and co-Inventor of PHP) who has
> had some interesting suggestions for
> a next set of benchmarks.
That would be cool. And, could you please, email ScottGu too.
I love ASP.NET/MS SQL Server and I’ll keep on using it in any case. What I need is to be honest with my customers.
Thank you.
SergeyS
Email Scott for what ?
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Pingback from Cal Evans’ Blog: PHP and Community | Webs Developer
> Email Scott for what?
To suggest testing scenario to reveal all the ASP.NET/MS SQL power. What you tested was almost not related to real life more or less complex projects (in my opinion, – I may be wrong). And for simple projects the performance does not matter.
For example
- Does PHP/MySQL really scale in both dimensions as they love to say (specifically for AJAX-rich mass web projects)
etc etc
Thanks.
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Pingback from Cal Evans’ Blog: PHP and Community | PHP
Joe, I must apologize for my rant, I did go off the deep end a little, but in my own defense the file ‘http://www.misfitgeek.com/pages/aspnet_perf_test_source.htm’ does not display correctly in Firefox 3.5 on my laptop, which led me to believe that there was missing information. However, upon further investigation, I realized that it does display in IE. And I will be happy to put it to the test myself.
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Pingback from ASP.Net Vs PHP performance…. – The Prophecy Forums
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Pingback from Of Lies, Damned Lies, and Benchmarks – Brandon Savage | rapid-DEV.net
Thanks Sam – I do appreciate it. Feel free ot email me directly if you like and if you create a scenario that renders different results, I’ll be happy to post the results here as well.
Also, I plan to progress to more snecario based tests (full page renderings, etc.) – suggestions are welcome.
-Joe
Database is the main scalability and performance issue, Page UI content is the second biggest performance factor in my experience – assuming no serious coding errors. I have been able to shave seconds off first loads with CSS spriting techniques, javascript packaging, and CDN.
Obviously other performance gains can only be a good thing, I don’t see why a newcomer would choose PHP over .NET, simply due to the depth of support you guys (MS) give, the size of the community and the nature of C# and asp syntax. It’s one big beautiful combo.
At the end of the day, it’s all about the developer. It’s also about knowing your server, optimizing it properly, and knowing how to exploit the resources you have.
If you can code .NET to be faster, go for it. If you can code PHP to be faster, again, go for it. Either way, PHP has it’s pro’s and con’s, as does .NET.
This "age old question" about which is better has long been too focused on the languages and platforms. You should be looking at yourself, the developer, to know which one you are stronger in.
That alone dictates which will perform better.
How come your tests show it takes less to do more with ASP .NET?
If I normalize your empty loops to your string assignment loops I discover that the first two cause a 20% increase in time consumed. But the third takes 16% less time. Doing a simple extrapolation from 7 million to 20 million we can see that a do while loop doing a text assignment takes 16% less time to complete than when it has nothing to do. How is that?
Time Loops Extrapolated %increase
(test) time (-decrease)
0.0940 20000000 0.09400 (empty for loop)
0.0400 7000000 0.11429 21.58% (empty for loop with string)
0.0950 20000000 0.09500 (empty while loop)
0.0400 7000000 0.11429 20.30% (empty while loop with string)
0.1090 20000000 0.10900 (empty do loop)
0.0320 7000000 0.09143 -16.12% (empty do loop with string)
I have used both PHP and ASP.NET and really hooked up to ASP.NET now because of the Visual Studio IDE it beats any PHP IDE out there hands down (my opinion
).
Thanks for the hard work Joe.
Have you used Ubuntu’s PHP 5.2, Zend Server CE or built it from source (vanilla-php)? Ubuntu by default also installs the Suoshin Security Extension, which adds a performance penalty.
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Pingback from Brandon Savage’s Blog: Of Lies, Damned Lies, and Benchmarks | Webs Developer
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Pingback from Brandon Savage’s Blog: Of Lies, Damned Lies, and Benchmarks | PHP
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Pingback from Brandon Savage’s Blog: Of Lies, Damned Lies, and Benchmarks | PHP
I hope people actually looked at your spreadsheet, because your article is misleading.
"MySQL Access from PHP on Linux is a TINY bit faster than SQL Server access on Windows" – I think you meant to say, "is twice as fast" as SQL Server, according to your data.
"MySQL access with Linux is faster by more than a little and on Windows" – Again, you meant to say "is about five times faster", again according to your data.
Well the tone of article was set by the first few lines "I’m PAID by Microsoft to write BOTH PHP and ASP.NET Code. I was doing PHP before .NET shipped. I love them both."
Does anyone seriously believe, a guy who is in Microsoft employment will be unbiased??? I have done a few REAL LIFE tests, file access is WAY TOO SLOW in Windows and mysql is generally way faster than SQL.
"No Operating System or Development Runtime performance enhancements were added." – yes none were added but .NET has its Global Assembly Cache by default.
This is wrong from the start as somebody already pointed out(K I think was the name). For a real comparison you should have used a bytecode cache system for php, because the asp.net code is compiled and cached by default after the first request.
Ok – please see the results of add op-code caching here msjoe.com/…/php-linux-windo
<rant>
I don’t know why anyone is surprised by these results. Microsoft has done a great job tuning their web stack/ide in recent years.
I program primarily in php because my customers request it not because its the best thing ever. I think all technologies have their faults. The biggest selling point of php/mysql is the price. FREE.
The other thing thats nice is unlike windows server which I have to worry about getting hacked/viruses all the time linux servers are extremely easy to secure.
For Microsoft to rule the programming scene I would like to see them secure their operating system.. don’t allow processes rights to files they don’t need. Take security seriously be like apple and (borrow) an already great filesystem and make it your own.. its bsd licensing after all.
</rant>
This article is not a true comparison of apples to apples simply because .NET has caching built in, PHP doesn’t, by default. Also, according to the author, if PHP runs faster on a Windows 2008 machine than on Ubuntu 9.04, then this isn’t really a battle between ASP.NET and PHP but rather Windows 2008 and Ubuntu 9.04 ehh??
Anyone in the right mind will tell you that Ubuntu 9.04 is a much beefier operating system than Windows 2008. I’ve worked with both, yes, even the stripped down version of Ubuntu, and it just wan’t quite the same. How about you try running this on a stripped down version of *BSD system?
Plus, how does anyone know what background services Ubuntu 9.04 was running versus MS 2008 when this benchmark was performed?
Next, only true developers who understand the importance of performance, security and optimization will understand my point here. That is, in PHP, you design your own controls, your own Javascript and your own CSS to fit your needs for what your website’s intended use. You also have access to this code to further enhance your controls and optimize it to your needs.
In .NET, as we all know, everything is compiled so how would you know that a control you’re throwing on your page that has JS and CSS embedded, code that you have no access to, is 1. Secure, 2. Optimized code for your intended use and 3. Performs?
I’ll be fair here. VS2008 has done a great job creating user controls by wrapping JS and CSS into their IDE. And that’s totally great and works best for MS developers. I’m not a MS developer because I just don’t believe in closed code.
I have a saying: "Open Mind, Open Heart, Open Source" – Bobby Pejman.
Hi, Joe,
Great tests !
One question : The data access tests used transactions (and locks) in all databases ?
SQL Server always uses transactions (few exceptions here), but mysql not always and I don’t know about postgree in this case.
Thanks,
Dennes
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Pingback from PHP Linux Windows ASP.NET Performance ??? Redux ! : Misfit Geek
RE: PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?
Pingback from Web Pro ASP – Active Server Page Development News
Of course C# + asp.net is faster than PHP. IT’S COMPILED CODE! But that’s not what I’m talking about when I say I prefer building web apps in PHP compared to asp.net. I think a better comparison is to create a web app in both php and asp.net. Track the time it takes to build it, the environment cost and the amount of traffic each one can handle. That’s the TRUE test.
This is a wonderful opinion. The things mentioned are unanimous and needs to be appreciated by everyone…………
<a href="http://www.ibowtech.com/algeria">IT Solution</a>
Nice post,
Thanks for writing about it
It would be great to apply the same test to JSP and add the result to your spreadsheet.
Would it be possible for you to repeat the benchmarks with some kind of PHP optimizer?
This type of test would only be fair if you tested classic ASP, which isn’t compiled. Some PHP optimizers compile the actual script, which is exactly what happens with ASP.NET.