Vaclav Turecek Program Manager Azure Service Fabric P4020 ASPNET Core Service Fabric MVC web application Web API backend service Web API frontend service Web API backend service Web API backend service ID: 596448
Download Presentation The PPT/PDF document "ASP.NET Core + Azure Service Fabric" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1Slide2
ASP.NET Core + Azure Service Fabric
Vaclav TurecekProgram ManagerAzure Service Fabric
P4020Slide3
ASP.NET Core + Service Fabric
MVC web application
Web API back-end service
Web API front-end service
Web API back-end service
Web API back-end service
Service Fabric Slide4
Hosting ASP.NET Core in Service Fabric
In a ContainerAs a Guest EXEHosted in a Reliable ServiceSlide5
ASP.NET Core WebHost
WebHost in a single process, like a guest EXE
Program Main()
ASP.NET Core
WebHost
Server
Kestrel or
WebListener
Application
MVC,
etc
Create
Host processSlide6
ASP.NET Core WebHost in Service Fabric
WebHost in a Reliable Service
Program Main()
ASP.NET Core
WebHost
Server
Kestrel or
WebListener
Application
MVC,
etc
Service
Fabric runtime
ICommunication
-Listener
Create
Create
Register
service type
Service host process
Service instance/replica (multiple)
ASP.NET CoreSlide7
Stateless replica
ASP.NET Core Reliable Services
Stateless service lifecycle
Service
Fabric runtime
Create
Open
Close
Service host process
ASP.NET Core
WebHostSlide8
Stateful replica
ASP.NET Core Reliable Services
Stateful service lifecycle
Service
Fabric runtime
Create
Open
Change role
Service host process
Close
Primary
Secondary
None
ASP.NET Core
WebHostSlide9
Service communication
Service A
Service B
Naming Service
Network protocol: HTTP, AMQP, etc.
Client authentication/authorization
Service identification
Transport encryption
Get Service B address
Register addressSlide10
Mistaken identity
Service A listens on
10.0.0.1:30000
over HTTP.
Client resolves Service A and gets address 10.0.0.1:30000
Service A moves to a different node.Service B is placed on 10.0.0.1 and coincidentally uses the same port: 30000.Client attempts to connect to service A with cached address
10.0.0.1:30000.Client is now successfully connected to service B not realizing it is connected to the wrong service.How does the client know to re-resolve the address for service A?Slide11
Service Fabric middleware
Service A
ASP.NET Core service
Naming Service
Get service address
http://10.0.0.1:30001/pID/rID
Register address
http://10.0.0.1:30001/pID/rID
UseUniqueServiceUrl
Process request
http://10.0.0.1:30001
GET http://10.0.0.1:30001/pID/rID
Valid
Path?
HTTP 410 Gone
no
yes
pID
/
rID
HTTP ResponseSlide12
Kestrel in Service Fabric
Kestrel
Kestrel
ServiceHost.exe
http://10.0.0.1:80
http://10.0.0.1:81
Kestrel
Kestrel
ServiceHost.exe
http://10.0.0.1:82
http://10.0.0.1:83
Node (Windows/Linux)
Client
Connection failure
Libuv
: Linux or Windows
Just a socket in a process
No URL registration
No port sharing
No URL path mapping
No hostname mapping
No
DoS
protection (yet)Slide13
WebListener in Service Fabric
WebListener
WebListener
ServiceHost.exe
http://10.0.0.1:80/A
http://10.0.0.1:81/B
WebListener
WebListener
ServiceHost.exe
http://10.0.0.1:80/C
http://10.0.0.1:81/D
Node (Windows only)
Client
HTTP 503 or 404
http.sys:
Windows kernel
Machine-wide URL map
URLs must be registered
Port sharing
URL path mapping
Hostname mapping
DoS
protection
ht
tp.
sysSlide14
Static application ports
Replica
Replica
ServiceHost.exe
Replica
Replica
ServiceHost.exe
<
Resources
>
<
Endpoints
>
<
Endpoint Protocol
="http" Name=
"
MyWebEndpoint
"
Port
=
"
80
"
/>
</
Endpoints
></
Resources>
Port 80
Port 80Slide15
Dynamic application ports
Replica
Replica
ServiceHost.exe
Replica
Replica
ServiceHost.exe
<
Resources
>
<
Endpoints
>
<
Endpoint
Protocol="http" Name=
"
MyWebEndpoint
"
/>
</
Endpoints
>
</
Resources
>
Port 30000
Port 30001Slide16
Recommendations
WebListener: Use for Internet-facing fixed-port stateless services.
URL path and hostname routing features can be useful for hosting multiple web applications in the same cluster.
Provides
DoS protection. Windows authentication and other IIS features.Kestrel: Use for internal service communication.
Much simpler service resolution.No URL registration required.Very fast.Slide17
ASP.NET Core Service Fabric application
MVC
WebListener
Web API
Kestrel
MVC
WebListener
Web API
Kestrel
Web API
Kestrel
Service Fabric
http://ip:30001/p1/r4
http://ip:30002/p2/r5
http://ip:30003/p3/r6
http://mysite.com
http://mysite.com/apiSlide18
Learn more!
https://github.com/Azure/service-fabric-aspnetcoreSlide19