In this sneak peak post we’ll take a look at a new feature for XPO, direct from the “Devexpress Labs”. For sometime now the guys in the lab have been trying to solve the problem of how to make distributed databases more ubiquitous, and it looks like they’ve finally cracked it!
As you know the advantage of the distributed database model is that the data is distributed, the clue’s in the name really. This means that each node of the distribution graph has less work to do and it also means that it is more secure and more likely to be “always available” – if one node fails then you can simply get the required data from another node. Of course this advantage also forms the basis for the disadvantage of this system, and that is how to guarantee access to all the data in a “sometimes connected” distributed database system?
Well to solve this problem, the guys in the lab have taken advantage of Stanley Milgram’s work on the Six Degrees of Separation phenomenon. As you know, this work shows that there are only 6 degrees of separation between any two people on the planet. They coupled that with the fact that, in most developed countries in the world, most people have mobile phones. You’ll be aware of the fact that most mobile phones have bluetooth capabilities too.
So how does it work? Well, quite simply, when you send CommitChanges() to a UnitOfWork instance – and you have distributed database support turned on – then the UnitOfWork collects all the objects that require to be persisted and iterates over them, first taking a hash of the object, so that it can be found later on. It then looks around for a mobile bluetooth device. Having found one, it simply sends the object, as a message, to that device. The UnitOfWork ensures that each object is persisted to a different mobile bluetooth device to ensure the maximum distribution in the system.
That is the simple part. Reading information from this distributed database is the clever part. When you wish to read the data back, the UnitOfWork simply finds the first available bluetooth enabled mobile device and issues a request for the object with the given hash. If that device has the object then it is returned, if not then the device issues a request for the object to everyone in the address book. If one of them has it then they return the object, if not then each of them issues a request to everyone in their address book and so on and so forth, in a cascade effect. Milgram’s work guarantees that the maximum number of hops, between devices, is six and when found, the object is returned back along the chain of devices to the UnitOfWork.
I think this is a great use of ubiquitous computing from the guys in the lab, if you want to try it out for yourself then download the update for XPO and have fun.
Until next time, happy XPOing!