Live data from Hacker News

Running ASP.NET Web API Services under Linux and OS X

piotrwalat.net

11–17 of 17 posts

Re: Running ASP.NET Web API Services under Linux and OS X

#11
post #2

It's sounds cool and all but would you run this in a production environment? I am a ASP.NET developer by day and Linux fan at night, but there is no way I can convince anyone run ASP.NET applications on Linux. I don't think you can reliably run ASP.NET applications on Linux. Or am I mistaken?

You will be, but not quite the way the author details. The OWIN [0] specification (which was solidified back in October 2012) was designed to completely separate .net web applications from their host (i.e. ASP.NET dependency on IIS). Similar to Ruby's Rack[1], it allows you to compose applications using one or more frameworks and/or middleware[2].

The KatanaProject [3], by MS, is a suite of projects for creating and hosting owin compatible web applications and is expected to see a v1 in the coming months. The ASP.NET (System.Web) host is already at v1[4](yes, asp.net can _host_ owin apps) and is used by SignalR [5,6] which is entirely OWIN based. Mono builds of KatanaProject are being worked on [7] (log on as guest). There are alternative non-MS hosts being developed, though not sure if any are serious projects yet.

A future version of ASP.NET MVC will support OWIN[8].

You can of course use .net alternate frameworks instead of ASP.NET, such as FubuMVC[9], Oak[10], NancyFX[11], ServiceStack[12]. I know that NancyFX and ServiceStack support mono (linux) as a first-class OT, concern.

OT, but you can even run node.js in-proc with OWIN based host.[13].

There is a lot going on in the .NET web app area!

[0] http://owin.org/

[1] http://rack.github.com/

[2] http://dhickey.ie/post/2012/12/16/How-I-am-using-OWIN.aspx

[3] http://katanaproject.codeplex.com/

[4] http://nuget.org/packages/Microsoft.AspNet.SignalR.SystemWeb...

[5] http://nuget.org/packages/Microsoft.AspNet.Signalr

[6] http://signalr.net/

[7] http://teamcity.codebetter.com/project.html?projectId=projec...

[8] http://aspnet.uservoice.com/forums/41199-general-asp-net/sug...

[9] http://mvc.fubu-project.org/

[10] http://amirrajan.github.com/Oak/

[11] http://nancyfx.org/

[12] http://www.servicestack.net/

[13] https://github.com/loudej/owin-js

Re: Running ASP.NET Web API Services under Linux and OS X

#12

I just got our production server for our new mobile game setup on AWS EC2 running a similar setup- Ubuntu, Mono, and Nginx. I wanted to use C# server side so I could share code with the client (a game written in C# + Unity3d). It was pretty easy to get up and running, even without running Visual Studio (I used Xamarin Studio (Monodevelop) for everything). I think it was a lot easier to get setup than this blog post m…

Asp.Net Empty Web Application is the base project for an IIS hosted... asp.net app. It just contains the bare minimum web.config and project settings to get started. Though there are too many project references imho. All asp.net projects are based off this. Asp.Net Web Forms Application is the original, and now derided, web framework. Consider it deprecated. Asp.Net MVC Web Application is comparable to Rails / Django…

Don't forget to add Service Stack to this list: http://servicestack.net/

Re: Running ASP.NET Web API Services under Linux and OS X

#13
post #2

It's sounds cool and all but would you run this in a production environment? I am a ASP.NET developer by day and Linux fan at night, but there is no way I can convince anyone run ASP.NET applications on Linux. I don't think you can reliably run ASP.NET applications on Linux. Or am I mistaken?

You will be, but not quite the way the author details. The OWIN [0] specification (which was solidified back in October 2012) was designed to completely separate .net web applications from their host (i.e. ASP.NET dependency on IIS). Similar to Ruby's Rack[1], it allows you to compose applications using one or more frameworks and/or middleware[2]. The KatanaProject [3], by MS, is a suite of projects for creating and…

Cool! I'll definitely read up on this.

Re: Running ASP.NET Web API Services under Linux and OS X

#14
post #6

Earlier quoted context omitted.

If you are running some simple web services in a cloud environment, it is generally cheaper to run them on a Linux system afaik there's not so much difference between a vps/virtual machine running Windows Server or Linux. I.e. for a cloud provider I'm using there's a difference of 5euro on a low level machine (30 euro) and same price for a more powerful machine (110euro for a 4 vcpu 8gb ram 50gb disk)

Mind telling us what provider are you using? It's hard to find a Windows VPS provider at decent prices.

I recommend taking a look at Microsoft's own hosting services (Azure). You can get either shared website hosting or VPSs running Windows or Linux.

http://www.windowsazure.com/en-us/pricing/calculator/?scenar...

Re: Running ASP.NET Web API Services under Linux and OS X

#15
post #12

Earlier quoted context omitted.

Asp.Net Empty Web Application is the base project for an IIS hosted... asp.net app. It just contains the bare minimum web.config and project settings to get started. Though there are too many project references imho. All asp.net projects are based off this. Asp.Net Web Forms Application is the original, and now derided, web framework. Consider it deprecated. Asp.Net MVC Web Application is comparable to Rails / Django…

Don't forget to add Service Stack to this list: http://servicestack.net/

That's more geared towards web services, i.e. a WCF replacement (even though it supports razor view engine). Mentioned it in a comment below anyway :)

Re: Running ASP.NET Web API Services under Linux and OS X

#16

I just got our production server for our new mobile game setup on AWS EC2 running a similar setup- Ubuntu, Mono, and Nginx. I wanted to use C# server side so I could share code with the client (a game written in C# + Unity3d). It was pretty easy to get up and running, even without running Visual Studio (I used Xamarin Studio (Monodevelop) for everything). I think it was a lot easier to get setup than this blog post m…

Asp.Net Empty Web Application is the base project for an IIS hosted... asp.net app. It just contains the bare minimum web.config and project settings to get started. Though there are too many project references imho. All asp.net projects are based off this. Asp.Net Web Forms Application is the original, and now derided, web framework. Consider it deprecated. Asp.Net MVC Web Application is comparable to Rails / Django…

NancyFx seems exactly what I was looking for. I only checked out ServiceStack but it seemed as equally complex as the Asp.Net stuff. Thanks a bunch.

Re: Running ASP.NET Web API Services under Linux and OS X

#17
post #8

I just got our production server for our new mobile game setup on AWS EC2 running a similar setup- Ubuntu, Mono, and Nginx. I wanted to use C# server side so I could share code with the client (a game written in C# + Unity3d). It was pretty easy to get up and running, even without running Visual Studio (I used Xamarin Studio (Monodevelop) for everything). I think it was a lot easier to get setup than this blog post m…

Are you using default garbage collector, or switched to SGen? http://www.mono-project.com/Generational_GC You may have memory usage problems http://stackoverflow.com/a/8766427/55209

Thanks a lot for bringing this up. After load testing a whole bunch today I was definitely seeing unexpected memory usage and unbounded growth.

I also ported my app to Nancy and load tested it as well. The performance was about the same and the memory usage grew as well but it seemed to eventually stop growing.

After reading a lot and trying (unsuccessfully) to make fastcgi-mono-server4 use mono-sgen I just gave up and went the console app self hosting route (using Nancy).

With self hosting my memory stays ultra low and doesn't grow. It also sped up the app quite significantly. My previous benchmarks were 10,000 requests served in 35-45 seconds (using fastcgi-mono-server4) and now I'm seeing 16-18 seconds (self hosting).

So yeah, self hosting is the way to go it seems.

Post reply on HN