简体   繁体   English

Service Fabric-在同一Web服务的多个实例之间同步配置

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

I have a unique web service configuration question. 我有一个独特的Web服务配置问题。

I have several instances of the same Web Service (hosted via Service Fabric) 我有几个相同Web服务的实例(通过Service Fabric托管)

I need to connect each unique instance of the web service to a client id. 我需要将Web服务的每个唯一实例连接到一个客户端ID。

For example, if I have 5 instances of the service, and the following 5 client ids: 例如,如果我有该服务的5个实例以及以下5个客户端ID:

A, B, C, D, E A,B,C,D,E

I want to configure each service to work with it's unique client id like so: 我想配置每个服务以使其具有唯一的客户端ID,如下所示:

1 -> A 1-> A

2 -> B 2-> B

3 -> C 3-> C

4 -> D 4-> D

5 -> E 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. 重要的是每个服务只能获得一个唯一的客户端ID才能使用。

One possible solution I've thought of is using an SQL Table which stores the client ids, and also a column with "IsTaken". 我想到的一种可能的解决方案是使用存储客户ID的SQL表以及带有“ 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. 每个服务都锁定其他服务以防止访问该表,然后获取一个未使用的客户端ID,并将IsTaken值更改为true。

Are there any other ways to go about this? 还有其他方法吗? Maybe a specific tool that is designed to sync configuration between multiple web services? 也许是专用于在多个Web服务之间同步配置的特定工具? 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. 与将客户端ID注册为其URL一部分的Service实例结合使用。

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. 如果我正确理解了您的要求,则可以使用actor模型来实现服务,并使用clientId作为实例ID。 In the actor model, only one instance is created/running for each instanceId in the cluster. 在参与者模型中,集群中的每个instanceId仅创建/运行一个实例。 Actors are isolated, independent units of logic and state within a single-threaded execution model. 参与者是单线程执行模型中的独立,独立的逻辑和状态单元。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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