Tips & Tricks: the fastest synchronization in the West

by Giuseppe Lanzi on 03/27/2013

The user experience is the most important characteristic of a successful app. It is perceived to be good when it is functional, simple, and fast. In terms of speed, there’s a little trick I’d like to recommend to optimize synchronization of data between mobile apps and the central server.

Without any additional steps, the Instant Developer framework reduces data exchanged with the server to a minimum, working differentially and in clusters. The only time you might have to wait is during the first synchronization, when the device’s database is completely empty and has to be populated from scratch. Are there 500,000 objects to synchronize? Then the device will receive an XML from the server with 500,000 nodes and will write as many records to SQLite.

In this case, you can use a faster method: instead of transferring each individual object, during the first synchronization you can have the entire database returned by the server as a single file, to be restored on the device in one fell swoop. Here’s how:

  1. the mobile device empties all the SQLite database tables and then backs up the file using the BackupDB method;
  2. the device sends the file to the synchronization server using UploadFile;
  3. the server restores the empty database using RestoreDB and populates it using the appropriate queries;
  4. the server backs up the file again and responds to the device;
  5. the mobile device downloads the file containing the database that was just populated and runs a restore.

And that’s it! To give you an idea, when we’ve used this method it has been 10 times faster than the automatic method.

I know some of you are thinking, “That’s easy enough to say, but how do I do it?” which is why I’ve put together this example project to show you how it’s done.

Let me know how it goes. 🙂

Leave a Comment

Previous post:

Next post: