Wednesday, 13 June 2012

Performance comparison: IIS 7.5 and IIS 8 vs. self-hosted mvc4 web api

Introduction

There are several ways to host your services with the new MVC4 Web Api framework. Traditionally, most people would use IIS which has several advantages such as application pools, recycling, monitoring and on-demand loading.

This post on stackoverflow has a more of in-depth discussion about the pros and cons of self-hosting so I won't re-iterate that here - this post assumes you only care about the raw performance comparison which I haven't been able to find so far. It will compare IIS7 and IIS8 (Windows 8 Consumer Preview) to see if there are any differences between different versions of IIS.

Test Environment

This test was run on an Intel i5 with 8GB ram using Apache Bench 2.3 - Rev. 655654 (from the XAMPP for Windows installation).

In these tests, the web-server and benchmark client were located on the same physical machine.

Windows 7 Ultimate Edition with IIS7 will be used and Windows 8 Consumer Preview with IIS 8 will be used for the Web server performance comparisons. Do not try this with the version of IIS Express that ships with Visual Studio - the performance was a fraction of "real" IIS 7.5 in my tests.

The Test Code

The nightly build of MVC4 from nuget (as of 11th June 2012) was used. For Self-Host, the host was a console application (I would expect a Windows Service to yield comparable results).

In both cases, the controller itself was located in the same, external assembly and contained the following code:

public class TestApiController : ApiController
{
public IList GetAll()
{
return new List<Foo>
{
new Foo {Id = 1, Name = "Foo 1", CreatedOn = DateTime.Now},
new Foo {Id = 2, Name = "Foo 2", CreatedOn = DateTime.Now},
new Foo {Id = 3, Name = "Foo 3", CreatedOn = DateTime.Now}
};
}
}

The console application was configured as follows to try and get as close to the same functionality as the Web equivalent:

static void Main(string[] args)
{
const string serviceAddress = "http://localhost:4444";

var config = new HttpSelfHostConfiguration(serviceAddress);
config.Routes.MapHttpRoute("default-api",
"api/{controller}/{id}",
new
{
id = RouteParameter.Optional,
namespaces = new[] { typeof(TestApiController).Namespace }
});

config.Formatters.XmlFormatter.SupportedMediaTypes.Clear();
var server = new HttpSelfHostServer(config);
server.OpenAsync();

Console.WriteLine("Waiting on " + serviceAddress);

Console.ReadLine();
}

The web application had the following code in the global.asax.cs file:

protected void Application_Start()
{
var config = GlobalConfiguration.Configuration;
config.Filters.Clear();
ViewEngines.Engines.Clear();
config.Routes.MapHttpRoute("default-api",
"api/{controller}/{id}",
new { id = RouteParameter.Optional, namespaces = new[] { typeof(TestApiController).Namespace } });
config.Formatters.XmlFormatter.SupportedMediaTypes.Clear();
}

In the web.config, debug was set to "false", authentication mode was set to "none", runAllManagedModulesForAllRequests was set to "false" and sessions and profiles were disabled.

Although these options are not the defaults, I assumed they would give the best raw performance (although in practice they seemed to make little or no difference).

The Results

Note: all tests were run 3 times and the "best" time was taken.

All tests were run with:

ab -n 100000 -c 100 http://myip:port/api/testapi
 Requests (#/sec)Time per request (ms)
Windows 7 (IIS 7.5)3025.7333.050
Windows 7 (self-host)4624.4421.624
Windows 8 (IIS 8)4778.2320.928
Windows 8 (self-host)5612.2317.818

As can be seen above, in my environment, self-hosting can serve approximately 50% more requests per second under Windows 7 and about 17.5% on Windows 8.

Some of the overall performance difference between Windows 7 and Windows 8 is likely to be as a result of my Windows 7 installation having more services running (as the Windows 8 installation is brand new).

Conclusion

It is hardly surprising that self-hosting is more performant in terms of raw requests than IIS considering the rich feature-set of IIS. In addition, there might be settings in IIS that can bring it closer (or surpass) that of self-hosting by disabling various features. I would be happy to re-run the tests if anyone has any ideas.

As a basic recommendation, I would suggest that if you are creating a web api project, IIS is the safer and simpler choice by default.

Deployment using something like webdeploy means that the service can be updated without interruption. In the case of self-hosting with a Windows Service, there might be some juggling required to make sure that the stop -> deploy -> restart cycle minimizes down-time. A thin wrapper with auto-reloading external assemblies could go some way to resolve this but would require you to roll your own piece of infrastructure - something that is already solved in IIS.

Use-cases I can see for self-hosting include:

  • You are already shipping a Windows Service for a different purpose and would like to expose some kind of managment interface
  • You want very fine-grained control over the hosting stack and don't need any of the features of IIS
  • Squeezing out the maximum requests/second is critical to your application

23 comments:

  1. config.Routes.MapHttpRoute("default-api",
    "api/{controller}/{id}",
    new
    {
    id = RouteParameter.Optional,
    namespaces = new[] { typeof(TestApiController).Namespace }
    });

    config.Formatters.XmlFormatter.SupportedMediaTypes.Clear();


    is the "common code"

    ReplyDelete
  2. Thanks for the good words! Really appreciated. Great post. I ve been commenting a lot on a few blogs recently, but I had nt thought about my approach until you brought it up.

    SAP training in Chennai

    ReplyDelete
  3. Really i enjoyed very much. And this may helpful for lot of peoples. So you are provided such a nice and great article within this.

    Digital Marketing For Small Business in Chennai

    ReplyDelete
  4. I have read your blog its very attractive and impressive. I like it your blog.

    Digital Marketing Company in Chennai Digital Marketing Agency

    ReplyDelete
  5. A great website with interesting and unique material what else would you need.
    web hosting in Nigeria

    ReplyDelete
  6. Great blog, thank you so much for sharing with us. Get a custom mobile app development services at Appslure WebSolution by the professional ios app designers and developers and also get e-commerce app Services
    App development company in mumbai

    ReplyDelete
  7. شرکت تلکا هاست پیشرو در میزبانی انواع وب سایت و هم چنین دارای انواع خرید هاست ارزان با کنترل پنل سی پنل میباشد.حتما از سایت ما دیدن کنید و از قیمت های مناسب برای انواع سرویس های وب و ثبت انواع دامنه شگفت زده شوید.

     

    ردومی سایت موسیقی ایرانی دارای محتوای آموزشی اخبار به روز هنر و سینما و موسیقی دانلود فیلم های جدید ایرانی و دانلود آهنگ های بی کلام

    ReplyDelete
  8. Crypto-currency as a modern form of the digital asset has received a worldwide acclaim for easy and faster financial transactions and its awareness among people have allowed them to take more interest in the field thus opening up new and advanced ways of making payments. Crypto.com Referral Code with the growing demand of this global phenomenon more,new traders and business owners are now willing to invest in this currency platform despite its fluctuating prices however it is quite difficult to choose the best one when the market is full. In the list of crypto-currencies bit-coins is one of the oldest and more popular Crypto.com Referral Code for the last few years. It is basically used for trading goods and services and has become the part of the so-called computerized block-chain system allowing anyone to use it thus increasing the craze among the public, Crypto.com Referral Code.

    Common people who are willing to purchase BTC can use an online wallet system for buying them safely in exchange of cash or credit cards and in a comfortable way from the thousands of BTC foundations around the world and keep them as assets for the future. Due to its popularity, many corporate investors are now accepting them as cross-border payments and the rise is unstoppable. With the advent of the internet and mobile devices,information gathering has become quite easy as a result the BTC financial transactions are accessible and its price is set in accordance with people’s choice and preferences thus leading to a profitable investment with Crypto.com Referral Code Code. Recent surveys have also proved that instability is good for BTC exchange as if there is instability and political unrest in the country due to which banks suffer then investing in BTC can surely be a better option. Again bit-coin transaction fees are pretty cheaper and a more convenient technology for making contracts thus attracting the crowd. The BTC can also be converted into different fiat currencies and is used for trading of securities, for land titles, document stamping, public rewards and vice versa.

    Another advanced block-chain project is Ethereumor the ETH which has served much more than just a digital form of crypto-currency Crypto.com Referral Code and its popularity in the last few decades have allowed billions of people to hold wallets for them. With the ease of the online world,the ETH have allowed the retailers and business organizations to accept them for trading purposes, therefore, can serve as the future of the financial system.

    ReplyDelete
  9. Our full Lace Front Wigs are all hand made with a lace cap. They are manufactured with thin lace sewn on top of the cap. Individual hairs are then sewn onto the thin lace. Each lace wig has lace all around the unit which will need to be cut prior to securing the wig to your head. You will need to cut along the hairline around your entire head. By doing so, you will be able to wear your hair anyway you like. You can even style ponytails, up-dos, etc. Once the Lace Wigs is successfully applied, it will appear that all the hair is growing directly from your head!

    Lace front wigs are hand-made with lace front cap & machine weft at back. Lace front wigs are manufactured with a thin lace that extends from ear to ear across the hairline. When you receive the wig, the lace will be quite long in the front. Cut and style according to your preference, as you will need to apply adhesive along the front of the wig. Once the wig is applied, you will still have Lace Wigs with a very natural appearance.
    TeamWigz Provide the Best Lace Front Wigs and Lace Wigs in Johannesburg and South Africa.

    ReplyDelete
  10. 우리카지노 에 오신 것을 환영합니다. 국내 최고의 카지노사이트 에 가입하여 바카라사이트 에서 다양한 게임을 즐기시면서 대박의 기회를 놓치지마세요! 우리 카지노는 한국의 바카라 산업을 지배하는 카지노 사이트입니다. 우리 카지노는 한국 바카라 시장 점유율의 50 % 이상을 차지하는 10 년 이상 온라인 바카라 시장을 지배 해 왔기 때문에 우리 카지노를 모르는 사람은 거의 없습니다.

    ARTICLE: 우리카지노는 대한민국의 바카라 업계를 장악하고 있는 카지노사이트 입니다. 우리카지노가 대한 민국에서 장악한 바카라 시장점유율이 50%가 넘고 10년 넘게 온라인 바카라 시장을 장악해왔기 때문에 대한민국에서는 우리카지노를 모르는 사람은 드뭅니다. 이런 바카라 업계의 독보적인 입지 때문에 늘 유명하거나 최고만을 찾는 사람들이 카지노사이트를 찾을때는 늘 우리카지노를 찾습니다.바카라를 처음 시작하시는 초보자분들에게도 우리카지노에서 카지노사이트를 시작하시기 좋은 환경입니다. 우리카지노사이트에서는 신규가입시 3만쿠폰을 지급 해주기 때문입니다. 사람들이 늘 1등만을 찾는 이유는 분명 있습니다. 다른 카지노사이트와는 달리 우리카지노를 이용하실시 에이전트를 끼고 게임을 하신다면 본사 이외에 활동쿠폰 및 오링쿠폰을 별도로 제공해주고 있기 때문입니다. 이러한 이유들 때문에 카지노사이트 업계에서 바카라를 즐기신다면 다들 우리카지노를 선호 하십니다. 카지노사이트에서 바카라를 이기기 물론 어렵습니다. 하지만 우리카지노의 에이전트를 끼고 바카라를 즐기신다면 승산이 있다고 봅니다. 우리카지노 에이전트의 연락처는 홈페이지로 연락하시면 언제든지 부담없이 소통가능 합니다. 카지노사이트를 선정할때는 바카라를 다른곳보다 유리하게 즐길 수 있는 카지노를 선택해야한다고 생각합니다. 그것이 바로 우리카지노 입니다. 이상으로 우리카지노와 바카라 카지노사이트 사이의 상관관계를 알아보았습니다바카라사이트.

    ReplyDelete
  11. Tongkat Ali ist eine Pflanze beheimatet in Südostasien. Sie gehört zur Gattung der Bittereschengewächse und Ihr botanischer Name lautet “Eurycoma longifolia”. Es gibt noch eine weitere Reihe länderspezifischer Namen
    wie z. B. “Pasak Bumi”, wie die Pflanze in Indonesien genannt wird oder “longjack”, die allgemeine Bezeichnung für Tongkat Ali Kaufen in den USA, Kanada und Australien.

    Das Ursprungsland von Tongkat Ali Kaufen ist Indonesien, daher findet man auch dort auch die größten Bestände. Weitere Vorkommen gibt es in Ländern wie Thailand, Malaysia, Vietnam und Laos.

    Die Einnahme von Tongkat Ali Kaufen empfiehlt sich insbesondere für Leistungssportler, die einen schnellen
    Muskelaufbau und Muskelzuwachs anstreben und nicht auf illegale und künstliche Substanzen zurückgreifen möchten um Ihren Testosteronspiegel zu erhöhen.

    Generell empfiehlt sich eine Einnahme von Tongkat Ali für alle Männer ab dem 30ten Lebensjahr, da in dieser Phase nachweislich die Produktion von körpereigenem Testosteron zurückgeht. Dies macht sich vor allem dadurch bemerkbar dass die körperliche Leistungsfähigkeit nachlässt, die Lust auf Sex spürbar abnimmt und dadurch allgemein das Selbstwertgefühl negativ beeinflusst wird.

    Mit der Einnahme von Tongkat Ali können Sie nachweislich Ihre Libido steigern, Ihr Testosteron erhöhen und Ihre gewohnte Lebensenergie aus den jungen Jahren Ihres Lebens wieder herbeiführen. Hier können Sie übrigens weitere Informationen bekommen zum Thema ‘Libido steigern‘ ganz natürlich. Sollten Sie daran interessiert sein lohnt es sich auch unseren Artikel über Butea Superba zu lesen.

    Tongkat Ali wächst als Strauch und kann Höhen von bis zu 12 Metern erreichen. Typischerweise dauert es 10-15 Jahre bis solche Ausmaße erreicht werden. Der Strauch trägt anfangs grüne Blüten die sich im Laufe der Zeit, bis zur Reife, rot färben.

    Allerdings sind die Blüten im Hinblick auf die Wirkung der Pflanze weniger interessant. Der wertvolle Teil verbirgt sich unter der Erde.
    Im Laufe der Jahre wachsen die Wurzeln teilweise senkrecht und bis zu mehrere Meter tief in den Boden, was die Ernte zu einer schweren und mühsamen Arbeit werden lässt. Je älter die Wurzeln sind, desto höher ist auch die Anzahl der Wirkstoffe Butea Superba.
    Von daher gilt es einige Dinge zu beachten sollten Sie Tongkat Ali Kaufen wollen.

    ReplyDelete
  12. ChemLab Store Store provide you with top quaility research chemicals like: A-pvp, Methylone Crystals, Methylone Powder, Pentedrone Crystals, Pentedrone Powder, MDPV Powder, Buphedrone Powder, 4-FMC Powder, 4-MemABP Powder, NEB Powder, AMT Powder, 6-APB Pellets, Butylone Powder, MDAI Powder, 4-FA Powder, 4-FA Crystals, MPA Powder, Methoxetamine, JWH-122 Powder, JWH-122 Herbal Buds, Ketamine, AM-2201, Herbal Buds, We have a wide range of products including JWH-018, JWH-073, JWH-200, buy 34 dmmc online JWH-250, 4-MEC, 5-IAI, Phenazepam, 2c-i, Actavis Promethazine, Naphyrone, U-47700. Methedrone, crystal meth and other chemicals in all different amounts ranging from 5gm to 1kg retail and also large amounts at wholesale prices, When you buy Research Chemicals or bath salts from us you are guaranteed of the highest quality available on the market, high purity products, secure payment, fast and discreet international delivery.

    Disclaimer: None of the Products on ChemLab Research Chem Store are intended for human consumption and Neither ChemLab Research Chem Store,

    nor any of the staff INCLUDING the owner of ChemLab Online Chem Store resume ANY responsibility for ANY injuries to ANY individual who does not correspond with this warning and will not be held accountable for any loss or damages due to an individual burning, inhaling, or consuming into the body of any human being, animal or living specimen. This statement applies to all of the products sold on this site.

    By purchasing ANY PRODUCT ON THIS SITE, You Agree to be held 100% liable for any personal injury or damages due to you (Customer) using any of the products in any way other than that manufacturer’s instructions of use printed on the package!

    ReplyDelete
  13. Health Experts have proven that regular exercise coupled with a good diet allow you to live longer and healthier. In this busy day and age, not everyone has the time to go to the gym - resulting to a lot of overweight people that desperately need to exercise. A healthy alternative is for you to Buy Home Gym Equipments that you can store in your own home or even at your office. Here are some tips when buying home gym equipment.

    First, know your fitness goals and keep these goals in mind when you are buying home gym equipment. One of the biggest mistakes that people make is buying the biggest or trendiest fitness machine simply because they like how it looks. More often than not, these end up gathering dust in your storage rooms or garage because you never end up using them. It is important to take note of what particular type of physical activity you want or enjoy doing before you buy your exercise machine. If you are looking to loose a few pounds and you enjoy walking or hiking, a treadmill is the best option for you. If you are looking to tone your lower body while burning calories a stationary bike is your obvious choice. Similarly, Special Equipments for Core Strength Exercises, Strength Training Weight Vests, Core Strength & Abdominal Trainers, Home Cardio Training, Strength Training Power Cages, Strength Training Racks & More.

    Second, set aside a budget before Buying Home Gym Equipments. Quality exercise machines do not come cheap. They are constantly exposed to wear and tear when they are used properly. So, pick machines that are built to last and have passed quality certifications to get the most out of your money. If you are operating on a tight budget, think about investing in several weights, We can Provide you High Quality Home Gym Equipments at Very Low Prices for your Complete Uses: Core Strength Exercises, Strength Training Weight Vests, Core Strength & Abdominal Trainers, Home Cardio Training, Strength Training Power Cages, Strength Training Racks & More.

    Its the Right Time to Buy Home Gym Equipments for you at Very Low Prices.

    ReplyDelete
  14. Buy Dank Now began as an idea to create a top-notch delivery service for buy weed online in the US and quickly evolved in much more. Even though California accepted Safe to Buy Marijuana Online in 1996, we felt there was still a major lacking in quality and service. From what once started as a humble, flower-child type movement, evolved into the next California gold rush.

    Buy Dank Now Shop is committed to ensuring that your privacy and security is protected at all times, in fact, we care so much that we offer guaranteed stealth delivery to anywhere in the world at no extra cost! Buy Weed Online, Glo Carts, Glo Extracts, Glo Cart, Glo Cartridges, Glo thc Carts, Glo vape, Lions Breath Carts, Big Chief Carts and All orders are fully guaranteed, so whatever happens, nothing will ever stand between you and your weed!

    With literally thousands upon thousands of amazing strains from the best breeders in the world, ranging from famous cup-winners to potent, CBD-laden medical strains, High THC powerhouses, Glo Extracts, famous cheese to Buy Marijuana Online and Glo Carts popular white widow strains, all the way through to some of the rarest, hardest-to-find varieties in the world.

    Why Is Marijuana Effective for Treating Anxiety? Conventional medicine uses several different kinds of drugs to treat anxiety disorders, including serotonin reuptake inhibitors like Zoloft and tranquilizers like Valium. However, many patients don’t respond well to these medications. One of the non-psychoactive cannabinoids found in marijuana that is commonly used to treat anxiety is cannabidiol (CBD). Various scientists and researchers have experimented with both animals and humans to test the effectiveness of CBD for anxiety treatment.

    You can get it all right here at Buy Dank Now! Because we only ever work with breeders who meet our rigorous quality standards, you can be sure that whatever products you get from our Website such as, Glo Carts, Glo Extracts, Glo Cart, Glo Cartridges, Glo thc Carts, Glo vape, Lions Breath Carts, Big Chief Carts, they’ll make exceptional additions to your genetic library!

    ReplyDelete
  15. PMP certification is the globally recognized certification for project management. It is the validity given by the PMI Institute to candidates who clear certain education and professional criteria - Pass PMP.

    There are many ways to Pass PMP certification.

    [img]https://i.imgur.com/qh9wn8G.png[/img]


    Go for the heavy books, memorize them, sit for PMP trainings on your weekend, sit in the long, sleepy PMP video on demand trainings and still have the unsurety of passing the exam.
    Get PMP dumps, PMP practice exams, PMP review material and try to memorize hundreds of questions and still fear of forgetting some and getting new questions as PMP changes very frequently.
    Contact CBTproxy and through PMP proxy exam, get your PMP certification without any hassle.
    There are several sites selling PMP dumps and PMP exam questions which are 90% not reliable. Since there are always new questions in PMP exam, there is no reliability on the PMP dumps. Contact CBTproxy and through our PMP proxy exam, Pass PMP Certification without any hassle. We ensure first time passing guarantee and liberate the candidate from taking the real exam multiple times - PMP Brain Dump.

    ReplyDelete