This is a simple walk-through for anyone to get an idea about what’s happening in these 2 leading technologies. I was wondering about the same issue and wanted to find out if there is a real winner

One thing I noted was that the .NET core is backed up by Microsoft in a very positive way. This is really good and with the Microsoft tag in them, it has created a professional-level programming environment with supporting tools like Visual Studio. Visual Studio has made it easy in building, debugging, and publishing the .NET C# code over multiple platforms and devices.

Introduction

.NET Core

.NET is an open-source software development framework that was initially owned by Microsoft and then released to the open-source community. Initially, it had 2 branches like the .net framework which runs only on Windows, and the .net core which is cross-platform. But from .net core version 3, Microsoft stopped the earlier .net framework support. All the future releases are only .net Core versions and they are rebranded as .Net. NET Core is famous for building modern cloud-enabled, Internet-connected apps.

Node.js

Node.js is an open-source runtime environment to develop fast and scalable network applications. Node js is built on chromes javascript runtime which is called the V8 engine. Node js is highly preferable in data-intensive real-time applications as it uses an event-driven, non-blocking I/O model. Node js is not much preferred in developing process efficient applications such as video and audio processing.

Processing Model Difference

Node.js

Node.js runs on a single thread so it uses fewer resources than traditional process request methods. What happens inside node.js request handling is it takes a request and if it can be processed immediately, sends the response. If it’s a time-consuming API call or long-running job pass it to the event loop and continue to the next incoming request. After the event loop has processed the request, the response is sent back using a callback function.

.Net core

Someone may think that the .NET core may be using only the old blocking thread pool method to handle requests, That’s what I thought at the beginning. But .Net core provides excellent support for using asynchronous programming patterns.

An example DbContext.SaveChanges is a Synchronous(blocking) method of saving to the database while DbContext.SaveChangesAsync can be used to save data Asynchronously.
Net core also has an I/O completion method to handle asynchronous requests where the allocated threads are not waiting until the response arrives. NET core can also handle heavy resource-consuming requests like encoding and decoding videos and audio. .NET core gives a good competition when it comes to handling concurrent tasks. But as I said node.js loses out to .NET when requests become CPU intensive.

Performance

When it comes to performance we have to be really careful about the use cases which is used in measuring the performance. What we have to understand is that being Fast and handling Load is two different scenarios. Like that performance varies in each use case.
A Server can be fast when processing a single request per second while it gets slow when handling 500 requests per second(Load).

Node js is popular for handling load. Because .NET dedicates a single thread for each request from the thread pool. When it gets out of the threads, requests get qued up. But if the requests are non-blocking It won’t be a problem again. So you can see the type of requests also affects the performance.

Not only that the type of web page it renders also matter. For rendering static pages .Net core wins probably because of its in-built IIS server. IIS uses kernel-mode caching, which means that requests requesting the static page are not even going to get out of the kernel

from the .net core side, it can handle highly CPU-intensive tasks better than node.js. And .Net core is highly pushing its limits on each release. With its newest release .Net core gRPC server performance is above other leading languages like Java, Go, and C++.

.NET Core

I came across a kind of benchmarking website which was used by different YouTubers and even mentioned in the official .NET core presentations by Microsoft. So I got the below benchmarking charts from Techempower.com

Bench Marks from Techempower.com

Best plaintext responses per second, Dell R440 Xeon Gold + 10 GbE(8 tests)

These were simple requests to get Hello World text responses.

Latency

Remember that lower latency is better. Even though the graphs show a huge difference these are in milliseconds. And will not be much effective unless you are building projects with a really high volume of requests

Processing Single Queries

A single query request was sent to get the response.

Requirements summary

In this test, each request is processed by fetching a single row from a simple database table. That row is then serialized as a JSON response.

Example Response

Best database-access responses per second, single query, Dell R440 Xeon Gold + 10 GbE(26 tests)

Latency of database-access responses, Dell R440 Xeon Gold + 10 GbE

Here Node js has the lowest latency but it’s in milliseconds which is negotiable.

Processing Multiple Queries

