Step 8. Which role instance is active
In the previous steps we approached this question several times, but to formulate it and answer it fully, the categories considered so far are only now sufficient.
For example, in the case from step 1, WS discovers the required DC in exactly the same way as when DC is made redundant in Active-Passive mode and split into groups by domain zones.
There are several principles that solve the problem concentrated in this question. Each is used in its own place.
The most obvious: given a configuration file, all that remains is to iterate over all servers on the site that could in principle host the required role. This is not the most efficient method for several reasons, and the loss of performance and speed is not the main one. The key reasons lie in the architecture and style of the «Incoplax» platform itself. At the very least it could be improved by adding caching and encapsulating this lookup in a separate service. In general, everything discussed further in this step is one combination or another of these mentioned improvements.
Principle 1. Named microservices
For other system services, the DC role is visible as a list of named microservices, one per domain. It is these microservices that are started by the active role instance and are not started by standby instances. It is these microservices that are split across role groups according to the served domain zones. Thus, for WS it is enough to formulate a task oriented toward DC and specify the domain of interest; the rest is handled by the
global names subsystem. At the same time, WS does not care which DC variant is on its site, MDC or SDC, how exactly domain zones are split across DC role groups, which domains are served on the current site, and which are proxied. All of this is implemented outside it: in the global names registration system and in the DC role itself.
The global names registration system is the main purpose of the RPCI service role. It registers the associations of global names with microservice addresses on the current site, monitors registered microservices so as not to store or use zombie registrations, and returns the address of the current responsible microservice by global name in response to requests from other subsystems.
The RPCI role is made redundant in Active-Active mode and has a client module active on any node and available to any services on it. In fact, the client module is the functional facade of RPCI.
Thus this is a simultaneous implementation of the caching tactic and the encapsulation principle. However, each role that owns globally named microservices is responsible for registering its microservices in RPCI, for switching global names during takeover, and for following the naming conventions (names are used on both sides: when a microservice is registered and when it is looked up before sending a request). RPCI is responsible for continuous provision of up-to-date information.
When considering service interaction of roles in the diagram, their distribution across servers does not matter. What matters is only that they are all on the same site.
Principle 2. Client module for encapsulation
The first principle above mentions the client module of the RPCI role, available on any node. It looks up the service of the RPCI role and caches unavailable instances while periodically checking them. This principle is used for service roles; in particular, ServerShell looks up IC in exactly this way.
This approach implements the encapsulation principle. Whether caching is present depends on the specific implementation of the role’s client component.
Principle 3. Local availability monitoring
A number of roles are made redundant and scaled in Active-Active mode. So far, only WS has been considered among such roles, but it is not an ideal example because only external actors use it. Nevertheless, imagine that some internal service needs to process a request in one of the instances of such a role. If it is a specific instance, it is addressed precisely, and that is not a problem (for example, external actors do this with WS). But if it is enough for any instance of the role to process the request, then an available one must be selected. If there is a failure, for example, take the next one and execute the request again; this depends on the context and may involve transactions.
To avoid contacting the RPCI server every time, the local client module, after receiving a response from the server, puts the returned process under monitoring. Subsequently, until that process terminates, data about it is provided locally and promptly.
Principle 4. Ping-pong and broadcast
Caching is not always useful; there are operations that cannot tolerate even 5 seconds of extra delay. Such a delay can occur if the cache provides data about an unavailable server for some time, and the request initiator sends a request and waits for its execution or some response for some time before recording a failure and moving to the next instance. This is solved by a system ping-pong before sending the request. The ping request either passes quickly, or the server/service is definitely unavailable. The advantage of the approach is a cheap, fast freshness check. Internal services do not overuse pings in tasks that are not time- or delivery-reliability-critical, so their total number in traffic is not too high.
Broadcast request sending can be used where request processing takes significantly longer than packet processing. Thus, during a broadcast, the expectation is that the recipient role will independently determine which instance will execute the request. Or the responses of each instance may be needed at all; for example, in the case "collect all external connections of the system", it would be necessary to poll all WS roles and merge their responses into one list. Of course, broadcast is performed in parallel: requests are sent to all recipients and only then are responses collected.
| Term | Definition |
|---|---|
|
! |
|
! |
|
! |
|
! |
|
! |
|
! |
|
! |
|
! |
-
Next step: Step 9. Cross-site interaction
-
Previous step: Step 7. Ensuring scalability