Migration From .NET5 to .NET 6: Performance Benchmarks

Article Image

Introduction

This post continues the series of articles (Migration from .NET Core 2.2 to .NET Core 3.1 and How to Migrate a Project From ASP.NET MVC to ASP.NET Core) on upgrading the nopCommerce project – a free .net eCommerce CMS with an open-source code for creating online stores. This article discusses why we continuously strive to upgrade our application’s platform. 

Here we tell you what we achieved with migration to .NET 6 in terms of performance and try to evaluate our results practically.

Magic Terminal over Web Sockets and SignalR

Web based terminal access is one of those crucial components to have if you truly want to build your own DIY cloud system. The first time I came to appreciate web terminals, was with Digital Ocean's droplets, which gave me a web based terminal, allowing me to directly modify my server any ways I saw fit through my browser. Golly gosh that was a najs day.

With a web terminal, you've got all of these features "for free."

Dynamically resolving URLs in .Net 5

My favourite feature with .Net and C# is that it's a static programming language. This is also the largest problem I have with .Net 5 - As in, its blessing also becomes its curse. Simply because sometime I need a bit more "dynamic nature" than that which .Net provides out of the box. However, .Net 5 has a lot of interesting features, allowing you to circumvent this, opening it up for a more "dynamic nature". Let me illustrate with an example C# HTTP API controller.

C#
 




x
9
10


1
[Route("magic")]
2
public class EndpointController : ControllerBase
3
{
4
    [HttpGet]
5
    [Route("{*url}")]
6
    public async Task<ActionResult> Get(string url)
7
    {
8
        /* Do interesting stuff with URL here */
9
    }
10
}


Notice the [Route("{*url}")] parts in the above code? This tiny little detail implies that everything going towards "magic/xxx" will be resolved by the controller, and its "xxx" parts will end up becoming the url argument to our method.

Stop Coding, Start Configuring

Most apps have commonalities that can be extracted, where generalised solutions can be created, based upon patterns of reusable components. Some examples here are Angular Material, BouncyCastle, and MimeKit. All of the previously mentioned libraries assumes you want to achieve something specific, for then to create high level components, allowing you to solve your problems. This of course is the very foundation of "libraries", "frameworks" and "components". As in; Reusability is king. However, the same is also true for your resulting end app. If you look at your last application, you will find that it has at least some of the following moving parts.

  • It needs to authenticate users
  • It needs to authorise access to its parts
  • It needs to log events
  • Etc, etc, etc

The AOP promise

The promise of Aspect Oriented Programming was that instead of "coding" these generalised parts, you could "apply them as aspects" to your code. Such as the following illustrates.

Magic Cloud is now 100% Open Source

A year ago I created a personal Microsoft Azure account, and I installed one of my Magic apps on it. The cost for a small MySQL database server, a static webapp, and a small backend website ended up draining my bank account for roughly €200 per month (ugh!) - A year later I did the same exercise, except I created a VPS on DigitalOcean, and I more or less got the same for €10 per month. Don't get me wrong, Azure is kick ass cool, and contains tons of features your local VPS provider doesn't provide you with. However, with Magic I no longer saw the need for those extra features, simply because Magic has alternatives for all the most frequently missed items that Azure provides, and hence a VPS basically "becomes" a cloud and more, as I install Magic on it.

  • Diagnostics or application insights - Check!
  • Browsing and editing my server's file system - Check
  • Audit logging and easily querying my log - Check
  • User administration - Check
  • Etc, etc, etc ...

This of course, is before all the things that Magic does which I cannot even imagine Azure ever being able to do - Such as the ability to automatically create secured HTTP REST CRUD endpoints wrapping my database, and scaffold an entire Angular frontend around my backend, producing some 50,000 lines of code in some 3-4 seconds. Or the ability to dynamically "install" modules on my server on the fly, securely, almost like dragging and dropping them into my server's file system. And all of this is now 100% Open Source and free of charge to use. In fact, you cannot even buy a license even if you tried. And my license choices also allows for anyone to create closed source applications using Magic (duh!)

Creating a .Net 5 Web app from my PHONE

Interoperability is something I care a lot about, because not having it, is the equivalent of painting yourself into a corner, becoming dependent upon obsolete components, and sometimes even obsolete hardware. Once you dive as deep into the ideas of interoperability as I have done, you get interesting results - Such as the ability to create a .Net 5 Web API from a 5 year old phone. In the video below I am illustrating this process, and showing you how you can reproduce it for yourself, using nothing but pure Magic!

Of course, the whole point about the above video, is that Magic does all the coding for me, allowing me to simply declare which database and tables I want it to wrap, through a simple to understand Web API - Which results in that my backend is "generating" HTTP backend endpoints for me, wrapping all CRUD operations from my database, inside of their own unique URL, associated with the relevant HTTP verb.

No coding skills? No problem, use Magic!

A lot of the feedback I get about Magic originates from university students. I assume most of these are looking for data gathering tools to write their thesis in. For these to have a web based application, to gather data, seems to be an obvious advantage compared to having to drag laptops around with Excel or God knows what to store data within.

Anyways, I've just now release a new Release Candidate of Magic, where I've updated the entire frontend and middleware, in addition to fixing lots of backend bugs - and I would appreciate BETA testers. If you find at least one (severe) bug in it, and you document it Magic's GitHub forums, providing me with a reproducible, I'll throw you a free license as a thank you for helping me stabilise Magic.