The way in which you manage synchronization within your application can depend on your network. Synchronization strategies for computers connected by a single local area network (LAN) are usually quite different from synchronization strategies for computers connected using wide area networks (WANs) and modems. For computers connected through a single LAN, synchronization can occur frequently because telecommunication overhead does not have to be considered.
With WANs, telecommunication overhead can be a major factor because of longer data transmission times and higher transmission rates. In this section, two different WAN topologies are discussed, along with possible ways to handle synchronization.
The following diagram shows a company that has an order-entry department in Denver and headquarters in Boston. Each day, customers call an 800 number to order products from the company’s catalog, and these orders are entered in a custom Microsoft Jet database application.
Figure 7.3 Ring topology synchronization over a WAN
Note Networks have topologies too, and these should not be confused with replication topologies. For example, a network topology can be a ring, a star, or a straight line. The ring (circle) shown in the diagram above refers to the replication topology. The underlying network topology is not shown and can be of almost any type.
Once a day, sales transactions entered in Denver must be transferred to headquarters, where managers can run queries against the data to track sales totals, geographic sales distribution, and other statistics. Conversely, updated product information such as new products and discounts on existing products must be sent from headquarters to the sales office as soon as it is available. Computers in the order-entry department make up a single LAN, and computers at headquarters make up another LAN. The two LANs are connected through a modem.
In this environment, how can replication be configured efficiently to meet the company’s requirements? Configuring replication within each LAN is a fairly straightforward task. For example, the databases in Denver could be configured to synchronize data every 30 minutes by using a ring topology. In a ring topology, computer A updates computer B, which updates computer C, and so on. This update chain occurs repeatedly at specified intervals and can be set by using Microsoft Replication Manager or by using DAO methods and the Timer event. The databases in Boston can be configured to regularly synchronize data in a similar manner.
The main concern is the bottleneck created by the modem link between Denver and Boston. For a large number of sales transactions, the telecommunications overhead of frequently synchronizing data between the two cities would be high. But because headquarters needs information only once a day, a good strategy would be to wait until night to synchronize one of the computers in Denver with one of the computers in Boston. The computer in Boston and the computer in Denver must be fully synchronized within their respective rings before they synchronize between the two rings. After the information is synchronized between the two computers, the periodic synchronization that occurs between computers in the same city disperses the information to all computers.
Because product information in Boston must be sent to Denver only when new information is available, replication can be configured to occur only when necessary. This might occur once or twice a week. To handle this, a user could click a button on a form to synchronize the databases in Denver and Boston whenever product information changes. A more sophisticated solution would be to set a value in a table each time information in one of the product tables changes. A procedure linked to a Timer event would periodically check this value and invoke the Synchronize method whenever the value is set.
Caution It is highly recommended that you take special precautions when performing exchanges over WANs. When “direct” exchanges are performed over dial-up lines, the potential for database corruption increases substantially. This is due to the fact that the local Synchronizer or reconciler can be asked to make many lengthy updates to the remote database over slower, and often unreliable, switched lines. If the line is dropped, or interrupted, while the local process is updating the remote replica, corruption can occur because exchanges are not transactionally secure. For this reason it is recommended that you make exchanges often to minimize the duration of the exchanges and do what you can to ensure the integrity of your dial-up connection. Alternatively, you can use Replication Manager to set up indirect synchronization. In this configuration, updates are first transferred to the remote site and then are applied locally on the same machine.