Slide 1

Slide 1 text

Project Bedrock Laying the foundation for the .NET Networking stack

Slide 2

Slide 2 text

Why? • Writing good networking code is hard. • Usually full of manual memory management. • Tight control over threading. • Dealing with untrusted clients is usually an after thought (security is hard) • Good networking code is the core of lots of applications and components • HTTP Client/Servers • Database drivers • Proxies/Gateways/Routers • Caches • Core APIs only cover the basics

Slide 3

Slide 3 text

Why? • New transport protocols appear all the time. Applications shouldn’t have to rewrite their networking stack to take advantage. • HTTP/2 • QUIC • Aeron • The ecosystem needs primitives to build application protocols on top of. • Without a trusted solution, the ecosystem recreates protocol implementations that aren’t reusable. • It allows experts to innovate at different parts of the networking stack while still leveraging other reusable components. • We can swap out the SSL implementation with something more efficient and still use ASP.NET Core and Kestrel. • Remove boilerplate from writing parsers and protocols. • Provide helpers to protocols authoring easy and efficient.

Slide 4

Slide 4 text

Landscape • Java – Netty https://github.com/netty/netty • Rust – Tokio https://tokio.rs/ • Swift – SwiftNIO https://apple.github.io/swift- nio/docs/current/NIO/index.html • ServiceTalk - https://apple.github.io/servicetalk/servicetalk/SNAPSHOT/ • .NET – DotNetty https://github.com/Azure/DotNetty (port of the java framework)

Slide 5

Slide 5 text

The Solution • We built SignalR and Kestrel on top of the same networking primitives. • We’ve been our own customers of this tech and have hardened it over a couple of .NET Core releases. • We have a couple of OSS projects using it already. We’re starting to see some demand from internal teams. • Orleans is using it and saw a 30% performance improvement. • MQTTnet is a popular OSS MQTT library built on top of it • Redhat built a better linux native sockets implementation on top. This beats our implementation on the TechEmpower benchmarks. • CoreWCF is built on top of this it.

Slide 6

Slide 6 text

The Solution: Ecosystem • We want to seed an ecosystem of reusable application protocol implementations. • This should be a community driven effort, but we can seed implementations from .NET Core. • HTTP • WebSockets • TLS • AMQP • MQTT • …

Slide 7

Slide 7 text

Architecture • The design is centered around 3 core concepts • Transports • Middleware • Protocols • ProtocolReader/ProtocolWriter • IMessageReader/IMessageWriter • Transports have support for both a server and a client • Servers and clients only differ in how they obtain a connection. • Single connection abstraction for server and client • Cross cutting concerns are middleware and can be applied to both servers and clients. • Protocols are terminal middleware (the last one in the chain) that transform the byte stream into other frames.

Slide 8

Slide 8 text

Architecture: Connection abstraction • An abstraction over a connection shared between client and server • Loosely based on the same ideas ASP.NET Core’s HttpContext • “Features” allow the transport and middleware to flow rich context to the other layers in the stack.

Slide 9

Slide 9 text

Architecture: Transports IConnectionListener IConnectionFactory .NET Sockets Libuv WebSockets Named Pipes QUIC

Slide 10

Slide 10 text

Architecture: Middleware Connection Middleware (ConnectionDelegate) TLS Logging Compression Throttling Metrics

Slide 11

Slide 11 text

Architecture: Protocols ConnectionHandler HTTP MQTT AMQP SignalR RSocket

Slide 12

Slide 12 text

Architecture: The pipeline Transports Middleware Protocols

Slide 13

Slide 13 text

Architecture: The pipeline IConnectionListener Transport IConnectionFactory Connection Middleware Protocols

Slide 14

Slide 14 text

Example: HTTP Server/Client Sockets TLS ConnectionLimits Http1/Http2 QUIC ConnectionLimits Http3

Slide 15

Slide 15 text

Contribute to the project https://github.com/davidfowl/BedrockFramework @davidfowl