6

still trying to understnad node.js...

  1. If I apply the asp.net async pattern for every i/o operation, and configure maxWorkerThreads=1, is it (conceptually) similar to node.js?

  2. Does an i/o operation (in either framework) takes place in its own thread or is there some OS functionality to get notifications / light thread?

  3. this SO thread says that node.js still uses threads internally so it is not such a big difference from asp.net. Some answers say that yes, but it is a better programming model etc. Which threads does the question refers to, lightweight i/o like the ones I asked on in #2?

Community
  • 1
  • 1
Yaron Naveh
  • 23,560
  • 32
  • 103
  • 158
  • 1. possible duplicate of [What so different about Node.js's event-driven? Can't we do that in ASP.NET's HttpAsyncHandler?](http://stackoverflow.com/questions/5599024/what-so-different-about-node-jss-event-driven-cant-we-do-that-in-asp-nets-htt) – Raynos Aug 13 '11 at 12:23

1 Answers1

6
  1. See this similar question

  2. As for the i/o operations that's implementation specific. the linux backend uses libev and the windows backend uses IOCP. See this video on async i/o details for windows/linux

  3. node.js only uses threads internally because linux doesn't have an async IO system (like windows does with IOCP). So to make async IO possible you need an internal thread pool. See the video.

Community
  • 1
  • 1
Raynos
  • 166,823
  • 56
  • 351
  • 396
  • #1 - so if I make asp.net single threaded also as I described is it similar or is it still totally different? #3 - so in linux we still create threads like a classic server would do, it is just that we create them only when needed (i/o starts) and the programming model is better? – Yaron Naveh Aug 13 '11 at 13:17
  • @YaronNaveh I don't know how the internal thread pool handles IO. Go read about libio and libev – Raynos Aug 13 '11 at 13:43
  • 1
    @YaronNaveh as for #1 it's conceptually the same but the coding style, community and 3rd party libraries are vastly different. we're also talking about using ASP.NET on a very low level. The moment you start using controls or any of the abstractions ASP.NET offer you will probably start to block. Not to mention that ASP.NET is horribly bloated for this task – Raynos Aug 13 '11 at 13:45
  • asp.net is really only bloated when you think about the page model and control model implemented when you consider an async page. When you consider an async handler, the overhead is quite minimal. – Adam Carr Nov 08 '11 at 03:29
  • @AdamCarr to me personally, ASP.NET is bloated because I can't understand how it works as a framework. node.js is light and agile, you can quickly get to grips with what it's doing. This may be a limitation of me understanding .NET or it may be a difference of learning resources and attitude. – Raynos Nov 08 '11 at 09:50