Architecture Overview: David Fowler Software Architect
Architecture Overview: David Fowler Software Architect
NET Core
Architecture overview
David Fowler
Software Architect
What is ASP.NET Core?
• Cross platform web platform from the .NET team
• Similar concepts as previous versions of ASP.NET but not binary
compatible
• Can build a wide range of application types
• REST APIs or gRPC services
• Single Page Applications with Blazor
• Server Rendered web applications with Razor Pages
• Real time web applications with SignalR
ASP.NET Core Design principles
• Various components of the stack should be independently usable
• Only pay for things you that you use
• Performance is paramount
• Code over configuration
• Composition via dependency injection
• Extensibility points used by the framework should be usable by
anyone
• No statics, it should be possible to run multiple applications in the
same process and not conflict.
ASP.NET Core is fast
http://aka.ms/aspnet/benchmarks
M = Million(s) RPS
ASP.NET Core: TechEmpower benchmarks
ASP.NET Core Architecture
Routing
Middleware
Host
The focus of this talk
Routing
Middleware
Host
Overview
1. Application bootstrapping
2. Anatomy of a request
Application Bootstrapping
Host WebHost
• Initialize the dependency injection, • Builds middleware pipeline
logging and configuration systems • Starts the server with the
• Start the IHostedService application
implementations.
• Manages the lifetime of the
application.
Application Bootstrapping: Host
Host WebHost
• Initialize the dependency injection, • Builds middleware pipeline
logging and configuration systems • Starts the server with the
• Start the IHostedService application
implementations.
• Manages the lifetime of the
application.
Host: Microsoft.Extensions.*
• Responsible for bootstrapping the dependency injection, logging and
configuration systems.
• Abstracts how the underlying platform manages lifetime for startup
and shutdown (e.g. windows services, cloud services)
• Provides abstractions for getting environment information.
• Notifies hosted services on start up and shutdown.
Host Architecture: Microsoft.Extensions.*
Host
IServer
Server
• Listen for incoming requests
• Responsible for the core request handling logic
• Produces an IFeatureCollection for request execution
• ASP.NET Core has a minimum set of features it expects all IServers to
implement.
• May expose additional server specific functionality (e.g. server variables in IIS)
• Call into the IHttpApplication registered with the server when
requests arrive
Server: Kestrel
• Cross platform
• Written entirely in managed code
• Extremely optimized
• Supports HTTP/1, HTTP/2, HTTP/3 (preview)
• Pluggable transports (see project bedrock)
• Default transport uses Sockets
• Other protocols are possible on top of transport abstraction
Server: Kestrel Architecture
w3wp.exe
w3wp.exe App.exe
Endpoint
ExceptionHandler HttpsRedirection Route Matching UseAuthorization
Execution
Endpoint
ExceptionHandler HttpsRedirection Route Matching UseAuthorization
Execution
Middleware definition
Reference to the next middleware
Add authorization
metadata
Endpoint Metadata
Build Apply
Discover Build
application conventions to
controllers endpoints
model model
MVC : Request Processing
ControllerActionInvoker
ControllerActionInvoker