简体   繁体   中英

Service Fabric - Sync configuration between multiple instances of the same web service

I have a unique web service configuration question.

I have several instances of the same Web Service (hosted via Service Fabric)

I need to connect each unique instance of the web service to a client id.

For example, if I have 5 instances of the service, and the following 5 client ids:

A, B, C, D, E

I want to configure each service to work with it's unique client id like so:

1 -> A

2 -> B

3 -> C

4 -> D

5 -> E

The order of the clients or which services they are configured to does not matter. All that matters is that each service only gets a single unique client id to work with.

One possible solution I've thought of is using an SQL Table which stores the client ids, and also a column with "IsTaken". Each service locks the other services from accessing the table and then takes one client id that is not taken, and changes the IsTaken value to true.

Are there any other ways to go about this? Maybe a specific tool that is designed to sync configuration between multiple web services? Thanks in advance.

You could also create an Application instance per Client. Combined with a Service instance that registers the client-id as part of it's URL.

So you'd get something like:

You can configure it to create as many instances as you need. Use the built-in reverse proxy to access them from the outside world.

If I understand your requirement correctly, you can implement the services using the actor model and use the clientId as the instance id. In the actor model, only one instance is created/running for each instanceId in the cluster. Actors are isolated, independent units of logic and state within a single-threaded execution model.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM