5

I'm developing an ASP.NET application that will be run under Linux/Mono for various reasons (mostly to stay away from IIS, quite frankly). Of course the first web server I had in mind was Apache. But Apache, for all its advantages, adds a lot of overhead. Also, the application I'm building needs to be highly scalable and performance is one of the main concern.

Apache has, obviously, a very good reputation and its record speaks for itself, but I don't need things like Reverse Proxy or Load Balancing because dedicated network devices would be used for that. So those modules from Apache will never be used.

So basically my question is: since Nginx seems to fit exactly needs, is there any caveat I should be aware of? For instance, is Nginx renowned to be particularity safe? When security flaws are detected, how fast are they patched?

Any insight on the pros and cons of using either of those servers in conjunction with Mono is welcome.

Astaar
  • 438
  • 8
  • 18
  • 2
    If you know you are developing for Linux, why are you choosing ASP.NET? Just seems like a very odd choice. Mono is going to cause *WAAAAAYYYYYY* more overhead than Apache or Nginx will. – Aaron Brown Dec 16 '09 at 19:36
  • 2
    That may be. But ASP.NET is also much faster than PHP because it's compiled, and it's an amazing framework. I hate Microsoft as much as anyone, but in the case of web development, it's the technology with the fastest execution time, period. :-) If Mono causes too much performance degradation (I *will* load test the Web App under Linux/Mono and under Windows/IIS), I will calculate if buying Windows licenses will require less hardware than a free Linux license but with more hardware. – Astaar Dec 17 '09 at 11:19
  • 2
    I would respectfully disagree with all of your statements above, and the architecture choices made by some of the largest sites on the Internet (Google [Python], Facebook [PHP]) support my disagreement. Also, there is Java, opcode compilers for PHP such as eAccelerator, caching engines, etc, etc...Proper web architecture (caching layers, etc) are the right answers to performance and scalability, not hacks. If you are looking for performance, IIS or Mono are poor choices. Plus, you are just asking for trouble going with a Windows-based technology on Linux. – Aaron Brown Dec 17 '09 at 15:37
  • 4
    And yet, some equally large websites (including the one you are browsing right now, whose owners stated they went for ASP.NET because of its speed) still use ASP.NET. I would ask you to provide links to factual, neutral benchmarks comparing those various technologies because right now you are just a post on Internet with no argument backing up what he's saying - no offense. My question is about the merits of Nginx over Apache, though. – Astaar Dec 18 '09 at 11:46
  • 1
    What you don't get is that it's NOT about the language, or the front end - it's about architecture. All of the prominent web languages out there can perform if you plan your architecture well by using caching technologies (memcached, couchdb) on top. I'm just telling you that you are asking for a world of pain if you want to make ASP.NET work well on Linux. And no offense, but serverfault and it's cousins are not anywhere near the size of Facebook or google, which uses a traditional LAMP stack with memcached layers. Their existence and success proves my point that it's not the language. – Aaron Brown Dec 18 '09 at 17:29
  • Sorry, to clarify - I meant that Facebook uses LAMP, not Google. – Aaron Brown Dec 18 '09 at 17:31
  • 1
    Isn't the question "which is better, Apache or Nginx" ? – Greg B Jun 04 '10 at 12:26
  • I've looked heavily into building web applications in ASP.NET and running them on Mono, and I've found that you run into frequent difficulties with features present in .NET but missing or slightly different in Mono. It's a big enough problem to tarpit an entire undertaking and keep you from ever launching. Running Windows servers has always been out of the question for maintenance reasons for me. My advice is if you want an enterprise-y framework, use Java (Grails is a good choice) and if you want easy distribution, use PHP (Kohana is a good framework). – tylerl Dec 09 '10 at 06:37
  • 1
    ASP.NET (mono) or PHP compiled (using hip-hop from Facebook for example) are known to perform well on Linux (you can compare if using both compiled). Both can be enhanced using caching technologies, this is not a non-ASP.NET exclusive. It's having nothing to do with the language itself. Both PHP and ASP.NET are good and all depends on what you are more comfortable with and if it suits your needs. – Rui Marques Nov 17 '11 at 23:42

4 Answers4

4

ask yourself WHAT the application will be doing

lots of file I/O? well then apache's threading model is just fine, file I/O is blocking

long-running connections with clients? then nginx's event model is more appropriate, network I/O can be nonblocking

the most honest answer is that its unlikely you will be hitting the architectural limits of ANY webserver. just use whatever you are most comfortable with. the "overhead" arguments directed against apache's thread model are only meaningful in high-traffic scenarios.

Brad Clawsie
  • 411
  • 2
  • 7
1

I personally replaced my Nginx setup with Cherokee

So far everything is running just as fast and I have a web interface on top of that. It also support Mono.

Embreau
  • 1,277
  • 1
  • 9
  • 10
1

@ABrown: You're wrong on the point that ASP.Net is interpreted.

Applications/websites can be written in C# for example which are then compiled to an intermediate bytecode (IL). That's phase 1.

When a user initially visits the website, the byte code is then compiled to machine code.

Subsequent visits to the website invoke the machine code (it is not parsed or interpreted, it is executed natively).

Andrew
  • 231
  • 2
  • 8
1

Sergey Sysoev -- the author of nginx -- releases patches quite often. The webserver is very nice, and is capable of effectively running anything with the help of FCGI, either PHP or Mono or whatever. Nginx is also exteremely efficient in serving static content, and uses very little memory for all these keep-alives and slow ones. Additionally, it has nice features&modules available to resist DDoS attacks.

But look, every scripting language is slow. If performance is the main concern, maybe you'll better try to create a FCGI app in C?

Cheers! :)

kolypto
  • 10,738
  • 12
  • 51
  • 66
  • Thanks for the response. ASP.NET does not a scripting language though. It uses VB or C# (the app will use C#), which is compiled, and pretty much as fast as C. – Astaar Dec 17 '09 at 11:20
  • 1
    C# and VB are compiled in the same sense that Java is "compiled" They are not, and never will be "pretty much as fast as C." They are compiled to byte code (not machine code) and *interpreted* by the CLR. It appears that you are making a lot of assumptions based on flawed information. – Aaron Brown Dec 17 '09 at 15:40
  • 3
    ASP.NET will compile C# twice. First from the IDE it will build "Assemblies", which are indeed Byte Code. Then when these assemblies are executed for the first time, they will be compiled again as JIT (Just In Time), and converted from Byte Code to machine code. Theoraticaly, C# is as fast as C, although with C you can make a bit more tweaking since you have direct access to the memory pointers. – Astaar Dec 18 '09 at 12:45
  • Yes, but the JIT part occurs on execution, which slows things down considerably. It works basically like Java. C# will never and can never be as fast as C. The library overhead alone guarantees that. Anyhow, the point being is that your premise is flawed and ASP.NET is not the fastest, nor the best supported, nor does it have the best tools. Perhaps you are comfortable with it, but it's a lousy choice to run on Linux. – Aaron Brown Dec 18 '09 at 17:25
  • A nice proof: http://www.cppblog.com/images/cppblog_com/chipset/benchmarksJan2009Final.gif – kolypto Dec 18 '09 at 18:26
  • That's not really a proof of anything, Tync since it doesn't look like it tests things a web application would actually do. Mandelbrot sets? How about generating pages from a common database. I'm not in love with PHP, but looking at that thing, they'd have you believe that it is *3* orders of magnitude slower than Java at all tasks, which is quite obviously false. I do believe that calculating Mandelbrot sets and SpectralNorms is weak on PHP and Ruby, since they are not designed to do those type of things. PHP, Ruby, Perl, Python, are optimized for string manipulation, not calculation. – Aaron Brown Dec 18 '09 at 21:18
  • ABrown, you're right. I've googled a bit and found no representational benchmark data for C# vs. C in string operations :( But i'm sure good usage of C pointers can leave all opponents FAAR behind :) BTW it may be the reason of no benchmark data – kolypto Dec 18 '09 at 22:27
  • Oh, absolutely - C will be faster than almost anything. Of course, your webapp will likely be plagued with all sorts of exploits, buffer overrun problems, and not particularly maintainable, but who needs to worry about those things these days. (I was a C/C++ developer for several years...thankfully I left those days behind) – Aaron Brown Dec 19 '09 at 23:21
  • @AaronBrown: You're extremely biased against C#, almost trollish, derailing the Apache vs Nginx question in every comment. Do know about pre-compiling C# to avoid that 1st JIT hit? In fact, C# can be faster than C++ because the runtime's JIT can spit out more optimized machine code for the underlying architecture than C++ compiled code. End of the day C# is extremely close to C++ for the language features. FYI, I've been an assembly, C/ C++, C#, Objective C for embedded system on watch batteries to high end servers. http://journal.stuffwithstuff.com/2009/01/03/debunking-c-vs-c-performance/ – DeepSpace101 Jan 30 '12 at 18:12