O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

ASP.NET Core 3.0 Deep Dive

148 visualizações

Publicada em

An in-depth look at ASP.NET Core 3.0 - presented at DOTNET KONF Istanbul 2019

Publicada em: Tecnologia
  • Login to see the comments

ASP.NET Core 3.0 Deep Dive

  1. 1. Upgrading to ASP.NET Core 3.0
  2. 2. https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30
  3. 3. Blazor
  4. 4. https://... JS
  5. 5. C#
  6. 6. .NET
  7. 7. How Blazor WebAssembly works https://... DOM Razor Components .NET WebAssembly
  8. 8. Blazor on client or server https://... DOM Razor Components .NET WebAssembly https... DOM .NET Core SignalR Blazor WebAssembly Blazor Server Razor Components .NET .NET Core 3.0May 2020
  9. 9. Blazor on client or server Blazor WebAssembly Blazor Server .NET Core 3.0May 2020
  10. 10. https://blazor.net
  11. 11. Build your own pizza store UI with Blazor https://aka.ms/blazorworkshop
  12. 12. https://www.telerik.com/blazor-ui “Telerik UI for Blazor components have been built from the ground-up to ensure you experience shorter development cycles, quick iterations and cut time to market” “DevExpress UI for Blazor ships with 12 UI components (including a Data Grid, Pivot Grid, Charts and Scheduler) so you can design rich user experiences for both Blazor server-side and Blazor client-side platforms.” https://www.devexpress.com/blazor “The Syncfusion ASP.NET Core Blazor Components library is the only suite that you will ever need to build an application, containing over 60 high-performance, lightweight, modular, and responsive UI controls in a single package.” https://www.syncfusion.com/blazor-components
  13. 13. https://aka.ms/awesomeblazor https://gitter.im/aspnet/blazor
  14. 14. • Blazor: https://blazor.net • Docs: https://blazor.net/docs • .NET Core 3.0: https://dot.net/get-core3 • Visual Studio: https://visualstudio.com/ • Workshop: https://aka.ms/blazorworkshop • Community: https://aka.ms/awesomeblazor Try Blazor today!
  15. 15. gRPC
  16. 16. gRPC is… • Popular open source RPC framework • Largest RPC mindshare • Cloud Native Computing Foundation project • gRPC stands for gRPC Remote Procedure Calls • Built with modern technologies • HTTP/2 • Protocol Buffers • Designed for modern apps • High performance • Platform independent + =
  17. 17. Protobuf (aka Protocol Buffers) • IDL (interface definition language) Describe once and generate interfaces for any language • Service model Service method and structure of the request and the response • Wire format Binary format for network transmission syntax = "proto3"; message SubscribeRequest { string topic = 1; } message Event { int32 id = 1; string details = 2; } service Topics { rpc Subscribe(SubscribeRequest) returns (stream Event); } 5052 4920 2a20 4854 5450 2f32 0d0a 534d 0d0a 0d0a 0000 0004 0000 0000 0401 0000 0000 0000
  18. 18. Remote Procedure Calls vs HTTP APIs • Contract first (proto file) • Content first (URLs, HTTP method, JSON) • Contract is designed for humans • Hides remoting complexity • Content is designed for humans • Emphasises HTTP HTTP APIsRemote Procedure Calls Performance Developer productivity Widest audience Ease of getting started
  19. 19. Demo! • Create gRPC service using template • Create gRPC client • Call service
  20. 20. Grpc.Core Going deeper: gRPC on .NET Core 3.0 Grpc.Core Grpc.Core.Api Grpc.AspNetCore Grpc.Net.Client • HTTP/2 via Kestrel • Integrates with ASP.NET • HTTP/2 via HttpClient • DelegatingHandler
  21. 21. Key features - Performance • Low network usage • HTTP/2 binary framing and header compression • Protobuf message serialization 0 100 200 300 400 500 600 700 800 1 2 10 20 Size(bytes) Serialized items JSON vs Protobuf Size Comparison JSON Protobuf syntax = "proto3"; package sample; message Test { string query = 1; int32 page_number = 2; int32 result_per_page = 3; repeated Ticker tickers = 4; } message Ticker { string name = 1; float value = 2; } { "query": "myQuery", "page_number": 42, "result_per_page": 100, "tickers": [ { "name": "rPs", "value": 9.768923 }, { "name": "WEo", "value": 6.067048 } ] } https://nilsmagnus.github.io/post/proto-json-sizes/ 5052 4920 2a20 4854 5450 2f32 0d0a 534d 0d0a 0d0a 0000 0004 0000 0000 0401 0000 0000 0000
  22. 22. Key features - Performance • HTTP/2 multiplexing • Multiple calls via a TCP connection • Avoid head-of-line blocking*
  23. 23. <Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>netcoreapp3.0</TargetFramework> <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel> </PropertyGroup> <ItemGroup> <Protobuf Include="Topics.proto" GrpcServices="Server" /> <PackageReference Include="Google.Protobuf" Version="1.23.0" /> <PackageReference Include="Grpc.AspNetCore.Server" Version="2.23.2" /> <PackageReference Include="Grpc.Tools" Version="1.23.0" PrivateAssets="All" /> </ItemGroup> </Project> Key features - Code generation • All gRPC libraries have first-class code generation support syntax = "proto3"; message SubscribeRequest { string topic = 1; } message Event { string details = 1; } service Topics { rpc Subscribe(SubscribeRequest) returns (stream Event); } public abstract partial class TopicsBase { public virtual Task Subscribe( SubscribeRequest request, IServerStreamWriter<Event> responseStream, ServerCallContext context) { throw new RpcException(new Status(StatusCode.Unimplemented, "")); } } public partial class TopicsClient : ClientBase<TopicsClient> { public TopicsClient(ChannelBase channel) : base(channel) { } public virtual AsyncServerStreamingCall<Event> Subscribe( SubscribeRequest request, CallOptions options) { return CallInvoker.AsyncServerStreamingCall(__Subscribe, options, request); } }
  24. 24. Key features - Multiple languages
  25. 25. Key features - Streaming • gRPC uses HTTP/2 to enable streaming
  26. 26. Going deeper: gRPC and HTTP/2 requests POST /SayHello host: localhost content-type: application/json {"name":"world"} HEADERS frame DATA frame HTTP/1.1 HEADERS frame DATA frame HTTP/2 POST /greet.Greeter/SayHello host: localhost content-type: application/grpc 1: world
  27. 27. Going deeper: gRPC and HTTP/2 responses 200 OK date: Mon, 18 Jul 2020 16:06:00 GMT server: Kestrel content-type: application/json {"message":"Hello world"} HEADERS frame DATA frame HEADERS frame HTTP/1.1 HEADERS frame DATA frame HTTP/2 200 OK date: Mon, 18 Jul 2020 16:06:00 GMT server: Kestrel content-type: application/grpc 1: Hello world grpc-status: Success
  28. 28. Demo! • Update proto with server streaming call • Implement on server • Call from client
  29. 29. Disadvantages – Limited browser support • Browsers have great HTTP/2 support  • Browser JavaScript APIs haven’t caught up  • gRPC-web provides limited support for calling gRPC services
  30. 30. Disadvantages - Not human readable • HTTP/2 and Protobuf are binary protocols • Additional tools required to debug calls BloomRPC
  31. 31. SignalR
  32. 32. Automatic Reconnections Client-to-server & server-to- client streaming Used in Blazor Server-side Components Azure SignalR Service
  33. 33. What is SignalR?
  34. 34. Long polling Request Response Request Event Client Server
  35. 35. Server-sent events new EventSource(…) Message Event Client Server Message Event Message Event
  36. 36. WebSockets upgrade: websocket Client Server messages HTTP/1.1 101 Switching Protocols 👍 🙂🙂
  37. 37. Azure SignalR Service
  38. 38. Business Logic (Hub) Client Pages Web traffic SignalR traffic
  39. 39. Business Logic (Hub) Pages Client Endpoint Server Endpoint SignalR trafficWeb traffic
  40. 40. API / SPA Auth
  41. 41. Migration Blazor gRPC SignalR API / SPA Auth
  42. 42. https://live.dot.net

×