Share via


Simplifying Synchronization-Challenges of a multi-device, highly-connected world

Simplifying Synchronization Complexities

Synchronizing data is more important than ever. Never has there been more device types and never has the world of distributed systems been more common. I’m getting a lot of questions about keeping phones, browsers, and databases synchronized.

Things get difficult right away.

Mobile Applications How do you send data to a mobile application if that mobile application isn't running the application that needs the data?
Web Browsers What about a web browser that needs to get realtime updates? How do you avoid really chatty Javascript that constantly makes asynchronous calls the the server? After all, http is stateless.
Relational data in the cloud What about your relational data? What if you have SQL Azure hosted in a Microsoft data center and what if you want to keep that data synchronized with some SQL Server data that is hosted on-premise?

There a many scenarios the modern developer faces. Moving forward, as the lines separating between desktop, tablet, and mobile become increasingly blurred, the synchronizing challenge will increase. Consumers will switch between devices and expect to be able to continue where they left off. They also expect to get the latest information from applications.

Developers must support cloud, on-premise and mobile. I present you three challenges and three solutions.

How do you send data from a web server to a mobile device?
How do you send near real-time updates to browsers from web servers?
How do you synchronize events between cloud-hosted sites and on-premise sites?

The Big Picture

Figure 1: A Visual Picture of Synchronization Challenges The various players in the world of synch.

How do you keep this stuff synchronized?

The 3 challenges I will address here are:
(1)Synchronizing Mobile and Web
(2)Relational data base in the cloud and hosted on-premise
(3)Browser and Web

4s1ie0fs


Challenge #1: Web user needing latest information from an on-premise web site

This situation is very common. The goal is to have real-time persistent long-running connections between the on-premise web site and the remotely connected web user.

Imagine the web user wants real time stock price information.

There are many situations where you want as near real time as possible to synchronize the web server and the browser.

txfxpski

karzi4ui

Figure 2: A user of a web browser needs the latest from the ASP.NET Web Site (doesn’t have to be a browser, could be a .NET Client as well)
Keeping the web user synchronized with up to the second weather, travel or financial information. Note that the web site/service could be hosted on-premise or in the cloud.

Solution to Challenge #1 - SignalR

Scott Hanselman describes SignalR succinctly as "Asynchronous scalable web applications with real-time persistent long-running connections."

There are two pieces to SignalR, a client piece and a server piece. The client piece comes in two forms: (1) Javascript for browsers; (2) .NET for web apps or for thick client (WPF, WinForms, etc).

1 Server and 2 clients Library Name Description
Server SignalR.Server Server side components needed to build SignalR endpoints
Client #1 SignalR.Js Javascript client for SignalR
Client #2 SignalR.Client .NET client for SignalR
     

Where to get SignalR

https://github.com/SignalR/SignalR

 

 


Challenge #2: Synchronizing databases (SQL Azure and On-Premise SQL Server)

The challenge is having multiple copies of databases in different locations. There is a need to synchronize multiple copies of a database globally dispersed. You can even think of the scenario as needing to sync two different web sites. Often times and efficient way to pass messages from the cloud to an on-premise web site/service is to have some type of an Messages table that is kept in synch between op-premise and cloud-hosted databases.

d0pzjczu

Figure 3: Synchronizing geographically dispersed databases.
Using SQL Azure Data Sync to keep databases properly synchronized
Image here

Solution to Challenge #2: Microsoft SQL Azure Data Sync

Microsoft SQL Azure Data Sync is a cloud-hosted data synchronization service which provides uni-directional and bi-directional data sync. Data Sync allows data to be easily shared between SQL Azure and on-premises SQL Server databases, as well as between multiple SQL Azure databases.

Benefits of Microsoft SQL Azure Data Sync

No holes in corp firewall
No web services
SQL Data Sync Service Agent Process & WCF

Where to get Microsoft SQL Azure Data Sync

https://msdn.microsoft.com/en-us/library/hh667316.aspx

 

 


Challenge #3: Sending data to mobile devices from the cloud for from on-premise web sites

The challenge is not having mobile devices “poll” for new data. This is also known as the “pull” model, where by the mobile application needs to constantly ask the web server if there is newer data. This is considered too chatty, meaning that it wastes bandwidth, doesn’t scale well, and drains battery life.

In a practical sense, it doesn’t work well, since most mobile frameworks don’t allow applications to constantly poll web services, because of the limited power of batteries.

psawi3qh 

Figure 4: Sending data to mobile devices

From on-premise or cloud-hosted web sites

Solution to Challenge #3: Push Notifications services

The solution is to leverage the native notification frameworks available in today’s modern devices. There are third party vendors, such as Urban Airship, as well as implementations by Apple and Microsoft.

Microsoft offers a powerful service hosted in Windows Azure. The diagram illustrates the major pieces. As you can see, the Microsoft Push Notification Service brokers or proxies the messaging interactions. Notice that there is a push client service built into the Windows Phone 7 frameworks and operating systems.

0gn1mrxn

Figure 5: Windows Push Notification Services Diagram

How the pieces fit together

Two Types of Notification

(1) Toast evltzydd
(2) Tile 0jksgclk

Here is an example relevant for Windows Phone 7 developers.

3twixja3

Figure 6: A Cloud Hosted Notification Server sending messages to a Windows Phone 7 Device
Developers can easily create scalable, cloud-hosted push notifications services with the Windows Azure SDK and Visual Studio web sites

Benefits to Solution #3

The definitive way to send data from a web server/service to a mobile device. The primary driver is enabling updates to the mobile device but not requiring the an application to always be running. This approach saves on battery life.

Where to get more information on Push Notification Services

How it works can be found here: https://msdn.microsoft.com/en-us/library/ff402558%28v=VS.92%29.aspx

There is also an extensive lab in the Windows Phone Training Kit 


Conclusion

I presented 3 technologies that will help you stay synchronized. There is more to discuss in a future post. Here are some additional synchronization technologies that offer additional capabilities.

Technology Features
Windows Azure Service Bus Integrate on-premise and the cloud

Event notifications to occasionally connected clients

Store messages with connectivity failure

Integrate across NATs, firewalls

Multiple web service standards - REST, WS-*, SOAP

More secure than a VPN

Asynchronous Cloud Event Support

Azure Traffic Manager Geo-load balancing. Manage and distribute incoming traffic to your Windows Azure hosted services whether they are deployed in the same data center or in different centers across the world
   

Download for Azure SDK