A method, system, device, and medium for routing and distributing user directory provisioning.

CN123123346APending Publication Date: 2026-11-17SANGFOR TECH INC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611441673.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-16
Publication Date
2026-11-17

Smart Images

  • Figure CN123123346A_ABST
    Figure CN123123346A_ABST
Patent Text Reader

Abstract

This application discloses a routing and distribution method, system, device, and medium for user directory provisioning, relating to the field of distributed system technology. The method involves: obtaining operation messages for user directory provisioning; obtaining the load count values ​​of each service node and selecting the service node with the smallest load count value as the target service node; obtaining the reference counts of each message channel under the target service node and selecting the message channel with the smallest reference count as the target message channel; incrementing the load count value of the target service node and the reference count of the target message channel within the same atomic transaction; and sending the operation message to the target message channel of the target service node. This achieves smooth scaling without migration and dynamic adaptive load balancing, reducing message processing costs. Furthermore, binding the operations of incrementing the node load count value and incrementing the channel reference count within the same transaction ensures the synchronous update of the two counts, providing an accurate data foundation for subsequent routing decisions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of distributed systems technology, and more specifically, to a routing and distribution method, system, device, and medium for user directory provisioning. Background Technology

[0002] As enterprises deepen their digital transformation, more and more companies are adopting IDaaS (Identity as a Service) platforms for unified identity authentication, user management, and access control. IDaaS platforms need to automatically synchronize user identity data to downstream application systems or local LDAP (Lightweight Directory Access Protocol) directory services; this process is called User Directory Provisioning.

[0003] Currently, user directory provisioning typically employs static sharding routing using hashing, that is, consistent hashing sharding based on tenant ID or provisioning policy ID, mapping operations to specific consumer nodes for processing. This approach ensures the consistency of operation order for the same policy, but adding or removing nodes requires rehashing, potentially triggering a large number of message migrations, resulting in high scaling costs, and failing to perceive the actual load on each node. Hot tenants may cause some nodes to become overloaded.

[0004] In summary, how to achieve elastic scaling and dynamic load balancing of user directory provision at low cost is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0005] The purpose of this application is to provide a routing and distribution method for user directory provisioning, which can, to some extent, solve the technical problem of how to achieve elastic scaling and dynamic load balancing of user directory provisioning at low cost. This application also provides a routing and distribution system for user directory provisioning, an electronic device, and a computer-readable storage medium.

[0006] To achieve the above objectives, firstly, a method for routing and distributing user directory provisioning is provided, comprising: Retrieve operation messages for the user directory supply; Obtain the load count value of each service node, and select the service node with the smallest load count value as the target service node; Obtain the reference count of each message channel under the target service node, and select the message channel with the smallest reference count as the target message channel; Within the same atomic transaction, increment the load count of the target service node and the reference count of the target message channel; The operation message is sent to the target message channel of the target service node.

[0007] Preferably, before obtaining the load count value of each service node, the method further includes: Determine the strategy identifier of the operation message, wherein the strategy identifier is used to uniquely identify a supply strategy; Using the policy identifier as the key, query whether there is a binding relationship corresponding to the policy identifier in the cache. The binding relationship is used to record the service nodes and message channels that the supply policy corresponding to the policy identifier has been bound to. If the binding relationship exists in the cache, then it is verified whether the service node in the binding relationship is online and whether the message channel is valid. If the verification passes, the operation message is sent to the corresponding service node and message channel according to the binding relationship, thus ending the routing distribution process; If the binding relationship does not exist in the cache or the verification fails, a distributed lock is acquired at the granularity of the policy identifier. After successfully acquiring the distributed lock, the cache is queried using the policy identifier as the key. If the corresponding binding relationship already exists in the cache, the distributed lock is released, and the operation message is sent to the corresponding service node and message channel according to the binding relationship, thus ending the routing distribution process. If the corresponding binding relationship still does not exist in the cache, then proceed with the step of obtaining the load count value of each service node.

[0008] Preferably, querying the cache for a binding relationship corresponding to the policy identifier, using the policy identifier as the key, includes: Using the policy identifier as the key, query whether a binding relationship corresponding to the policy identifier exists in the local memory cache; If the binding relationship does not exist in the local memory cache, then the policy identifier is used as the key to query whether the corresponding binding relationship exists in the distributed cache; If the binding relationship exists in the distributed cache, then it is determined that the binding relationship exists in the cache. If the binding relationship does not exist in the distributed cache, it is determined that the binding relationship does not exist in the cache.

[0009] Preferably, after incrementing the load count value of the target service node and the reference count of the target message channel, the method further includes: Establish a binding relationship between the policy identifier and the target service node and the target message channel; Write the binding relationship into the cache and set a first expiration time; Generate an auxiliary expiration key corresponding to the binding relationship. The key name of the auxiliary expiration key is encoded with the node identifier of the target service node and the channel number of the target message channel. Write the auxiliary expired key into the cache, and set a second expiration time according to the first expiration time, so as to generate a key expiration notification event for the auxiliary expired key based on the second expiration time; Listen for cached key expiration notification events; In response to receiving a key expiration notification event for the auxiliary expired key, the service node and message channel to be reclaimed are determined based on the key name of the auxiliary expired key. Acquire a mutex marker, and after successfully acquiring the mutex marker, acquire the distributed lock; Under the protection of the distributed lock, the load count of the service nodes to be reclaimed is reduced, and the reference count of the message channels to be reclaimed is reduced.

[0010] Preferably, the verification of whether the service node in the binding relationship is online and whether the message channel is valid includes: Query the list of currently online service nodes; Determine whether the service node in the binding relationship exists in the service node list; If the service node in the binding relationship does not exist in the service node list, the verification fails. If a service node in the binding relationship exists in the service node list, it is determined whether the message channel number in the binding relationship is within the range of channel numbers allowed by the service node. If the message channel number in the binding relationship is within the range of channel numbers allowed by the service node, the verification passes. If the message channel number in the binding relationship is not within the range of channel numbers allowed by the service node, the verification fails.

[0011] Preferably, before selecting the service node with the smallest load count value as the target service node, the method further includes: Acquire a global state lock, which is used to protect the read-write consistency of the load count and reference count; After incrementing the load count of the target service node and the reference count of the target message channel, the method further includes: Release the global state lock.

[0012] Preferably, selecting the service node with the smallest load count value as the target service node includes: Batch query the load count values ​​of all service nodes; For service nodes that do not have load count records, set the load count to 0; Iterate through all service nodes and select the service node with the smallest load count as the target service node.

[0013] Secondly, a routing and distribution system for user directory provisioning is provided, including: The operation message acquisition module is used to acquire operation messages provided by the user directory; The node selection module is used to obtain the load count value of each service node and select the service node with the smallest load count value as the target service node. The channel selection module is used to obtain the reference count of each message channel under the target service node and select the message channel with the smallest reference count as the target message channel. The update module is used to increment the load count of the target service node and the reference count of the target message channel within the same atomic transaction. The sending module is used to send the operation message to the target message channel of the target service node.

[0014] Thirdly, an electronic device is provided, comprising: Memory, used to store computer programs; A processor, used to implement the routing and distribution method for user directory provisioning as described above when executing the computer program.

[0015] Fourthly, a computer-readable storage medium is provided, wherein a computer program is stored therein, and when executed by a processor, the computer program implements the routing and distribution method for user directory provisioning as described above.

[0016] This application provides a routing and distribution method for user directory provisioning, which involves: obtaining operation messages for user directory provisioning; obtaining the load count values ​​of each service node and selecting the service node with the smallest load count value as the target service node; obtaining the reference counts of each message channel under the target service node and selecting the message channel with the smallest reference count as the target message channel; incrementing the load count value of the target service node and the reference count of the target message channel in the same atomic transaction; and sending the operation message to the target message channel of the target service node. In this application, the load count reflects the total number of policies currently bound to a service node, and the reference count reflects the number of policies currently bound to a message channel. Selecting the service node with the smallest load count as the target service node, and the message channel with the smallest reference count as the target message channel, ensures that newly added service nodes with the smallest load count will be prioritized for operation messages, achieving smooth scaling without migration. Service nodes with lighter loads will handle more new operation messages, while those with heavier loads will handle fewer, enabling dynamic adaptive load balancing. Furthermore, multiple operation messages can share the same service node but occupy different message channels. In other words, a single service node can carry multiple operation messages through a message channel, reducing message processing costs. Based on this, binding the incrementing of the node load count and the incrementing of the channel reference count to the same transaction ensures synchronous updates of the two counts. Either both counts increment successfully, or both fail and roll back, preventing intermediate states and avoiding distributed state inconsistencies. This provides an accurate data foundation for subsequent routing decisions, enabling accurate elastic scaling and dynamic load balancing. The routing and distribution system for user directory provision, electronic device, and computer-readable storage medium provided in this application also solve the corresponding technical problems. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0018] Figure 1 A flowchart illustrating a routing and distribution method for user directory provisioning provided in this application embodiment; Figure 2 Flowchart of the routing distribution method for user directories based on cache hits; Figure 3 Flowchart of a routing distribution method for a user directory based on key event notifications; Figure 4 This is a schematic diagram of the architecture of the IDaaS platform in this application; Figure 5 A schematic diagram of the consumption mechanism for service nodes; Figure 6 A schematic diagram of the structure of a routing and distribution system for user directory provisioning provided in an embodiment of this application; Figure 7 This is a schematic diagram of the hardware structure of the electronic device according to an embodiment of this application. Detailed Implementation

[0019] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0020] As enterprises deepen their digital transformation, more and more companies are adopting IDaaS (Identity as a Service) platforms for unified identity authentication, user management, and access control. IDaaS platforms need to automatically synchronize user identity data to downstream application systems or local LDAP (Lightweight Directory Access Protocol) directory services. This process is called User Directory Provisioning, and user identity data can include operations such as creation, updating, and deletion. In multi-tenant SaaS scenarios, an IDaaS platform typically serves hundreds to thousands of tenants simultaneously, with each tenant configured with multiple provisioning policies to synchronize user data to different downstream applications.

[0021] Currently, user directory provisioning typically employs static sharding routing using hashing, i.e., consistent hashing sharding based on tenant ID or provisioning policy ID, mapping operations to specific consumer nodes for processing. This approach ensures consistent operation order for the same policy, but adding or removing nodes requires rehashing, potentially triggering large-scale message migrations, resulting in high scaling costs and an inability to perceive the actual load on each node; hot tenants may cause some nodes to become overloaded. The user directory provisioning routing and distribution scheme provided in this application can achieve elastic scaling and dynamic load balancing of user directory provisioning at low cost.

[0022] Please see Figure 1 , Figure 1 This is a flowchart illustrating a routing and distribution method for user directory provisioning, as provided in an embodiment of this application.

[0023] This application provides a user directory provisioning routing and distribution method, which may include the following steps: Step S101: Obtain the operation message provided by the user directory.

[0024] In practical applications, you can first obtain the operation messages provided by the user directory, such as receiving CUD (create, update, delete) operation messages. The operation messages carry the change information of user identity data and need to be synchronized to the corresponding downstream target applications.

[0025] In practical implementation, this operation message can be generated when user data changes. The operation message can be in a structured data format and can include the following fields: tenant identifier, target application identifier, operation type, user data, supply agreement type, etc.

[0026] Step S102: Obtain the load count value of each service node, and select the service node with the smallest load count value as the target service node.

[0027] In practical applications, when a complete routing calculation is required—that is, when allocating a new service node and message channel for the current operation message—the load count values ​​of each service node can be obtained first. For example, the load count values ​​of all registered service nodes can be queried in batches from a distributed key-value store. The load count value of a service node represents the total number of provisioning policies currently bound to that node. Distributed key-value stores refer to high-availability storage services used to store shared data such as load status and binding cache, supporting features such as atomic operations and key expiration notifications. All service nodes are then traversed, and the service node with the smallest load count value is selected as the target service node. Since the service node with the smallest load count value has the smallest load, a minimum load priority service node selection strategy is implemented, ensuring that new provisioning policies are always assigned to the service node with the lightest current load, thereby achieving a balanced global load distribution.

[0028] In practical implementation, for service nodes without load count records in the distributed key-value store, such as newly registered service nodes that have not yet been assigned any policies, their load count can be set to 0. This prioritizes completely idle service nodes, facilitating rapid load ramp-up for new service nodes. In other words, when selecting the service node with the smallest load count as the target service node, the load counts of all service nodes can be queried in batches; for service nodes without load count records, their load counts are set to 0; all service nodes are traversed, and the service node with the smallest load count is selected as the target service node. Furthermore, when there are multiple service nodes with the smallest load count, different weights can be assigned to different service nodes based on their configurations, and the target service node can be selected based on these weights; alternatively, the service node with the smallest load count can be randomly selected; or a comprehensive load score can be calculated by considering multiple dimensions such as CPU utilization, message backlog, and network latency, and the target service node can be selected based on this comprehensive load score.

[0029] It's important to note that a service node (Worker) refers to a single consumer service instance. Each service node maintains a fixed number of message channels, serving as an independent execution unit for provisioning operations. Service nodes are stateful, with states including, but not limited to, reference counts for each message channel and the binding relationship between channels and policies. A message channel refers to a logical channel within a message queue, also serving as an independent execution unit for provisioning operations. Each message channel can be understood as an independent message queue or queue partition. A provisioning policy refers to the configuration unit for provisioning rules, defining the method, scope, and protocol type for synchronizing user data from IDaaS to a specific target application in an operation message. For example, tenant A might configure one provisioning policy to synchronize user data to a specific app and another to synchronize user data from the same tenant to Salesforce. These two policies have different policy identifiers. Furthermore, the policy identifier refers to the policy-application composite identifier defined in this application, which can be composed of a tenant identifier and a target application identifier. As the smallest unit of granularity for route binding, different combinations of tenant identifier and target application identifier correspond to different provisioning policies. For example, if the tenant identifier is "tenant001" and the target application identifier is "APP1", then the policy identifier can be "tenant001:APP1".

