On July 30th, Microsoft hosted the latest online .NET Conf. The topic was “Focus on Microservices”. Many famous speakers like Scott Hunter, David Fowler, Kelsey Hightower, or Jessica Deen talked a whole day about microservices. In this post, we will summarize most of the talks. You can find all talks here.
Welcome to .NET Conf: Focus on Microservices
by Scott Hunter & David Fowler
The virtual conference kicked off with a keynote by Scott Hunter where he talked about the current state of .NET Core and the next version .NET 5.
The current State of .NET Core
According to the Stack Overflow developer survey, ASP .NET Core is the most loved framework in 2019 and 2020 (Stack Overflow survey). .Net Core is one of the highest velocity OSS projects, C# is a top 5 language on Github and ASP .NET Core is 7x faster than Node.js.
Last year there were more than 600K new monthly .NET Core developers and more than 2 million publishes from Visual Studio on Linux. Also, .NET Core 3 was the fastest adopted version of .NET ever.
The Future of .NET Core
The next version of .NET Core will be released in November 2020 and is called .NET 5. .NET 5 will replace .NET Core and also will unify the .NET environment. This means that, for example, .NET Standard won’t be needed anymore. The version is 5 instead of 4 to prevent confusion between the new .NET and the existing .NET framework (4.8.x). Microsoft plans to release a new version every November whereas every even number (starting with version 6.0) will be an LTS (long term support) version.
Introduction to Microservices
After Scott Hunter was finished David Fowler introduced microservices and why they became so popular over the last couple of years. The main advantages of microservices are:
- Independent deployments
- Smaller, more focused teams
- Improved scalability
- Higher resource utilization
- Run the same code everywhere because microservices run in containers –> no more “But it works on my machine”
Microsoft expects that by 2020 more than 75% of global organizations will run containers in production. The reasons for the growth are that containers are widely used, they are vendor-neutral (e.g. you can run them in every cloud environment) and they have great community support.
With more containers running in production, you will need a platform to manage all these containers. This is where Kubernetes comes into play. Kubernetes is an orchestrator for these containers and takes care of scaling, load balancing, and monitoring of the containers. Cloud Vendors like Azure provide managed Kubernetes services (AKS in Azure), which makes it very easy to set up and get started.
Microservices with .NET Core can be shrunk to around 30 MB.
After the introduction to microservices, David did the following demos:
- A .NET Core Web API with Swagger and HttpRepl to have a GUI and command-line window for your API. Also he showed how to generate code from the API through Swagger.
- Creating a gRPC server from the Swagger file and a client from the generated proto file.
- Running the application inside Visual Studio on Linux with WSL2. You can also debug inside Linux.
- Introduction to Tye to run the server and client application with a single command. Additionally, you could see logs for all applications and run them inside a container without a Dockerfile. Tye can orchestrate applications that are running locally and remotely. The demo showed how the server and client sent data to an external Raspberry Pi. (There is a session about Tye later)
You can find the start of the video here.
Build High-performance Microservices with gRPC and .NET
by James Newton-King
gRPC is a popular open-source remote procedure call framework, CNCF project. It is built with modern technologies like HTTP/2 and Protobuf and was created in 2015. gRPC is designed for modern apps, but especially microservices and it is high performant and platform-independent.
Protobuf is an IDL (interface definition language). It describes once the interface and then can generate code for any language.
gRPC uses a binary format for network transmission compared to text-based JSON, therefore it is very fast and small.
RPC vs HTTP APIs
|Contract first (proto file)||Content first (URL, HTTP method, JSON)|
|Contract is for humans||Content is for humans|
|Hides remoting complexity||Emphasis HTTP|
|Focuses on performance and developer productivity||Focus on ease of getting started and has the widest audience|
Starting with .NET Core 3, Visual Studio ships a basic gRPC template and James Newton-King showed in a Demo how to use it. For more information see Microsoft’s documentation.
You can find the start of the video here.