Requirements summary

In this test, each request is processed by fetching multiple rows from a simple database table and serializing these rows as a JSON response. The test is run multiple times: testing 1, 5, 10, 15, and 20 queries per request. All tests are run at 512 concurrency.

Example Response for 10 Queries

Responses per second at 20 queries per request, Dell R440 Xeon Gold + 10 GbE(25 tests)

Multiple Querries Latency

With the techempower.com performance charts .Net core shows a clear high performance in various aspects. I did the same tests changing the physical DB to cloud DB and there was no difference. Net Core showed higher performance.

Above is a benchmark performance that was taken from the .Net 6 introductory video on the Microsoft Developer youtube channel. With new updates .Net is more optimized with increased performance.

Community support

When it comes to Community support both of them have active and strong community support. Node.js was on GitHub from the beginning so it has strong community support in GitHub. While .Net Core has huge community support in Stack Overflow.

It seems that .NET core is booming with its community support as well. Official Dotnet youtube channel uploads valuable content daily engaging the community in a positive way.

Platform Support

Node.js runs on multiple platforms from the start. That was a reason it got more popular. It officially supports Windows, Linux, macOS, SmartOS, and IBM.

.NET core had a separate approach where it was initially built only to work on Windows platforms. But from 2018 it went through a massive revolution and from NET core 3.1 version runs on Windows, Linux, and macOS.

Node.js Use Cases

Node.js is better at handling multiple tasks simultaneously due to its single-threaded event loop. Node.js was designed as an alternative to Apache HTTP Server. Node.js is based on javascript and developers can use a single language to write both front end and backend.

Developers can use pre-written code from the node package manager(npm) and use the modules for quick and efficient programming.

Node.js can handle a high amount of traffic with stable requirements without needing to increase the server capacity. Node.js tends to handle all its requests in an asynchronous manner with its highspeed V8 engine and single-threaded asynchronous model.

Advantages Of Using Node.js

  • Can use a single language JavaScript to perform both front end backend development
  • Node is cross-platform and asynchronous by origin.
  • Support of NPM package manager to use external modules
  • Code modularity causes less dependency inside the project and exported modules can be used in multiple projects without any side effects on existing code.

.Net Core Use Cases

.NET core is based on object-oriented programming language C#. It also can be used to build projects with F# language. The .NET core ecosystem provides prebuilt class libraries including both simple and complex data structures. Net core also provides specific libraries for database access, security, encryption, and database access. These libraries can be used in graphic rendering projects database interactions and XML manipulations.

.NET core unlocked the possibility of cross-platform application development as well. Net core can be used within a vast variety of development requirements such as Desktop, Web, Cloud, Mobile, Gaming, IoT, and AI.
Due to its modular and scalable nature, .NET can be used to build microservices. so .NET can be used to build highly scalable systems with microservices to give an efficient user experience.

Office Add-in Development

Most of the companies and enterprises use Ms office or office 365 in their work. Developing office-addins to extend the ms office capability can be done using .Net.

Advantages of Using .Net Core

  • Possibility of separation of concerns
  • Reduced coding time with inbuilt libraries
  • Security
  • Supportive coding environment and tooling with Visual Studio
  • Cross-Platform support
  • Development and deployment across multiple platforms Cloud, IoT, Desktop, etc.

Popular companies that shifted to Node.js

PayPal, Netflix, Uber, LinkedIn, eBay

Popular companies that shifted to .NET Core

Chipotle, UPS, GoDaddy, Asgard Systems, Siemens Healthineers

Conclusion

Throughout the exploration even though most of the benchmarking results were towards .Net Core. Things may depend on the requirements of the project, hosting requirements as well. But I noted that .Net core has started to move forward passing node with the support of Microsoft and its enterprise-level influence. So I think .net core is taking the lead with all these benchmarks and with cloud support.

And Node.js is written on top of the V8 which again uses C++. So node has another layer below which includes extra work when compiling the code. But .NET core creates a .dll which is in a way closer to the machine-readable side. Because In the end, all that matters is how fast that the code gets compiled.