Skip to content

Comment on Ask HN: How viable is F# on Mono for real-life web apps?

Comments

It's viable. Mono is very good these days. It's pretty rare that you find .NET libraries that are incompatible. I still use Visual Studio as an IDE but deploying to Linux is straightforward.

Your options are (realistically): Websharper - full web stack, transparent RPC. Hard to interop with native JS libraries like angular though.

Funscript - F# to JS compiler, more minimalist approach.

F# server side (REST api in Nancy/Fanciful/WebAPI) teamed with javascript front-end. Also well worth checking out Livescript, syntax is very similar to F# but dynamically typed.

See also: A relevant blog article I posted: http://thecodedecanter.wordpress.com/2013/06/22/hosting-webs...

My consultancy (just in case): http://www.perfectshuffle.co.uk

Always up for a chat if you have some ideas :) Shoot me an email through website above or PM me.

If you're using Mono for web hosting then don't use Mono's FastCGI implementation. It's incredibly slow from what I've seen. Instead, use something like evhttp-sharp which has a wrapper for Nancy. Just to give you an idea look at nancy using evhttp ("nancy-libevent2" in the benchmark) vs FastCgi ("nancy" in the benchmark) at http://www.techempower.com/benchmarks/#section=data-r8&hw=i7...

I've tried to contact the folks who are maintaining FastCgi on Mono but the email I sent last week bounced. When you use evhttp though, (at least with C#) there's not a huge performance difference than when using it in Windows.

Awesome, I wasn't aware of evhttp-sharp. On first glance it seems not to provide any Owin middleware compatibility, but it should be easy to do a small server factory that plays with Microsoft.Owin.Hosting and get that out of the box. I've also found https://github.com/Bobris/Nowin a while ago - very fast on Windows, but I can't get it to work on Mono 3.4 on linux, locks on the first request.

If you do make it OWIN compatible or a FastCGI wrapper for libevent that would be awesome. Right now, you need to basically have nginx proxy all the requests to evhttp which probably adds a little bit of overhead over doing it through FastCGI directly.

Edit: Actually from what I've seen, Mono uses epoll/kqueue for async IO which is what libevent uses as well. I think the problem might not be so much that libevent is faster than what Mono can do in plain C# but rather that the FastCGI implementation has some bottlenecks or is not using the most performant APIs available. I haven't had time to profile it though.

I second this. I worked on an ASP.NET MVC product that ran just fine on Mono. This was in the old 2.x days. While I didn't test FastCGI, the founder did, several times. He always told me mod_mono performed better.

I wonder what the TechEmpower benchmarks would look like if they used mod_mono instead of FastCGI.

Thanks, this is really useful!

Hey another follow up about FastCGI performance for those who are interested.

I asked on the mono dev list about FastCGI performance and it turns out there is a dev who wrote his own FastCGI implementation for Mono. It turns out that Mono uses .NET remoting to talk between the FastCGI process manager and the child processes and remoting is super slow. It would be interesting to see how it compares to evhttp but you can find the source here: https://github.com/xplicit/HyperFastCgi and his blog posts about profiling FastCGI here: http://forcedtoadmin.blogspot.com/2013/11/servicestack-perfo...

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.