[0030] Step S103: Obtain the reference count of each message channel under the target service node, and select the message channel with the smallest reference count as the target message channel.

[0031] In practical applications, after selecting the first-level service node, a second-level selection is performed, namely, channel-level minimum load selection. This involves querying the reference count of all message channels under the target service node from the distributed key-value store. The reference count of a message channel represents the number of supply strategies currently bound to that channel. All message channels under the target service node are traversed, and the channel with the lowest reference count is selected as the target message channel. A reference count of 0 indicates that the message channel is currently idle, and new supply strategies will be preferentially bound to idle channels. This achieves a one-strategy-one-channel isolation model. Ideally, each supply strategy occupies a dedicated message channel, and operations of different supply strategies are processed in parallel on different message channels without interference.

[0032] Step S104: In the same atomic transaction, increment the load count of the target service node and the reference count of the target message channel.

[0033] In practical applications, after selecting the target service node and target message channel, the state data in the distributed key-value store needs to be updated to reflect the load changes brought about by the new binding relationship. In a distributed concurrent environment, when multiple routing instances perform route calculations simultaneously, inconsistencies may arise between the load count and reference count and the actual binding relationship. Without concurrency control, two instances might simultaneously read the same load count and reference count, each believing its selected node / channel is optimal, and then increment the counters independently, causing the actual load to deviate from expectations. To avoid this situation, the load count of the target service node and the reference count of the target message channel can be incremented within the same atomic transaction. An atomic transaction refers to the requirement that two increment operations must be completed within the same atomic transaction. That is, incrementing the load count of the target service node and incrementing the reference count of the target message channel must be completed within the same atomic transaction. In this way, either both counters are updated successfully or both fail and roll back. This avoids intermediate states where the load count of the service node has been updated but the reference count of the message channel has not been updated (resulting in an artificially high node load) or the reference count of the message channel has been updated but the load count of the service node has not been updated (resulting in an artificially low node load). This provides accurate input data for subsequent routing decisions.

[0034] In practical implementation, atomic transactions can be protected by a global state lock. That is, before selecting the service node with the smallest load count as the target service node, a global state lock can be acquired. The global state lock is used to protect the read-write consistency of the load count and reference count. After acquiring the global state lock, a complete operation sequence of reading-incrementing-writing the load count and reference count is executed under the protection of the lock. Correspondingly, after incrementing the load count of the target service node and the reference count of the target message channel, the global state lock is released.

[0035] Step S105: Send the operation message to the target message channel of the target service node.

[0036] In practical applications, after the state update is completed, the operation message can be sent to the corresponding message channel based on the target service node identifier and the target message channel number. When sending the operation message, the supply protocol type attribute can be included so that the service node can select the correct protocol plugin for processing during consumption. This completes one routing and distribution process. Subsequent supply operation messages belonging to the same supply strategy can be directly routed to the same message channel through cache hits, thus ensuring sequential consistency.

[0037] This application provides a routing and distribution method for user directory provisioning, which involves: obtaining operation messages for user directory provisioning; obtaining the load count values ​​of each service node and selecting the service node with the smallest load count value as the target service node; obtaining the reference counts of each message channel under the target service node and selecting the message channel with the smallest reference count as the target message channel; incrementing the load count value of the target service node and the reference count of the target message channel in the same atomic transaction; and sending the operation message to the target message channel of the target service node. In this application, the load count reflects the total number of policies currently bound to a service node, and the reference count reflects the number of policies currently bound to a message channel. Selecting the service node with the smallest load count as the target service node, and the message channel with the smallest reference count as the target message channel, ensures that newly added service nodes with the smallest load count will be prioritized for operation messages, achieving smooth scaling without migration. Service nodes with lighter loads will handle more new operation messages, while those with heavier loads will handle fewer, enabling dynamic adaptive load balancing. Furthermore, multiple operation messages can share the same service node but occupy different message channels. In other words, a single service node can carry multiple operation messages through a message channel, reducing message processing costs. Based on this, binding the incrementing of the node load count and the incrementing of the channel reference count to the same transaction ensures synchronous updates of the two counts. Either both counts increment successfully, or both fail and roll back, preventing intermediate states and avoiding distributed state inconsistencies. This provides an accurate data foundation for subsequent routing decisions, enabling accurate elastic scaling and dynamic load balancing.

[0038] Based on the above embodiments, if the same supply strategy is processed by different message channels, it will cause the same strategy to be repeatedly calculated by multiple routing instances, compromising the accuracy of the overall load balancing. To avoid this problem, please refer to [link to relevant documentation]. Figure 2 The routing and distribution method for user directory provisioning provided in this application embodiment may include the following steps: Step S201: Obtain the operation message provided by the user directory.

[0039] Step S202: Determine the strategy identifier of the operation message. The strategy identifier is used to uniquely identify a supply strategy.

[0040] In practical applications, the policy identifier of the operation message can be determined first. The policy identifier is used to uniquely identify a provisioning policy. For example, the tenant identifier and the target application identifier can be parsed from the operation message. Then, the tenant identifier and the target application identifier can be combined to generate the policy identifier, so that the policy identifier can be used as the smallest unit of granularity for all subsequent routing decisions.

[0041] Step S203: Using the policy identifier as the key, query whether there is a binding relationship corresponding to the policy identifier in the cache. The binding relationship is used to record the service nodes and message channels that the policy identifier has been bound to. If there is a binding relationship in the cache, proceed to step S204. If there is no binding relationship in the cache, proceed to step S206.

[0042] In practical applications, the policy identifier should be used as the query key to check whether the binding relationship corresponding to the policy identifier exists in the caching system. The binding relationship is used to record the service nodes and message channels that the supply policy corresponding to the policy identifier is currently bound to. Specifically, the local memory cache (L1 cache) is queried first. If it is not found, the distributed cache (L2 cache) is queried. Since the local memory cache has the advantage of fast access speed, it is suitable for alleviating the query pressure on the distributed cache in short-term high-concurrency scenarios.

[0043] In the specific implementation, when querying the cache for the existence of a binding relationship corresponding to a policy identifier using the policy identifier as the key, it is also possible to query the local memory cache for the existence of a corresponding binding relationship using the policy identifier as the key. That is, a cache space is maintained in local memory to store the mapping between recently accessed policy identifiers and their binding relationships. The local memory cache has the advantage of fast access speed and is suitable for alleviating the query pressure on the distributed cache in short-term high-concurrency scenarios. Accordingly, the local memory cache is first queried using the policy identifier as the key. If a match is found, it is directly determined that a binding relationship exists in the cache, without needing to query the distributed cache. If no binding relationship exists in the local memory cache, the distributed cache is queried using the policy identifier as the key to see if a corresponding binding relationship exists. The distributed cache is built on top of a distributed key-value store, and all routing distribution layer instances in the IDaaS platform share the same cache data. The distributed cache stores the binding relationships of all active policies and has a long expiration time to maintain the long-term binding relationship between policies and channels. If a binding relationship exists in the distributed cache, it is determined that a binding relationship exists in the cache; if no binding relationship exists in the distributed cache, it is determined that no binding relationship exists in the cache. In this way, the local memory cache provides extremely fast access speed and alleviates the hot spot pressure of the distributed cache; the distributed cache provides a globally consistent cache view, ensuring that all routing distribution layer instances share the same binding relationship data; and unlike the static hash sharding scheme, the binding relationship in this application is stored in an external distributed key-value store, so there is no need to re-hash the mapping when service nodes are added or removed, thus avoiding large-scale message migration.

