ASP.NET MVC vs PHP YII. Performance comparison

Эта страничка доступна на русском языке - ASP.NET MVC или PHP YII. Сравнение производительности

I am a member of freelance team AdvanceDev. There are a lot of customers asking us to develope a website or a crm using php. They tell lots of fake reasons why php is better than asp.net mvc and tell nonsence to prove their point of view.

In this article I would like to destroy most common myths about asp.net. By saying asp.net I mean asp.net mvc unless specified else. Old asp.net web-forms and asp.net mvc are two different technologies, it's like an apple and a pear, you cannot mix them up.

I am not trying to say that php is bad, my goal is to prove that asp.net mvc is not worse than php.

Okay, the most common "reasons" why customers do not want asp.net mvc in their projects

  1. Asp.net is outdated, but php is a tech of tomorrow
  2. There are lots of php developers, which may rescue your project if something goes wrong. In the same time there are too few asp.net developers.
  3. Website developed in asp.net requires an expensive server and won't work if published to a shared host.
  4. Asp.net websites work slower than php and getting even slower with large amount of users.

Asp.net is outdated, but php is a tech of tomorrow

This is a nonsense. PHP was developed back in 1994 and meant to be used in small websites. PHP - Personal Home Page, the name describes itself. Since that time php has grown up, a lot and the latest php 5.6 was released in Summer of 2014.

ASP.NET MVC was developed in 2007 and released to public use in 2009. Latest version asp.net mvc 5 was released in Summer of 2014.

In conclusion of these I may say that asp.net mvc is much newer technology, but both of them have great support by their teams.

There are lots of php developers, which may rescue your project if something goes wrong. In the same time there are too few asp.net developers

First of all we have to decide what means "developer". If asp.net and php show up in a picture then it would look like this:

asp.net vs php It is obvious, that there are much more lumbermen which may use hacksaw that those which may operate gasoline-powered saw. If someone knows how to use the hacksaw that doesn't mean he may use gasoline-powered saw.

Basic knowledge of php is much more simple compare to asp.net, that is why everyone who knows php a little bit calling themself "php developer", but when it goes to the real big projects those "developers" fail terms and disappear.

There are many customers which ask us to "finish a php website, because their developer can't make such functionality" or "rework a php website, because it is very buggy and works very slow, but his creator got payment and disappeared". I could not remember any customer turning to us because of such problems with asp.net websites.

I think there are about the same number of good php and asp.net developers. It is very often when skilled developers may use both of the technologies.

Any developer, which has some big php and asp.net projects behind would tell you that php lacks a lot of useful features which make developer's life much more easy.

Website developed in asp.net requires an expensive server and won't work if published to a shared host

Another myth. Price for php and asp.net are about the same. Look here for an example: http://www.winhost.com/hosting-plans/max.aspx, for $7.95 a month you get everything you may need for an asp.net website.

You will need a dedicated server for big project and it does not matter which technology you use php or asp.net.

It is preferably to use Linux operating system for php websites, it is free, but if you need you may port a php website on Windows server very easily.

Windows is native and best operating system for asp.net, however asp.net may work under Linux with some limitations.

To use Windows you have to pay for the license.

Monthly about 25 euro:
(http://www.hetzner.de/en/hosting/produkte_rootserver/windows-standard/)

Buy lifetime license:

  • Windows 2008 R2 - from $250
  • Windows 2012 R2 - from $500

As I mentioned before, php lacks lots of features which asp.net has, that is why developing the same site using php requires more time, means more money. From our experience I could tell that price for a project developed in php would be 1.5-2 times more expensive than the same project developed in asp.net.

Simple calculation:

ASP.NET MVC + Windows + MS-Sql Server

  • Website development - $2000
  • Operating system - $500
  • MS-Sql Server - free edition
  • Total $2500

PHP YII + Linux + MySql Server

  • Website development - $3000
  • Operating system - $0
  • MySql Server - free edition
  • Total $3000

As you may see the php variant is more expensive even if include Windows license price. If you are not satisfied with free edition of MS-Sql server, you always may choose MySql. MySql works great under windows and on pair with asp.net.

If you are considering not only money, but also development time and website speed then asp.net has even more advantages over php.

Asp.net websites work slower than php and getting even slower with large amount of users

It might be the biggest reason why customers are "afraid" of asp.net. Outdated asp.net web-forms is really slow, it consumes a lot of resources and it is very easy to mix everything up in the project. However asp.net mvc is not asp.net web-forms, you cannot mix them up! It is very common when php developers do not have any experience in asp.net and do now know what is asp.net mvc, but still claim that asp.net mvc is outdated and lose to php in every aspect.

I have made some real testing of php and asp.net performance, both php and asp.net were running at Linux and Windwos. A simple website was made for the benchmarks. The website is something like a small internet-shop, it contains set of products, set of customers, set of orders and set of order items. There are four testing scenarios.

In the all pictures:

  • left side – time in seconds
  • bottom side – number of users

I have shortened some names to minimize number of text in the diagrams.

  • win – windows
  • asp.net – asp.net mvc
  • ms-sql – ms-sql server
  • mysql – mysql server

1. Import from a text file

There is a text file which contains set of customers. The website reads data from the file, sort by alphabet, founds number of vowel letters in customer's name and displays the result to the user.

asp.net mvc vs php benchmark result

As you may see from the result asp.net under windows insignificantly loses to php under linux with small number of users and goes ahead with large amount of users.

Php under windows and asp.net under linux shows very bad results here.

2. Export into excel file from data base

The website needs to select all customers from the database, sort them alphabetically, save to excel document and return download link to the user.

asp.net mvc vs php benchmark result

In all cases asp.net mvc under windows + ms-sql server requires twice less time compare to php under linux + mysql.

Asp.net mvc + mysql shows almost the same result, asp.net under linux + mysql a little faster than php. Combination of php under windows and mysql again straggle behind.

3. Select and display products from database

Search for products by category and part of name. Display the result in an html table.

asp.net mvc vs php benchmark result

Asp.net again leads over php in any combination. I have to note, that mysql caches query result by default, that is why mysql is faster than ms-sql in this test. If manually enable caching for ms-sql we will get about the same results.

4. Place an order

Select a random customer. Create a new order. Pick ten random products. Save order data and display information about the customer and his order to the user.

asp.net mvc vs php benchmark result

In the latest test combination of asp.net mvc under windows + ms-sql shows significantly better result. Php under linux + mysql needs almost twice more time. Asp.net + mysql under windwos and linux also shows good results. Php under windows is far behind as alway.

Average performance by four tests

asp.net mvc vs php benchmark result

It is not difficult to notice that asp.net + ms-sql outperform php + mysql in any scenario, the more users, the greater the gap.

asp.net + mysql under windows shows almost the same result as php + mysql, but still a little faster,
asp.net + mysql under linux a little slower compare to windows,
and php under windows works very slow, I didn't even mention it in the final diagram.

All of the tests were performed on the same hardware. No other applications were running. Every test was performed four times and then took the average result.

Software configuration:

  • ASP.NET MVC 4, .NET 4.5
  • PHP 5.6 YII2
  • Windows 8, IIS8, MS-SQL Server 2012 Express, MySql 5.5
  • Ubuntu 14.10, Apache2, MySql 5.5
  • Ubuntu 14.10, Nginx + fastcgi-mono-server4, MySql 5.5

Hardware specification:

  • CPU: AMD Phenom II 965 x4
  • RAM: 4gb RAM
  • HDD: WD 1T

And in conclusion I want to give some examples of successfully running asp.net mvc websites.

  1. http://stackoverflow.com/ - forum for developer and more. About a million users a day.
  2. http://dearsystems.com/inventory-software/ - a CRM for inventory management, very popular in USA and Australia.
  3. http://www.asp.net/ - website about asp.net.
  4. http://live.com/ - popular mail server and more.
  5. http://www.documentoved.ru/ - service for online document generation.

Here you may read some statistics about asp.net mvc
https://www.similartech.com/technologies/asp-net

And here about php
https://www.similartech.com/technologies/php

Written by on
Views: 14724 Comments: 4
SunnyRitter on 22 September 2015 08:34 says

Good day!

If we continue research in this area, a lot of people will thank you. By the fact that tired of making two choices and then to hear from customers who saw the difference in performance:"... amazing, and we are told that PHP is faster".

Matt Watson on 30 November 2015 06:09 says

If you are looking to do some performance tuning, there are a lot of different tools to help you find and optimize ASP.NET performance. I made a great list of 9 different types of tools. Check it out and see if any of these can help: http://stackify.com/asp-net-performance-tools-you-need-to-know/

Elisa Gracedd on 15 December 2015 13:26 says

ASP.NET code executes lots faster as compared to PHP, when it's build in release mode, optimized, cached etc etc. But for websites like Facebook, it's less important - the most time of page rendering time is accessing and querying database. In connecting database ASP.NET is a lot higher - in asp.net we usually use LINQ that translates our object queries into stored procedures in SQL server database. also connection to database is persistent, one for one website, there is no need for reconnecting. On other side, PHP is Faster for small programs and slower for medium-to-big programs. Get more info here http://www.keenesystems.com/Expertise/ASPNetWebApplications.aspx and here http://stackify.com/asp-net-performance-tools-you-need-to-know/

Const on 15 December 2015 15:44 says

Elisa Gracedd, thank you for the input.