191180rk
191180rk

Reputation: 905

Azure service fabric concepts

What is the 'Naming service' and 'Reverse proxy' in azure service fabric & when to use which one? are they interconnected with one another (or) totally for different purpose altogether?. Providing examples/analogy of naming service and reverse proxy would be useful.

My requirement: At startup.cs my calling service (serviceA) should obtain the root URL for the callee service (serviceB) via the service fabric 'Naming service' to make the internal service request, how to do it? please suggest with sample code.

Upvotes: 0

Views: 357

Answers (2)

Miroslav Siska
Miroslav Siska

Reputation: 401

naming service or Reverse Proxy can help you to resolve current ServiceEndPoint ("Address of your service in cluster") - You need resolve service before each call because they can move (for example to another cluster node etc..)

Then you can use HTTP Client or Service Remoting etc. for inter-service communication. This samples can be helpful for you: https://learn.microsoft.com/en-us/samples/browse/?terms=service%20fabric&languages=csharp

Personal opinion: For me was better first Service Fabric experience with using of ASP.NET Core templates (stateless + stateful) - Here can you use "Kestrel" and call to this services via HTTP Client.

You need to configure Service Settings in each service according your needs (Internally or externally exposed). See it here: https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-reliable-services-communication-aspnetcore

IMPORTANT: Implement some retry pattern + circuit breaker for HTTP Client via POLLY (for example)

Great sample of HTTP Client for communication between services can you see here: https://github.com/dotnet-architecture/eShopOnContainers

Upvotes: 0

4c74356b41
4c74356b41

Reputation: 72171

So here is what the docs say:

Services connecting to each other inside a cluster generally can directly access the endpoints of other services because the nodes in a cluster are on the same local network. To make is easier to connect between services, Service Fabric provides additional services that use the Naming Service. A DNS service and a reverse proxy service.

Reverse proxy service:

The reverse proxy addresses services in the cluster that exposes HTTP endpoints including HTTPS. The reverse proxy greatly simplifies calling other services and their methods by having a specific URI format and handles the resolve, connect, retry steps required for one service to communicate with another using the Naming Service. In other words, it hides the Naming Service from you when calling other services by making this as simple as calling a URL.

So, if you want to call other services inside the cluster - you should use reverse proxy service and that will be backed by DNS service, which in turn is backed by Naming service

You can also use naming service or dns service directly, without using reverse proxy service, but reverse proxy is convenient, because it allows you to just an HTTP endpoint like you normally would: https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-reverseproxy#microservices-communication-model

Upvotes: 2

Related Questions