Why use ValueTask?

Allocations and Scalability

Task is a reference type, which means every time you await a task, it is allocated on the heap. As in many applications today, you are likely to have a method in your code that either runs synchronously or asynchronously depending on a condition, like whether or not some data is already stored in memory or it needs to be loaded from a longer running I/O operation. A common example in a web application would be storing infrequently changing data into a caching layer to increase the performance of subsequent reads of that data.

Read More

gRPC Server to Client Streams

HTTP/2 and gRPC

HTTP/2 has solved many of the problems that web technologies faced with using HTTP/1.x protocols. Features like multiplexing over a single TCP connection and binary transport have foster adoption of enhanced data transfer tech such a gRPC which is a Cloud Native Computing Foundation incubation project.

Read More

ASP.NET Core on Kubernetes

Containerized .NET Web Apps

No matter what your language/framework/platform of choice is, it is hard to go anywhere in this industry today without hearing people constantly bringing up terms such as Docker, Kubernetes, Helm, Containers, Microservices… . The list of constant buzz words can go on for days and if you are anything like me and just try to dive right into the docs, learning these technologies can seem initially like a daunting task. I found my biggest hurdle, after conceptualizing these concepts, was setting up an application with the proper structure and tooling that would even allow me to run in a container or on a k8s cluster.

Read More

.NET Options Pattern

Strongly Typed Configuration Values

Using the options pattern allows you to define classes that provide strongly typed configuration groups available in dependecy injection. There are 3 main types that are used when requesting options from DI, IOptions<T>, IOptionsMonitor<T>, IOptionsSnapshot<T>. In order to properly bind to the defined classes, they must be non-abstract public classes with a public parameterless constructor as well as having public read-write properties.

Read More

.NET Console App with Platform Extensions

.NET Platform Extensions FTW

Of all the things I have enjoyed with .NET core and the new unification in .NET 5.0, the new platform extensions have been one of my favorites. Never have I had such a simpler experience of adding logging or dependency injection to a basic console application than with the extensions suite that the dotnet team has added. NuGet Packages such as Microsoft.Extensions.Logging or Microsoft.Extensions.DependencyInjection.

Read More