Reliable Services Jeffrey Richter Microsoft Azure Service Fabric
Reliable Services (Stateless & Stateful) .NET Programming model benefits Networking naming service support Self-reporting of instance’s load metrics Integrate with code, config, & data upgrades Efficiency (better density): Multiple services (types & instances) in a single process Other programming models can be built on Service Fabric Example: Reliable Actors
Reliable Services Your class object is notified of service start/stop Similar to Azure Cloud Services’ RoleEntryPoint Your class object does whatever you need it to do Ex: Process network requests or queue messages Stateless services keep their state in an external store Ex: Azure Storage, SQL Database, Document DB, etc. Partition your data so it scales well
Creating a Stateless Reliable Service Visual Studio Solution
Steps to have your Service Listen For input endpoint(s), configure load balancer to allow traffic over desired port(s) Add endpoint(s) to ServiceManifest.xml (for ACL’ing) When service starts, listen for network traffic Override CreateServiceInstanceListeners Return method(s) that create listener objects/endpoint names When service instance starts, SF invokes method(s) to create listener object(s) Each listener object starts listening (tcp, http) & returns endpoint to SF SF runtime sends all names/endpoints to SF naming service Endpoints are visible in Service Fabric Explorer
Steps to have Client Talk to Service Client queries naming service Pass service/partition key; returns endpoint Client communicates with endpoint If service moves; communication fails. Re-query naming service. Ways to query naming service ResolvePartition (REST) Resolve-ServiceFabricService (PowerShell) ServicePartitionResolver (.NET) See also ServicePartitionClient which adds retry support
Recommended HTTP Endpoint String Format $"http(s)://{nodeNameorIP}:{port}/" + $"{partitionId}/{instanceId}/{Guid.NewGuid()}/" Example: http://192.168.1.71:80/ 99ab0795-c10f-4524-83e1-54025d8f9732/130951445550694185/ dc09a30c-9b7f-4374-91b7-e0784134995b/ For diagnostics Makes every endpoint unique
Upgrading a Named Application with Visual Studio
Q & A