[0044] Step S204: Verify whether the service node in the binding relationship is online and whether the message channel is valid; if the verification passes, proceed to step S205; if the verification fails, proceed to step S206.

[0045] Step S205: Based on the binding relationship, send the operation message to the corresponding service node and message channel to end the routing distribution process.

[0046] In practical applications, when a cache hit occurs, the binding relationships in the cache cannot be directly used for routing because the service nodes may have gone offline or undergone configuration changes. Therefore, this application adds a channel validity verification mechanism to the routing distribution process. This mechanism checks whether the service nodes in the binding relationships are currently online and whether the message channel is valid. Verification only passes when both the service nodes are online and the message channel is valid. Then, based on the binding relationships in the cache, the supply operation message is sent to the corresponding service node and message channel, ending the routing distribution process.

[0047] In the specific implementation, during the process of verifying whether the service nodes in the binding relationship are online and whether the message channel is valid, the list of currently online service nodes can be queried. For example, when the routing distribution layer starts up, it registers a listener with the service registry in the IDaaS platform and subscribes to service list change events. The service registry maintains a dynamic list of service nodes, recording information on all registered and healthy service nodes. When the routing distribution layer needs to perform verification, it directly retrieves the latest data from the locally cached service list, without needing to initiate a remote query to the service registry every time, thus ensuring verification efficiency; it also checks whether the service node in the binding relationship exists in the service node list; and responds when the service node in the binding relationship does not exist. If a service node is not found in the service node list, it indicates that the service node is offline or has not yet completed registration, and the verification fails. If a service node in the binding relationship exists in the service node list, the verification checks whether the message channel number in the binding relationship is within the allowed channel number range of the service node. Each service node is configured with the number of message channels it maintains at startup, for example, each service node maintains 16 channels, with channel numbers ranging from 0 to 15. If the message channel number in the binding relationship is within the allowed channel number range of the service node, the verification passes. If the message channel number in the binding relationship is not within the allowed channel number range of the service node, it indicates that the binding relationship has expired, possibly due to changes in the number of channels caused by node configuration changes, and the verification fails. This application considers that when a service node goes offline or the channel configuration changes, the cache may still retain routing information pointing to expired resources. Without verification, operation messages will be sent to non-existent service nodes or message channels, leading to delivery failure. Through real-time verification, this application ensures that routing decisions always point to valid service resources, solving the cache consistency problem in dynamic scaling scenarios of stateful services.

[0048] Step S206: Acquire a distributed lock at the policy identifier level.

[0049] In practical applications, when a cache miss or validation fails, a complete routing calculation process needs to be executed. However, before this, in a distributed environment, multiple routing distribution layer instances may simultaneously receive supply operation messages belonging to the same supply strategy. These instances may all detect cache misses, thus triggering routing calculations simultaneously. If multiple instances simultaneously execute the operations of selecting the minimum load node and incrementing the counter for the same supply strategy, it may lead to the supply strategy being bound multiple times, the same supply strategy being mapped to different message channels, or the counter being incremented repeatedly, resulting in distorted load data. To solve this problem, this application introduces a policy-level distributed lock. Specifically, a distributed lock is requested using the policy identifier as the lock key. A distributed lock refers to a synchronization mechanism used in a distributed system to coordinate mutual exclusive access to shared resources by multiple processes. During this process, a timeout can be set for acquiring the distributed lock, such as 5 seconds, to prevent the instance holding the lock from crashing abnormally and causing a deadlock.

[0050] Step S207: After successfully acquiring the distributed lock, query the cache using the policy identifier as the key. If the corresponding binding relationship already exists in the cache, release the distributed lock and send the operation message to the corresponding service node and message channel according to the binding relationship, thus ending the routing distribution process.

[0051] Step S208: If the corresponding binding relationship still does not exist in the cache, obtain the load count value of each service node and select the service node with the smallest load count value as the target service node.

[0052] In practical applications, after successfully acquiring the policy-level distributed lock, it is necessary to query the cache again using the policy identifier as the key. This is because during the lock waiting period, another routing instance may have already completed route calculation and written the binding relationship to the cache. If route calculation is executed directly at this time, it will lead to duplicate binding. Therefore, if the cache is queried again and the corresponding binding relationship already exists in the cache, the distributed lock is released, and route distribution is performed based on the binding relationship, ending the route distribution process. If the cache is queried again and it is confirmed that the corresponding binding relationship still does not exist in the cache, it means that no other instance has completed the calculation, and the current instance can safely execute the route calculation process.

[0053] Step S209: Obtain the reference count of each message channel under the target service node, and select the message channel with the smallest reference count as the target message channel.

[0054] Step S210: In the same atomic transaction, increment the load count of the target service node and the reference count of the target message channel.

[0055] Step S211: Send the operation message to the target message channel of the target service node.

[0056] Based on the above embodiments, if the message channel has finished processing the operation message, resource release is required. This can be done by periodically polling the service node. However, network fluctuations may prevent accurate resource release. To avoid this, please refer to [link / reference needed]. Figure 3 The routing and distribution method for user directory provisioning provided in this application embodiment may include the following steps: Step S301: Obtain the operation message provided by the user directory.

[0057] Step S302: Obtain the load count value of each service node, and select the service node with the smallest load count value as the target service node.

[0058] Step S303: Obtain the reference count of each message channel under the target service node, and select the message channel with the smallest reference count as the target message channel.

[0059] Step S304: In the same atomic transaction, increment the load count of the target service node and the reference count of the target message channel.

[0060] Step S305: Send the operation message to the target message channel of the target service node.

[0061] Step S306: Establish the binding relationship between the policy identifier and the target service node and the target message channel, write the binding relationship into the cache and set the first expiration time.

[0062] In practical applications, after atomic incrementing, a binding relationship is established between the policy identifier and the target service node and target message channel. This binding relationship is stored as key-value pairs, where the key is the policy identifier and the value is a string combining the node identifier and the channel number. The binding relationship is written to a cache with a first expiration time, such as 24 hours. This first expiration time determines the lifecycle of the binding relationship. If the supply policy remains active, the binding relationship will be refreshed by the rerouting process before expiration. If the supply policy is closed, the binding relationship will be automatically cleaned up after expiration.

[0063] Step S307: Generate an auxiliary expiration key corresponding to the binding relationship. The key name of the auxiliary expiration key is encoded with the node identifier of the target service node and the channel number of the target message channel.

[0064] In practical applications, in addition to the binding relationship itself, an auxiliary expiration key also needs to be generated. The key name of the auxiliary expiration key encodes the node identifier of the target service node and the channel number of the target message channel. The purpose of the auxiliary expiration key is that when the binding relationship is cleaned up due to expiration, the expiration event of the auxiliary expiration key will trigger the resource reclamation process. Since the key name of the auxiliary expiration key has already encoded the service node and channel information that need to be reclaimed, the reclamation process can accurately release the corresponding resources without additional queries.

[0065] Step S308: Write the secondary expired key to the cache and set the second expiration time according to the first expiration time, so as to generate a key expiration notification event for the secondary expired key based on the second expiration time.

[0066] In practical applications, the auxiliary expiration key is written to the cache, specifically a distributed cache, and a second expiration time is set based on the first expiration time. The second expiration time can be the same as the first expiration time or have a preset mapping relationship, such as the second expiration time being slightly longer than the first expiration time. In this way, the second expiration time can be used to determine whether the service expiration key has expired. If it has expired, a corresponding key expiration notification event can be generated.

[0067] Step S309: Listen for cached key expiration notification events.

[0068] In practical applications, the routing distribution layer can subscribe to key expiration notification events from the cache at startup, allowing for the release of corresponding resources by listening to these events. Since the routing distribution layer is typically deployed with multiple instances, all of which subscribe to the same master service node's event stream, it ensures that each key expiration notification event is received by at least one instance. Even if a small number of notifications are lost due to network fluctuations, the correctness of the function remains unaffected. This is because key expiration in distributed key-value stores is deterministic; lost notifications only delay resource reclamation, not permanent resource leakage.

[0069] Step S310: In response to receiving a key expiration notification event for the auxiliary expired key, determine the service node and message channel to be reclaimed based on the key name of the auxiliary expired key.

[0070] Step S311: Obtain the mutex marker. After successfully obtaining the mutex marker, acquire the distributed lock.

[0071] In practical applications, before starting resource reclamation, a mutex marker needs to be acquired to prevent the message channel of the same service node from being concurrently reclaimed by multiple routing instances. After successfully acquiring the mutex marker, a distributed lock needs to be acquired to protect the atomicity of subsequent counter update operations.

[0072] In the specific implementation, during the process of acquiring the mutex marker, the service node and message channel to be reclaimed can be used as reclaimed resources. A marker with the reclaimed resource identifier as the key and the current instance identifier as the value is created in the distributed key-value store, and a short expiration time is set, such as 10 seconds. When an instance starts to reclaim the resource, it attempts to create this key. If the creation is successful, it means that the instance has acquired the mutex marker and can continue to execute the reclamation; if the creation fails, it means that other instances are reclaiming the resource or have just completed reclamation, and the current instance abandons the reclamation.

[0073] Step S312: Under the protection of the distributed lock, reduce the load count of the service nodes to be reclaimed and reduce the reference count of the message channels to be reclaimed.

[0074] In practical applications, under the protection of a distributed lock, the following two atomic operations are performed: the load count of the service node to be reclaimed is reduced, for example, by 1; the reference count of the message channel to be reclaimed is reduced, for example, by 1. After all cleanup operations are completed, the distributed lock and mutex are released, completing a full resource reclamation process.

[0075] As can be seen from the implementation process, after incrementing the load count of the target service node and the reference count of the target message channel, this application establishes a binding relationship between the policy identifier and the target service node and the target message channel; writes the binding relationship into the cache and sets a first expiration time; generates an auxiliary expiration key corresponding to the binding relationship, the key name of which encodes the node identifier of the target service node and the channel number of the target message channel; writes the auxiliary expiration key into the cache and sets a second expiration time according to the first expiration time, so as to generate a key expiration notification event for the auxiliary expiration key based on the second expiration time; listens for the key expiration notification event in the cache; in response to receiving the key expiration notification event for the auxiliary expiration key, the service node and message channel to be reclaimed are determined according to the key name of the auxiliary expiration key; a mutex flag is acquired, and after successfully acquiring the mutex flag, a distributed lock is acquired; under the protection of the distributed lock, the load count of the service node to be reclaimed is reduced, and the reference count of the message channel to be reclaimed is reduced. This system implements resource reclamation triggered by key expiration notification events, which is more timely and efficient than periodic polling and scanning. Even if a small number of notifications are lost due to network fluctuations, it does not affect the correctness of the function, reducing the probability of notification loss and improving the accuracy of resource reclamation triggering. Furthermore, mutex markers prevent concurrent reclamation attempts for the same resource, ensuring that only one instance performs reclamation. Distributed locks guarantee the atomicity of the counter decrement operation, so even if an exception occurs during reclamation, there will be no inconsistent state where one counter has been decremented while another has not. The combination of mutex markers and distributed locks constitutes a double idempotent protection mechanism, ensuring accurate resource reclamation.

[0076] Understandably, to enable operations and maintenance personnel to monitor the load distribution of the entire supply system in real time and receive timely expansion alerts when capacity is insufficient, this application can also directly read reference count data written to the distributed key-value store by the routing distribution layer. For example, it can use monitoring tools to read the load count values ​​of all service nodes, the reference counts of each message channel under all service nodes, and the mapping of all policy identifiers and binding relationships from the distributed key-value store, without the need for additional data collection links, ensuring that the monitoring data is completely consistent with the actual routing behavior. Then, the load distribution is displayed from the following three dimensions: firstly, at the node level, displaying the total number of policies currently bound to each service node. Through the visualization of service node-level load, operations and maintenance personnel can quickly identify nodes with excessive load and load. The evaluation of load balancing effectiveness is based on three levels of service nodes. First, at the channel level, it distinguishes between three states: normal exclusive (reference count = 1), abnormal sharing (reference count > 1), and idle (reference count = 0). Under normal circumstances, each message channel should be exclusively occupied by one policy (reference count = 1) or in an idle state (reference count = 0). If the reference count of a message channel is greater than 1, it indicates that multiple policies are sharing the same message channel. This may be due to the resource reclamation mechanism failing to release resources in a timely manner, requiring attention from operations personnel. Second, at the global level, the utilization rate of message channels is calculated. The formula for channel utilization rate is the number of occupied channels (the number of channels with a reference count > 0) divided by the total number of channels. Channel utilization rate reflects the overall resource usage of the system. Operations personnel can set utilization rate thresholds, such as 80%. Monitoring tools calculate the global channel utilization rate in real time. When the utilization rate exceeds the preset threshold, an alarm message is automatically output, prompting operations personnel to add service nodes for horizontal scaling. In this way, the capacity warning mechanism provides operations personnel with data-driven scaling decisions, avoiding the subjectivity and uncertainty of relying on experience to determine whether scaling is necessary. Furthermore, it can be built into a multi-dimensional monitoring indicator system based on tenant, target application, provisioning protocol type, operation type, and execution result to accurately track the provisioning success rate of each tenant and each application, and achieve complete traceability of the provisioning process in conjunction with audit logs.

[0077] To facilitate understanding of the user directory provisioning routing and distribution scheme provided in this application, the scheme is now explained in conjunction with the IDaaS platform. The architecture of the IDaaS platform is as follows: Figure 4As shown, the system includes a message queue, a routing distribution layer, a distributed key-value storage cluster, a worker consumer cluster, and a service registry. The routing distribution layer executes the user directory provisioning routing distribution method provided in this application. Assuming an IDaaS platform serves 500 tenants simultaneously, each tenant has an average of 5 provisioning policies, totaling 2500 policies. The platform deploys 10 service nodes, each maintaining 16 message channels, for a total of 160 message channels. In traditional solutions, if each policy has its own dedicated service instance, 2500 service instances would be required, resulting in significant resource consumption. However, with this application's solution, the 2500 policies are distributed across 160 message channels on 10 service nodes. Each message channel carries an average of approximately 15.6 policies. Since this invention uses one policy per channel, 2500 channels are needed. By rationally configuring the number of service nodes and the number of message channels per service node, all policies can be carried using far fewer service nodes than the number of policies, while isolation is ensured through one policy per channel.

[0078] In the specific implementation, the service node (Worker node) is a stateful service node that is the consumer that actually performs the user directory supply operation. The consumption mechanism of the service node is as follows: Figure 5 As shown, the first feature is a stateful master-slave backup service, where each worker group consists of two nodes, a master and a slave, configured with the same identifier name. High availability of the master and slave is achieved through a failover subscription mode of a message queue, and the system automatically switches to the slave node after the master node fails.

[0079] Secondly, each service node maintains a fixed number of message channels, each exclusively consumed by a single consumer coroutine within that node. Upon startup, each service node creates a fixed number of consumer coroutines, each exclusively consuming one message channel. This one-coroutine-one-channel design ensures that operation messages within the same message channel are processed serially in the order of arrival. Since each supply strategy occupies a dedicated message channel, all operation messages under the same supply strategy enter the same channel and are consumed serially by the same coroutine, thus guaranteeing the consistency of the operation order. Operation messages arriving first are processed first, and those arriving later are processed later, eliminating the possibility of out-of-order processing. Furthermore, each consumer coroutine independently creates a set of plugin instances upon startup. Plugin states are not shared between coroutines; plugins are registered to the global registry through a self-registration mechanism. Workers create independent copies for each coroutine through factory functions, achieving thread safety without the need for mutex locks.

[0080] Furthermore, during the processing of operation messages, after receiving the operation message from the message channel, the service node immediately sends an acknowledgment (ACK) to the message queue before starting to process the message. This strategy of acknowledging before processing is called EarlyACK. The advantage of the EarlyACK strategy is that if the service node fails or the processing time is long during the operation message processing, the message queue will not redeliver the operation message to other consumers, thereby avoiding the duplication of operation message processing. Combined with the idempotency design of the downstream supply protocol, that is, executing the same operation multiple times has the same effect as executing it once, it can ensure that the operation message is not lost and avoid the side effect of duplicate delivery.

[0081] Next, the service node supports multiple provisioning protocols, such as SCIM (System for Cross-domain Identity Management) and LDAP. Different provisioning protocols are implemented by different plugins. Each consumer coroutine creates its own set of plugin instances upon startup, and the plugin state is not shared between coroutines. In this way, by creating an independent plugin copy for each coroutine during the construction phase, multi-threading contention issues are eliminated at the architectural level. Thread safety is achieved without the need for mutex locks, and each coroutine has its own independent plugin instance, allowing it to process messages from its respective channel in parallel without interference. Plugins are registered to the global registry through a self-registration mechanism, and the service node creates an independent copy for each coroutine through a factory function.

[0082] Finally, different supply protocols are implemented by different plugins, and the protocol type attribute in the message is automatically routed to the corresponding plugin. Based on this, this application defines two special error types to achieve fine-grained error handling. The first is the network retry error. When a supply operation fails due to temporary network problems such as network timeout or connection interruption, an exponential backoff retrieval is triggered. The service node waits for an increasing period of time before retrying the operation. The retry interval can increase exponentially, such as 1 second, 2 seconds, 4 seconds, 8 seconds, etc., to avoid traffic spikes when the network recovers. The second is the resource non-existence error. When a supply operation fails because a resource does not exist in the target system, such as updating a non-existent user, the update operation is automatically downgraded to a creation operation. This mechanism solves the fault tolerance and recovery problem when the target system's data is inconsistent. For example, if the IDaaS platform believes that a user already exists but the user has been deleted from the target system, the update operation will fail. Automatic downgrading to a creation operation can recreate the user in the target system, restoring data consistency.

[0083] It should be noted that, through the service registration and discovery mechanism, this application enables elastic horizontal scaling of stateful service nodes, giving stateful services scalability similar to that of stateless services. Specifically, each service node, upon startup, first initializes its internal state, including creating a fixed number of message channels and starting the corresponding consumer coroutines, and then registers its node identifier and network address with the service registry. The service registry maintains a dynamic list of service nodes, recording information on all registered and healthy service nodes. Service nodes need to periodically send heartbeat messages to the service registry to prove their continued existence. If the service registry does not receive a heartbeat from a service node within a preset time window, it marks the service node as offline and removes it from the service list. The routing distribution layer obtains the list of currently online service nodes in real time by listening to change events in the service registry. When the service list in the service registry changes, such as adding a node, a node going offline, or a change in node health status, the service registry pushes a notification to all routing distribution layer instances that have subscribed to the change event. After receiving the notification, the routing distribution layer updates its locally maintained list of online service nodes. When operations and maintenance personnel need to scale up, they only need to start a new service node instance. After starting, the new service node automatically registers with the service registry. The routing distribution layer detects the existence of the new service node through a listening mechanism. In subsequent routing calculations, the new service node will be included as a candidate node in the node-level minimum load selection. Since the load count of the new service node is 0 and it has not yet been bound to any provisioning policy, it will become the priority target for minimum load selection. This means that the newly added service node will quickly take over the new provisioning policy, achieving a smooth load migration. When operations and maintenance personnel need to scale down, they need to first shut down the target service node. Before shutting it down, the service node should first deregister from the service registry and stop receiving new bindings. Then, the service node waits until all messages in the existing channels have been consumed before exiting. After the routing distribution layer detects a node going offline through the listening mechanism, it updates the local online node list. In subsequent channel validity checks, offline service nodes will fail the check, and their corresponding binding relationships will be considered invalid, triggering rerouting. This ensures that operation messages are not sent to service nodes that no longer exist. Furthermore, regarding the handling of existing binding relationships on offline service nodes, these binding relationships will naturally expire when their expiration time arrives, and the corresponding load count and channel reference count will be released through an automatic resource reclamation mechanism. If operations and maintenance personnel wish to release these resources immediately, they can also manually trigger the reclamation.

[0084] It should also be noted that this embodiment only illustrates the solution using the IDaaS platform and does not limit specific application scenarios. For example, the solution in this application can also be applied in scenarios such as large-scale user batch import and hybrid cloud identity synchronization. In the scenario of large-scale user batch import, assuming that an enterprise may need to import the identity data of tens of thousands of users at one time when making organizational restructuring, resulting in a sudden surge in high-concurrency supply operations, in traditional solutions, the sudden traffic may cause consumers to be unable to handle it, resulting in serious message backlog. However, with the solution in this application, operations and maintenance personnel can quickly expand capacity and start new service nodes before the traffic arrives. The new nodes are automatically registered and detected by the routing layer, and immediately begin to bear the load. After the traffic peak, the capacity can be scaled down to save resources. In a hybrid cloud identity synchronization scenario, assuming an enterprise IDaaS platform needs to synchronize user data to a local AD / LDAP directory and multiple cloud SaaS applications, the provisioning strategies for different target systems need to run independently and in isolation. This is because AD / LDAP operations may be blocked due to network issues, but should not affect the synchronization to Salesforce. Through the one-policy-one-channel isolation model of this application, fault isolation between policies can be achieved. Even if the provisioning operation of a certain policy is blocked due to a target system failure, it will only affect the channel where that policy is located, and the provisioning operations of other policies will not be affected.

[0085] Please see Figure 6 , Figure 6 This is a schematic diagram of the structure of a routing and distribution system for user directory provision provided in an embodiment of this application.

[0086] This application provides a user directory provisioning routing and distribution system, which may include: The operation message acquisition module 101 is used to acquire operation messages provided by the user directory. The node selection module 102 is used to obtain the load count value of each service node and select the service node with the smallest load count value as the target service node. The channel selection module 103 is used to obtain the reference count of each message channel under the target service node and select the message channel with the smallest reference count as the target message channel. Update module 104 is used to increment the load count of the target service node and the reference count of the target message channel within the same atomic transaction; The sending module 105 is used to send operation messages to the target message channel of the target service node.

[0087] The user directory provisioning routing and distribution system provided in this application embodiment may further include: The identifier determination module is used to determine the policy identifier of the operation message before the node selection module obtains the load count value of each service node. The policy identifier is used to uniquely identify a supply policy. The cache query module is used to query the cache for the existence of a binding relationship corresponding to the policy identifier, using the policy identifier as the key. The binding relationship records the service nodes and message channels that the policy identifier has been bound to. If a binding relationship exists in the cache, it verifies whether the service nodes in the binding relationship are online and whether the message channel is valid. If the verification passes, it sends the operation message to the corresponding service node and message channel according to the binding relationship, ending the routing distribution process. If no binding relationship exists in the cache or the verification fails, it acquires a distributed lock at the policy identifier level. After successfully acquiring the distributed lock, it queries the cache using the policy identifier as the key. If a corresponding binding relationship already exists in the cache, it releases the distributed lock and sends the operation message to the corresponding service node and message channel according to the binding relationship, ending the routing distribution process. If no corresponding binding relationship exists in the cache, it executes the step of obtaining the load count value of each service node.

[0088] This application provides a user directory supply routing and distribution system. The cache query module is specifically used to: query whether there is a binding relationship corresponding to the policy identifier in the local memory cache using the policy identifier as the key; if there is no binding relationship in the local memory cache, query whether there is a corresponding binding relationship in the distributed cache using the policy identifier as the key; if there is a binding relationship in the distributed cache, determine that there is a binding relationship in the cache; if there is no binding relationship in the distributed cache, determine that there is no binding relationship in the cache.

[0089] The user directory provisioning routing and distribution system provided in this application embodiment may further include: A module is created to update the load count value of the target service node and the reference count of the target message channel after the module increments the load count value of the target service node and the target message channel. The binding relationship between the policy identifier and the target service node and the target message channel is then established. The first settings module is used to write the binding relationship into the cache and set the first expiration time; The key generation module is used to generate auxiliary expiration keys corresponding to the binding relationship. The key name of the auxiliary expiration key is encoded with the node identifier of the target service node and the channel number of the target message channel. The second setting module is used to write the auxiliary expiration key into the cache and set the second expiration time according to the first expiration time, so as to generate a key expiration notification event for the auxiliary expiration key based on the second expiration time. The listening module is used to listen for cached key expiration notification events; in response to receiving a key expiration notification event for an auxiliary expired key, it determines the service node and message channel to be reclaimed based on the key name of the auxiliary expired key. The recycling module is used to acquire a mutex marker. After successfully acquiring the mutex marker, it acquires a distributed lock. Under the protection of the distributed lock, it reduces the load count of the service nodes to be recycled and reduces the reference count of the message channels to be recycled.

[0090] This application provides a user directory supply routing and distribution system. The cache query module is specifically used for: querying a list of currently online service nodes; determining whether a service node in a binding relationship exists in the service node list; if the service node in the binding relationship does not exist in the service node list, the verification fails; if the service node in the binding relationship exists in the service node list, it determines whether the message channel number in the binding relationship is within the range of channel numbers allowed by the service node; if the message channel number in the binding relationship is within the range of channel numbers allowed by the service node, the verification passes; if the message channel number in the binding relationship is not within the range of channel numbers allowed by the service node, the verification fails.

[0091] The user directory provisioning routing and distribution system provided in this application embodiment may further include: The lock handling module acquires a global state lock before the node selection module selects the service node with the smallest load count value as the target service node. The global state lock is used to protect the read-write consistency of the load count value and the reference count. After incrementing the load count value of the target service node and the reference count of the target message channel, the global state lock is released.

[0092] This application provides a user directory supply routing and distribution system. The node selection module is specifically used for: batch querying the load count values ​​of all service nodes; setting the load count value to 0 for service nodes that do not have a load count value record; traversing all service nodes and selecting the service node with the smallest load count value as the target service node.

[0093] Based on the hardware implementation of the above program modules, and in order to implement the method of the embodiments of this application, the embodiments of this application also provide an electronic device. Figure 7 This is a schematic diagram of the hardware structure of the electronic device according to an embodiment of this application, as shown below. Figure 7 As shown, the electronic device includes: Communication interface 1 enables information exchange with other devices, such as network devices; Processor 2, connected to communication interface 1, enables information exchange with other devices and, when running a computer program, executes the routing and distribution method for user directory provision provided by one or more of the aforementioned technical solutions. The computer program is stored in memory 3.

[0094] Of course, in practical applications, the various components in an electronic device are coupled together through bus system 4. It can be understood that bus system 4 is used to achieve communication and connection between these components. In addition to the data bus, bus system 4 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 7 The general will label all buses as Bus System 4.

[0095] The memory 3 in this embodiment is used to store various types of data to support the operation of the electronic device. Examples of such data include any computer program used to operate on the electronic device.

[0096] It is understood that memory 3 can be volatile memory or non-volatile memory, or both. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), ferromagnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM); magnetic surface memory can be disk storage or magnetic tape storage. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), SyncLink Dynamic Random Access Memory (SLDRAM), and Direct Rambus Random Access Memory (DRRAM).The memory 3 described in the embodiments of this application is intended to include, but is not limited to, these and any other suitable types of memory.

[0097] The methods disclosed in the embodiments of this application can be applied to processor 2, or implemented by processor 2. Processor 2 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware in processor 2 or by instructions in the form of software. The processor 2 may be a general-purpose processor, DSP, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Processor 2 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the methods disclosed in the embodiments of this application can be directly manifested as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium, which is located in memory 3. Processor 2 reads the program in memory 3 and completes the steps of the aforementioned method in combination with its hardware.

[0098] When processor 2 executes the program, it implements the corresponding processes in the various methods of the embodiments of this application. For the sake of brevity, these will not be described in detail here.

[0099] In an exemplary embodiment, this application also provides a storage medium, namely a computer storage medium, specifically a computer-readable storage medium, such as a memory 3 that stores a computer program, which can be executed by a processor 2 to complete the steps described in the aforementioned method. The computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface memory, optical disc, or CD-ROM.

[0100] In an exemplary embodiment, this application also provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the steps of the method described in any of the preceding embodiments.

[0101] In the several embodiments provided in this application, it should be understood that the disclosed apparatus, terminal, and method can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.

[0102] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs.

[0103] In addition, each functional unit in the various embodiments of this application can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be implemented in hardware or in the form of hardware plus software functional units.

[0104] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media that can store program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.

[0105] Alternatively, if the integrated units described above are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause an electronic device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.

[0106] For descriptions of relevant parts of the user directory supply routing and distribution system, electronic device, and computer-readable storage medium provided in this application's embodiments, please refer to the detailed descriptions of the corresponding parts in the user directory supply routing and distribution method provided in this application's embodiments; they will not be repeated here. Furthermore, parts of the technical solutions provided in this application that are consistent with the implementation principles of corresponding technical solutions in the prior art have not been described in detail to avoid excessive elaboration.

[0107] It should also be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0108] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for routing and distributing user directory provisioning, characterized in that, include: Retrieve operation messages for the user directory supply; Obtain the load count value of each service node, and select the service node with the smallest load count value as the target service node; Obtain the reference count of each message channel under the target service node, and select the message channel with the smallest reference count as the target message channel; Within the same atomic transaction, increment the load count of the target service node and the reference count of the target message channel; The operation message is sent to the target message channel of the target service node.

2. The method according to claim 1, characterized in that, Before obtaining the load count values ​​of each service node, the process also includes: Determine the strategy identifier of the operation message, wherein the strategy identifier is used to uniquely identify a supply strategy; Using the policy identifier as the key, query whether there is a binding relationship corresponding to the policy identifier in the cache. The binding relationship is used to record the service nodes and message channels that the supply policy corresponding to the policy identifier has been bound to. If the binding relationship exists in the cache, then it is verified whether the service node in the binding relationship is online and whether the message channel is valid. If the verification passes, the operation message is sent to the corresponding service node and message channel according to the binding relationship, thus ending the routing distribution process; If the binding relationship does not exist in the cache or the verification fails, a distributed lock is acquired at the granularity of the policy identifier. After successfully acquiring the distributed lock, the cache is queried using the policy identifier as the key. If the corresponding binding relationship already exists in the cache, the distributed lock is released, and the operation message is sent to the corresponding service node and message channel according to the binding relationship, thus ending the routing distribution process. If the corresponding binding relationship still does not exist in the cache, then proceed with the step of obtaining the load count value of each service node.

3. The method according to claim 2, characterized in that, Using the policy identifier as the key, query whether a binding relationship corresponding to the policy identifier exists in the cache, including: Using the policy identifier as the key, query whether a binding relationship corresponding to the policy identifier exists in the local memory cache; If the binding relationship does not exist in the local memory cache, then the policy identifier is used as the key to query whether the corresponding binding relationship exists in the distributed cache; If the binding relationship exists in the distributed cache, then it is determined that the binding relationship exists in the cache. If the binding relationship does not exist in the distributed cache, it is determined that the binding relationship does not exist in the cache.

4. The method according to claim 2, characterized in that, After incrementing the load count of the target service node and the reference count of the target message channel, the method further includes: Establish a binding relationship between the policy identifier and the target service node and the target message channel; Write the binding relationship into the cache and set a first expiration time; Generate an auxiliary expiration key corresponding to the binding relationship. The key name of the auxiliary expiration key is encoded with the node identifier of the target service node and the channel number of the target message channel. Write the auxiliary expired key into the cache, and set a second expiration time according to the first expiration time, so as to generate a key expiration notification event for the auxiliary expired key based on the second expiration time; Listen for cached key expiration notification events; In response to receiving a key expiration notification event for the auxiliary expired key, the service node and message channel to be reclaimed are determined based on the key name of the auxiliary expired key. Acquire a mutex marker, and after successfully acquiring the mutex marker, acquire the distributed lock; Under the protection of the distributed lock, the load count of the service nodes to be reclaimed is reduced, and the reference count of the message channels to be reclaimed is reduced.

5. The method according to claim 2, characterized in that, The verification of whether the service node in the binding relationship is online and whether the message channel is valid includes: Query the list of currently online service nodes; Determine whether the service node in the binding relationship exists in the service node list; If the service node in the binding relationship does not exist in the service node list, the verification fails. If a service node in the binding relationship exists in the service node list, it is determined whether the message channel number in the binding relationship is within the range of channel numbers allowed by the service node. If the message channel number in the binding relationship is within the range of channel numbers allowed by the service node, the verification passes. If the message channel number in the binding relationship is not within the range of channel numbers allowed by the service node, the verification fails.

6. The method according to claim 1, characterized in that, Before selecting the service node with the smallest load count value as the target service node, the following steps are also included: Acquire a global state lock, which is used to protect the read-write consistency of the load count and reference count; After incrementing the load count of the target service node and the reference count of the target message channel, the method further includes: Release the global state lock.

7. The method according to claim 1, characterized in that, The step of selecting the service node with the smallest load count value as the target service node includes: Batch query the load count values ​​of all service nodes; For service nodes that do not have load count records, set the load count to 0; Iterate through all service nodes and select the service node with the smallest load count as the target service node.

8. A routing and distribution system for user directory provisioning, characterized in that, include: The operation message acquisition module is used to acquire operation messages provided by the user directory; The node selection module is used to obtain the load count value of each service node and select the service node with the smallest load count value as the target service node. The channel selection module is used to obtain the reference count of each message channel under the target service node and select the message channel with the smallest reference count as the target message channel. The update module is used to increment the load count of the target service node and the reference count of the target message channel within the same atomic transaction. The sending module is used to send the operation message to the target message channel of the target service node.

9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the routing and distribution method for user directory provisioning as described in any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the routing and distribution method for user directory provisioning as described in any one of claims 1 to 7.