Windows 5.0 -- Optimizing data sync

Optimizing mobile applications can be a difficult task, but from an end user standpoint, it is the speed, responsiveness and functionality of the application that is most important. By combining the network notification capabilities of SNAPI with the background and priority synchronization capabilities of a product like SQL Anywhere, the task becomes much simpler.

When developing a mobile application, one of the most difficult tasks is optimizing data movement over networks, which may or may not be available. Some difficulties that a developer will face include:

  • Determining the best network connection to use based on current device coverage
  • Prioritizing information sent based on the network(s) that are currently available
  • Implementing background synchronization to allow a user to continue to work

Developers using Windows Mobile 5.0 can make this job simpler, however. Windows Mobile 5.0 contains built-in functionality that can provide a truly optimized data synchronization application when successfully integrated with the functionality built into a data management product such as SQL Anywhere 10 from Sybase iAnywhere. SQL Anywhere 10 includes a synchronization server and client called MobiLink, as well as a small but fully functional relational database for mobile devices, called UltraLite. SQL Anywhere currently supports Windows, Linux, UNIX, Mac OS X, Palm, Symbian, and Windows Mobile.

Mobile architecture
A common architectural approach to building mobile applications includes an enterprise database on the back end -- such as SQL Server, Oracle, DB2, Adaptive Server Enterprise or even SQL Anywhere -- and SQL Anywhere as the enterprise database store on the client side. In this case, a relational database called SQL Anywhere UltraLite can be used to store the information on various endpoints, including desktops, laptops, PDAs, smartphones, and so on. Between these databases there is a MobiLink client integrated into the UltraLite database engine and a MobiLink server located in the corporate headquarters, which will manage the movement of changes. The following diagram outlines the general architecture.

Optimizing data synchronization
Tracking network states using the state and notification broker API

A major, often overlooked new feature in Windows Mobile 5 is the state and notification broker API called SNAPI. This element provides a built-in notification broker structure for the Windows Mobile 5.0 environment, which in turn enables a mobile application to be notified when certain events take place on the mobile device. These "events" could be anything from a user plugging in a Bluetooth device to the arrival of a new SMS message. You can use SNAPI to help monitor the states of the various network devices available on the PDA (Wi-Fi, GPRS, cradle, etc.). Through SNAPI, your mobile application will have the ability to determine which networks are currently available. Once this occurs, your application can choose the optimum route to communicate with a synchronization server, such as MobiLink.

Background synchronization
Background synchronization -- the ability to synchronize changes while the user is still working with the database -- is a critical function for all mobile applications. However, there is nothing more frustrating to a user than being locked out of an application while a system is synchronizing changes. If the right solutions are used, background synchronization should be completely anonymous to the end user. Not all mobile databases have the ability to handle background synchronization, however, so it is an extremely important feature to consider when choosing a mobile database.

UltraLite synchronization runs on a separate connection, which means that the user will have read-only access to the database when uploading changes and full read-write access when downloading changes. However, if the application changes a row that the download then attempts to change, the download will fail and roll back. Another option is to disable access to the database during synchronization.

One of the easiest ways to implement background synchronization is to use a timer. The timer event will talk to SNAPI to determine whether there is currently a network available. If there is one, the application will then choose to initiate background synchronization based on the type of network available. Once again, since UltraLite executes the synchronization on a separate thread, the user can continue to access the database without knowing that synchronization is occurring.

Priority synchronization
Priority synchronization gives the user or mobile application the independent ability to control when different data subsets are synchronized. This is especially important for users who need immediate access to information. The main advantages of priority synchronization include:

  • Maximizing network bandwidth usage
  • Synchronization of specific data changes at various times in the day, including off-peak times to minimize the server performance impact
  • Optimization of synchronization time

SNAPI enables tracking of the various network states on the device. When SNAPI is combined with priority and background synchronization, users have the ability to change the types of information sent based on the available network. For example, if a device has only a GPRS connection available, you may choose just to send high-priority information, such as uploading sales orders for a sales rep or downloading route changes for a field worker. Alternatively, if SNAPI recognizes that there is a cradle or WI-Fi connection available, you may wish to conduct a full synchronization that would include uploading and downloading the entire set of changes for both databases.

In an SQL Anywhere or UltraLite remote database, publications can be used to control priority synchronization -- a publication is a set of tables to be synchronized. If you have a high-priority and low-priority publication, you can choose either to synchronize your high-priority tables or both your high- and low-priority tables. By default, MobiLink sends changes bi-directionally, but synchronization can be customized to an upload-only or download-only synchronization of publications.

Optimizing mobile applications can be a difficult task, but from an end user standpoint, it is the speed, responsiveness and functionality of the application that is most important. By combining the network notification capabilities of SNAPI with the background and priority synchronization capabilities of a product like SQL Anywhere, the task becomes much simpler.

About the contributor: As senior product manager of Data Synchronization Technologies for Sybase iAnywhere, Liam Cavanagh has been instrumental in the development of "always available" mobile enterprise solutions – enabling mobile workers to remain productive regardless of network availability. He also works with enterprises implementing mobile solutions and conducts training seminars worldwide on mobile and wireless technology design, development and deployment. Liam holds a bachelor of mathematics degree in business and information systems from the University of Waterloo, Waterloo, Ontario, Canada.

Dig Deeper on Mobile data, back-end services and infrastructure

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.