Step 5. Synchronizing domain data between sites

The domain center located on the master site runs in the MDC (Master Domain Center) role and has a direct connection to DomainDB, as discussed in step 1. The domain center located on any other site runs in the SDC (Site Domain Center) role and caches data in a local object DB. The MDC role stores data about all domains of the entire system and their entities, even if a domain is not served on the site according to the configuration file. The SDC role caches data only for the domains served on its site according to the configuration file. Nevertheless, SDC owns the full domain tree, and when receiving requests for unserved domains it proxies them to the sites serving them (SDC–SDC or SDC–MDC communication).

mdc sdcThe master domain is fully served only on the master site (in the MDC role). Serving requests to the master domain in SDC differs from serving requests to other domains not served on the site: some requests are also proxied (to MDC), while some are processed locally. Accordingly, part of the master domain’s settings and entities is cached in SDC for the site to operate independently when communication with the master site is unavailable.

Since for all other parts of the system what matters is the domain center functionality, and the difference between MDC and SDC is irrelevant, it is customary to refer to the DC role in contexts where the difference between them does not matter.

MDC on the master site, through DomainDB, is the backup storage of all domain settings and entities. At any time, another site can be added to the configuration, domain zones can be bound to it, and the SDC on it will load all related entities into its storage by synchronizing with MDC.

A dedicated DomainDB guarantees the possibility of a complete reinstall of the system while preserving all domain settings and entities.

SDC–MDC data synchronization

Whenever modifying CRUD operations on domain entities are performed on the worker site serving the domain, the data first goes to SDC and then, on success, is sent to MDC, from where it reaches the domain DB.

seq_sdc_mdc
Case: an administrator performs modifying CRUD requests while connected to the WS of the master site, while the domain is served on a worker site.

For this, there is a synchronization process initiated by each SDC. It is precisely in this process that the accumulated unexecuted changes are first sent to MDC, and only after that a full synchronization of SDC and MDC is performed, with MDC acting as the source of information. Every 20 seconds, each site performs a synchronization procedure between SDC and MDC.

seq_mdc_sdc

Consequence: an administrator modifies an entity through the WS of a worker site; SDC accepts the changes and sends them to MDC, which rejects them. In this case, the administrator sees that the entity changed, but after 20 seconds the changes are rolled back, because MDC acted as the source of information during synchronization and does not contain these changes.

SDC–SDC communication

SDCs communicate directly with each other only when proxying requests from one site, where a domain is not served, to another, where the domain is served. This is degenerate communication.

Multi-site domain service

Case: an administrator applies a configuration in which a domain is assigned to be served by two sites. After some time, both sites operate fully and consistently.

sdc mdc sdcA domain can be served on several worker sites. This is configured by the configuration file (step 1). Different roles exhibit different behavior patterns in connection with multi-site domain service. Let us consider how SDC behaves in this situation. It turns out that everything has already been covered: its behavior follows from its synchronization process with MDC. Whenever some entity changes in SDC on one of the sites, the change first reaches MDC and then is synchronized from there to other SDCs (see figure). Conflicts are also resolved through MDC and its transactionality: when an element with the same identifier is created from different sites, the one that reaches MDC first wins; when one object is modified, the one that reaches MDC last wins; deletion is order-independent but has priority over entity modification in any operation order. Obviously, an infinite synchronization loop between several sites is impossible. Keep in mind that synchronization of domain entities between two sites occurs at 20-second intervals. That is, sites will mostly synchronize within 20 seconds. In some rare cases, synchronization time can increase several times.

Case: an administrator applies a configuration in which a domain zone with three levels of domains is bound to a new site. Every 20-second interval, one level of domains of the moved zone is synchronized: first the first level of domains is synchronized, its entities include child domains, and they are activated; after 20 seconds they are synchronized and pass the baton to the third-level domains of the zone.
sync_domain_levels

Worker site without communication with others

Case: an administrator performs a modifying CRUD request on the WS of a worker site when MDC is unavailable (perhaps there is no communication with the master site, or something else).

In this case, everything looks the same to the administrator as in step 1. Internally, the changes are applied to the current site and saved in a queue for sending. SDC periodically attempts to send them in exactly the order in which they were applied. The queue size is limited to 10,000 modifying CRUD requests per site, after which SDC starts rejecting their execution.

seq_sdc_mdc_fail
Case: two administrators on two sites modify the same entity when the master site is unavailable to one site.

As a verification exercise, try to describe the process stages yourself up to the completion of synchronization and determine the states of the modified entity on these sites at each stage.

Table 1. Terms used
Term Definition

MDC

!

SDC

!

DC

!

Object DB

!

Proxying a request to another site

!

Multi-site domain service

!