Pages

Sunday, March 20, 2011

Performance of ASP.NET on Windows/IIS vs Linux/Apache

Overview

The rivalry between proponents of .NET and Java frameworks has always reminded me of rivalry between Red Sox and Yankees. Each framework has its ups and downs, but in the end is a solid framework for designing enterprise-level applications. One major drawback of .NET compared to Java is that it’s not really platform independent and is geared heavily towards the MS Windows Operating system. The Mono project is a cross platform, open source .NET framework implementation. Mono makes it possible to run .NET applications including ASP.NET under Linux using Apache, and not to be bound into any specific technologies with their associated licensing fees.

I’ve always anticipated Apache to be faster than IIS but never tested it. This weekend, I had some spare time on my hands, so I decided to compare the performance of a typical ASP.NET application running on Windows with IIS web server versus its performance under Linux with Apache. What I found out is that on average Apache was serving requests three times faster than IIS.

A word of caution is that this comparison wasn’t scientific, as different background processes may have affected the timing. We’re also comparing ‘apples’ to ‘oranges’ since the Mono framework doesn’t implement the full breadth of features available with Microsoft .NET CLR. However, for simple programs, I am still convinced that using Apache will yield better performance. Below are my notes on the performance evaluation.

Test Platform

I use an Intel Core 2 Duo CPU T6600 @ 2.20 Ghz Mhz, 2 core, 2 logical processors with 4GB RAM at home. It’s partitioned to dual boot into ether Windows Vista or Ubuntu Linux. So I could execute the tests onto two different stacks of technology under identical hardware.

Test Program

I’ve used a test program from the following CodeProject’s Mono article. It’s effectively a ‘hello world’ program on steroids, which prints your computer’s configuration along with details of the HTTP request.

using System;
using System.Web.UI.WebControls;
 
namespace SimpleWebApp
{
   public class SimplePage : System.Web.UI.Page
   {
      protected Label operatingSystem;
      protected Label operatingSystemVersion;
      protected Label requestedPage;
      protected Label requestIP;
      protected Label requestUA;
      protected Label serverName;
   
      protected override void OnLoad(EventArgs e)
      {
         DisplayServerDetails();
         DisplayRequestDetails();
 
         base.OnLoad (e);
      }
 
      private void DisplayServerDetails()
      {
        serverName.Text = Environment.MachineName;
        operatingSystem.Text = Environment.OSVersion.Platform.ToString();
        operatingSystemVersion.Text = Environment.OSVersion.Version.ToString();
      }
 
      private void DisplayRequestDetails()
      {
         requestedPage.Text = Request.Url.AbsolutePath;
         requestIP.Text = Request.UserHostAddress;
         requestUA.Text = Request.UserAgent;
      }
   }
}

Benchmarking

For benchmarking, I used Apache Benchmark tool, which fired off 8,000 requests to the webpage with a 100 thread concurrency. On average, the Apache with mod_mono module was able to serve requests three times faster than an IIS installation.

1. Apache with mod_mono under Ubuntu

$ ab -n 8000 -c 100 -g out.dat http://localhost/index.aspx
This is ApacheBench, Version 2.3 <$Revision: 655654 $>

Server Software: Apache/2.2.11
Server Hostname: localhost
Server Port: 80

Document Path: /index.aspx
Document Length: 1992 bytes

Concurrency Level: 100
Time taken for tests: 20.273 seconds
Complete requests: 8000
Failed requests: 6
(Connect: 0, Receive: 0, Length: 6, Exceptions: 0)
Write errors: 0
Non-2xx responses: 6
Total transferred: 18559720 bytes
HTML transferred: 15927990 bytes
Requests per second: 394.62 [#/sec] (mean)
Time per request: 253.408 [ms] (mean)
Time per request: 2.534 [ms] (mean, across all concurrent requests)
Transfer rate: 894.05 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 2.3 0 24
Processing: 19 252 55.6 244 619
Waiting: 13 252 55.7 243 619
Total: 28 252 55.1 244 619

Percentage of the requests served within a certain time (ms)
50% 244
66% 258
75% 267
80% 273
90% 297
95% 340
98% 407
99% 560
100% 619 (longest request)

2. IIS under Windows Vista

C:\> ab.exe -n 8000 -c 100

http://localhost/index.aspx

This is ApacheBench, Version 2.3 <$Revision: 655654 $>

Server Software: Microsoft-IIS/7.0

Server Hostname: localhost

Server Port: 80

Document Path: /index.aspx

Document Length: 1964 bytes

Concurrency Level: 100

Time taken for tests: 63.468 seconds

Complete requests: 8000

Failed requests: 0

Write errors: 0

Total transferred: 17632000 bytes

HTML transferred: 15712000 bytes

Requests per second: 126.05 [#/sec] (mean)

Time per request: 793.347 [ms] (mean)

Time per request: 7.933 [ms] (mean, across all concurrent requests)

Transfer rate: 271.30 [Kbytes/sec] received

Connection Times (ms)

min mean[+/-sd] median max

Connect: 0 7 5.3 6 132

Processing: 162 780 189.1 710 1665

Waiting: 12 435 255.3 420 1576

Total: 167 787 190.4 716 1683

Percentage of the requests served within a certain time (ms)

50% 716

66% 751

75% 776

80% 805

90% 1021

95% 1272

98% 1453

99% 1527

100% 1683 (longest request)

3. A picture is worth a thousand words

Here is a comparison plot as the number of requests increase.

Reactions:

40 comments:

I've wondered about this before. Good to see some actual data supporting the gut feelings. So what you are telling me is I can move my (basic) .ASP apps over to ubuntu and say buhbye to my windows server and actualy get a performance increase. sweet.

which ubuntu are you running? I wonder how the same tests would go on Server 2008 vs. Ubuntu Server 10.04/05. Anybody have that configuration and want to test it?

Fun stuff. Nice work Aleksandr. Thank you!

This is great. I loved the explanation of each topic with an example .Thanks Aleksander.

.net obfuscator

IIS on vista probably shouldn't be expected to run fast, given that Vista by default prioritizes apps over services, and probable IIS optimizations that aren't in the vista build of IIS. So I second Eric's wonderings.

We should plop this test on a box with IIS 7 (or heck, even 8).

But even still, I can't imagine IIS 7/8 performing much better on a server than Apache. Probably comporable or worse.

This is a terrible comparison. IIS on a consumer O/S (XP,Vista,7,8) is limited in many ways (including max concurrent connections). A proper test would be a server level OS.

In my personal testing I've found xsp to give the best asp.net performance in linux, faster than nginx with fastcgi over unix sockets. I've also found mod_mono to be much slower than IIS 7.5, many times slower. I was running the basic asp.net mvc3 and mvc4 internet application templates with some minor changes to get them running under mono. Tested it last week in fact with mono 3.0.7

I've benched with apache bench and gotten results much different than yours, but it was windows 7 pro. I'm pretty sure windows server would turn in better results. Also to take full advantage of asp.net in production you probably use some the page caching features built into the windows kernel.

Anyways, I work as a web developer and I really wanted asp.net to run as well in linux as it does in windows, but I don't think it does. Mono is very focused on mobile these days so I'm not hopeful that asp.net performance tuning will be a priority for them either.

This is a silly benchmark. You're measuring performance using a the consumer (not server) version of IIS which is throttled. Plus, you're accessing the Environment variables and assuming that it's the same speed on both machines. What if there's a lag on Windows accessing the Environment? Then that would throw off your whole benchmark.

very good comparison between IIS and Apache.

Prathap
ASP.Net Training in Chennai

thanks for sharing..
www.7elevenech.com

Simply, admirable what you have done here. It is pleasing to look you express from the heart and your clarity on this significant content can be easily looked. Remarkable post and will look forward to your future update.

The use of 1z0-821 braindumps demo technologies in education is not a magic and rapid solution through which educational problems and challenges can be solved with the simple acquisition of HIT-001 real brain dumps technological devices and systems. Improving the quality of education remains one of the main issues in political agendas for all countries, especially developing ones. 642-813 braindumps demo

Yes i want to be a part of your party, No matter what time of your party and i also can perform in dance session. We are providing cheap essay writing service for those who want to attend party and don't have time to write their own articles.

Great post. really happy to visit your blog. Thanks for sharing.
Catering Services in Tambaram

Really informative post. I read your post. it is very useful. Thanks for sharing.
primary school website design

Thanks for sharing informative article on Node.js. In recent years, this technology is going to be the future of web design and development technology. I am going to include Node.js in my Web designing Training syllabus in educating my students.

Great article. I learned some new information. Thank you so much for sharing.
digital marketing training in chennai

IIS on a desktop OS to benchmark server comparison? Oh.. like comparing electric car performance by using a Tesla X vs Toyota Yaris and telling electric motor is always better for performance.
Give some chance to IIS by using Server OS instead and compare again with a normal page.

I bet to an equivalent speed or so.

These all are notable facts… I stick with responsive website design for my business. With the mobile marketing is at its peak stage, having website that goes comfy on all devices will help your business. You can check my website for more details on the importance of responsive website design. PHP Training in Chennai | Best PHP training in Chennai | PHP Training Institute in Chennai

Awww. One of the nice post i have seen.Your site gives us facts about performance of windows. by the way I highly recommend its services simple resume examples due to its quality and affordability.

I am reading ur post from the beginning, it was so interesting to read & i feel thanks to you for posting such a good blog, keep updates regularly.Best Hadoop Training Institute In Chennai

When you're tired, you want to relax after a stressful working hours, you need to have time to take care of the kids active.
Please visit our website and play exciting flash games.
Thanks you for sharing!
http://www.friv4-online.com Friv 4

When you're tired, you want to relax after a stressful working hours, you need to have time to take care of the kids active.
Please visit our website and play exciting flash games.Thanks you for sharing!
Friv 4

Pretty content. PHP is acronym for Hypertext Preprocessor which is the most trending technology and open source scripting language that is mainly used for web development, can be embedded with HTML.
PHP Training in Chennai | PHP course in Chennai

Tired of stress after strenuous school. Be entertained by the popular online games that are hot now wings.io

I am so thankful for your posts.Quite an interesting piece of information.Keep sharing like this.
Thanks,
Hadoop Training Chennai | Hadoop Training in Chennai | Bigdata Training in Chennai

This technical post helps me to improve my skills set, thanks for this wonder article I expect your upcoming blog, so keep sharing...
Big Data Training|Big Data Course in Chennai

This comment has been removed by the author.

The cloud computing offers numerous advantages for your business that can decrease the cost of supervising and keeping up the IT systems.
Cloud computing Training in Chennai | Cloud computing Training centers in Chennai | Cloud computing Training institutes in Chennai

Excellent post!!Dot net framework use to concentrate on the software environment to give contrast to the hardware environment, this phenomenon is known as the common language runtime. The program written in dot net features like this CLR (common language runtime). This framework works and provides the services like security, memory management, and exception handling.Thank you..!!
Regards,
dot net course | dot net training in chennai

The fundamental target of computerized showcasing is to advance brands from low quality to high quality. Begin to learn Digital Marketing course in Chennai It has incredible breadth in future.
Digital Marketing Training in Chennai | Digital Marketing Training Institutes in Chennai

.Net is most preferred programming language among software developers all over the world. It is also considered as most trusted and effective platform to build high performing desktop or enterprise application.
DOTNET Training in Chennai | DOTNET course in Chennai | DOTNET Training Institute in Chennai


Thanks for sharing such informative guide on .Net technology. This post gives me detailed information about the .net technology. I am working as trainer in leading IT training academy offering Dot Net Training in Chennai and i use your guide to educate my students. .Net Training in Chennai

Post a Comment