简体   繁体   English

ASP.NET Core和Node.js的相似之处

[英]ASP.NET Core & Node.js similarities

I have been using Node.js for a while now. 我一直在使用Node.js。 I know how it works internally (eventloop and other stuff) to a good extent but ASP.NET Core looks so similar to Node.js. 我知道它在内部如何工作(eventloop和其他东西),但ASP.NET Core看起来与Node.js非常相似。

ASP.NET Core - Uses Kestrel (basically a fork of libuv)
Node.js - Uses libuv

ASP.NET Core - Tasks (though present in previous ASP.NET versions too)
Node.js - Promises

ASP.NET Core - Async/Await (though present in previous ASP.NET versions too)
Node.js - Async/Await

So, are the following conclusions correct: 那么,以下结论是否正确:

Node.js has only a single thread for executing javascript code (sync) and many worker threads for background async operations. Node.js只有一个用于执行javascript代码(sync)的线程和许多用于后台异步操作的工作线程。

ASP.NET Core uses multiple threads for executing .NET code (sync) and many worker threads for background async operations. ASP.NET Core使用多个线程来执行.NET代码(同步)和许多工作线程用于后台异步操作。

Node.js enforces I/O to be async so you don't block the event loop but in ASP.NET user can do sync I/O too hence blocking the thread, but since it uses multiple threads the whole app doesn't get blocked. Node.js强制I / O为异步,因此您不会阻止事件循环,但在ASP.NET中用户也可以同步I / O因此阻塞线程,但由于它使用多个线程,整个应用程序无法获取受阻。

I've no in depth information about Node JS, but based on your first part of comparison about kestrel and libuv, I should say that ASP.NET core is server independent. 我没有关于Node JS的深入信息,但根据你对kestrel和libuv的第一部分比较,我应该说ASP.NET核心与服务器无关。 (I'm not talking about front web servers such as IIS, Apache, ...). (我不是在谈论前端Web服务器,如IIS,Apache,......)。 There is a interface in ASP.NET Core named IServer, any implementation of that can be a asp.net core app server, Kesterl is one of your choices, You can use any Owin Compatible server or any other servers such as nowin & web listener. ASP.NET Core中有一个名为IServer的接口,任何实现都可以是asp.net核心应用服务器,Kesterl是你的选择之一,你可以使用任何Owin Compatible服务器或任何其他服务器,如nowin和web listener 。 ASP.NET core is pipeline independent (I'm not talking about middlewares), for example you can use Owin pipeline, asp.net core default pipeline and you can develop your own pipeline too. ASP.NET核心是管道独立的(我不是在谈论中间件),例如你可以使用Owin管道,asp.net核心默认管道,你也可以开发自己的管道。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM