Optimizing .NET Code using Benchmarks

Background Oftentimes, we come across situation where code does not perform as per expectation. What is typically approch to address it, Performance Testing - Visual Studio Load Tests or Third party tools like Locust, Vegeta, Gatling etc. Visual Studio Diagnostics Tools Or Use tools like Perfview/dotTrace/dotMemory to diagnose bottlenecks What if it is possible to Benchmark code for, Set of varying parameter(s) Different runtimes (.NET Framework versions, .NET core, Mono etc.) with option to Benchmark it Observe Memory Allocations for diagnostics Get Detailed report on execution timeline Have it as part of test suite so that it can be easily executed with every iteration involving optimized code to get immediate feedback Enter BenchmarkDotNet, a Powerful .NET library for benchmarking. It is used by DotNET Team, Roslyn, ASP.NET Core and many other projects. ...

May 5, 2020 · 2 min · Sachin Sunkle

ASP.NET Core - Mind the SameSite HTTP Cookie settings

Background A Web Application, developed in ASP.NET Core (Runtime Version 3.1.100) using Razor Pages and Web API, is expected to be launched from within third-party Web Application in iframe, with complete HTML being rendered. During the Development, a mock HTML Page was developed to simulate launching of ASP.NET core based Web Application in iframe. Note that this page as well as Application was hosted on same IIS Server and it worked fine. Subsequently, Web Application was deployed on Test Server and URL was shared for integration with third party Application and then it happened Boom…. i.e. Application when launched in iframe rendered HTML but none of the post request would work (returning HTTP Error 400). Careful inspection showed that, ...

April 9, 2020 · 3 min · Sachin Sunkle

Using Channels for High performance Producer consumer implementation

Background Recently, i got involved in assignment where in an application was facing issues with throughput. Expectation is to support more than 500 transactions per second while load testing results were indicating system was experiencing high latency beyond 100+ transactions per second. This application is developed in .NET Framework + .NET Core and primarily uses Relational Database for persistence and has point to point integration (mainly over HTTP) with internal & external application(s). ...

February 12, 2020 · 3 min · Sachin Sunkle

Using .NET standard Assembly in .NET core and .NET Framework

Background One of the key project(s) at my current organization is developed on .NET 4.6.1. It is developed as Modular Monolith. As part of it’s functionality, it supports different channels like Mobiles, Terminals and Web. For the Web channel, there was need to develop a Web application with, High availability Lightweight, High throughput (Need to support few thousand(s) active users) Accordingly, we have been exploring developing this Web Application in .NET core 3.1. However, it also means that we will have to use class libraries, targeted at .NET framework 4.6.1, in .NET core and vice-versa. How can this be done? ...

February 7, 2020 · 3 min · Sachin Sunkle

Even Eric Evans explicitly states that DDD isn’t suitable for problems when there’s substantial technical complexity, but little business domain complexity. Using DDD is most beneficial when the complexity of the domain makes it challenging for the domain experts to communicate their needs to the software developers. By investing your time and effort into modeling the domain and coming up with a set of terminology that’s understood for each subdomain, the process of understanding and solving the problem becomes much simpler and smoother ...

6 min · Sachin Sunkle