XPO and database replication
After 15 years of working with XPO, I have seen many tickets asking if XPO is capable of doing data replication and all the time DevExpress team answer those tickets saying that replication its out of the scope of XPO and that it’s actually true.
So, to start talking about database replication lets try to define what “replication” means. Here is the definition of replication according to Wikipedia
“A computational task is typically replicated in space, i.e. executed on separate devices, or it could be replicated in time, if it is executed repeatedly on a single device. Replication in space or in time is often linked to scheduling algorithms”
The keywords on the above statement are task, space and time, so to replicate a database operation we need to know the following information
- What was the task?
- Who performed the task?
- When was the task performed?
- Who needs to know about the task what was performed?
Now let’s think what are the steps that any traditional database does, in order to replicate the data between instances
- It shares a copy of the database schema to the other instances/locations/devices
- It logs the DML statements that happened to a main instance/location/device
- It broadcast the statements on this log to the other instances/locations/devices
- it processes the statements on the target instance/locations/devices
Now the question is, can we do the same with XPO?
thanks to the great architecture develop by the XPO Team, the answer is a big YES!!!
so, let’s compare how you can match traditional database replication with XPO
Traditional database replication | XPO database replication | |
1 | Share a copy of the database schema. | In XPO we can re-create a database schema using the method UpdateSchema from the Session class. |
2 | Logs the DML statements. | In XPO we can keep track of the BaseStatement at the DataLayer level. |
3 | Broadcast the statements
|
We can transport the log of statements using any of the dot net network technologies like WCF, remoting or Web API. |
4 | Process the statements on the target instance, device or location
|
To process any kind of BaseStatement we can use the XPO DataLayer on the target instance, device or location |
So, it looks like DotNet and XPO provide us of all the necessary infrastructure to do a database replication so why not give it a try right?