oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

A Briefing on Syncing
Pages: 1, 2, 3

The Process

The dance for these three participants involves four steps, which always take place in the same order:

  1. Negotiating: In this first step, a client requests that the engine set up a syncing session between them; the request includes the kind of sync that needs to take place—see "Types of sync sessions,"
    on the next page.

  2. Pushing: Next, the client sends whatever new or changed information it has accrued to the sync engine.

  3. Mingling: The sync engine consults the truth database, inserting new data, marking outdated data, and noting any conflicts that might arise between the pushed information and the truth database's contents. The engine tries to resolve conflicts but might also instruct the client to ask the user (that's you) to resolve them.

  4. Pulling: Finally, the client receives the changes—what's new, what's modified, what's deleted—from the sync engine. The client reformats the information it receives if necessary and records it in the appropriate place, like the Mac's Address Book, or a connected PDA's contact list.

Note: Although the syncing process has four steps that occur in the order given, not all of the steps must be performed in any session. For example, a client can negotiate a session, push nothing, and then pull updates, or it can push updates but pull nothing.

Types of Sync Sessions

A sync session takes place either automatically (usually because you have established a schedule) or manually (usually because you specifically requested it or because you connected a device to your Mac that triggers a sync). Sync sessions can take any of the following forms:

  • Slow sync: This sync usually happens the first time a client syncs. The client pushes all of its information to the engine, waits while the engine integrates that information with the truth database, and then pulls the changes that the sync engine has decided need to be pulled. While this is happening, the sync engine also builds a snapshot of the client's current state, so the next sync doesn't take nearly as long.

  • Fast sync: If the truth database contains a valid snapshot of the client, the client and the sync engine can use a fast sync, in which the client pushes and pulls only changed information. Most sync sessions are fast syncs.

  • Refresh sync: Sometimes a device, such as a mobile phone, or an application, such as Safari, gets reset, and all the shared data on it goes to the land of lost data. When that happens, the client requests a refresh sync, in which the client pushes nothing and pulls everything the sync engine has to offer. iSync, for example, provides an option you can use to reset one or more connected devices, which initiates a refresh sync for them; see Sync a Handheld Device with iSync in the full e-book. In a refresh sync, the sync engine also deletes the old client snapshot and creates a new one. Refresh syncs usually take about the same amount of time as the initial slow sync.

  • Push the truth: This kind of sync happens when a client, for whatever reason, instructs the sync engine to replace all of the data in the truth database with its own collection. This can occur, for example, when you replace the truth database on your .Mac account with the one on your Mac, as described in the full e-book in Sync Another Mac with .Mac.

  • Pull the truth: As you might expect, in this type of sync session, the sync engine instructs the client to replace its information with the information contained in the truth database. The sync engine may force clients to pull the truth if they share information with a client that has just pushed the truth, in order to get everyone on the same page.

  • Trickle sync: This is a fast sync that happens frequently and automatically, in which clients dependent on each other's data quickly compare notes and make appropriate changes via the sync engine. If you've ever noticed iTunes unexpectedly announce that it was updating your iPod, you've seen a trickle sync in action.

Note: The sync engine, not the client, decides what type of sync session takes place: the engine may perform the type of sync session requested by the client, but it doesn't have to. The sync engine must evaluate the state of all of the clients involved and the state of the truth database when establishing a sync session. Don't be surprised, therefore, when a sync sometimes seems to take much more—or less—time than a seemingly similar sync has previously taken.

The Elements of Syncing

When you look at the stuff on your Mac that you might be interested in syncing, it typically breaks down into two forms:

  • Structured information: This comprises various bits and pieces of information managed by programs on your Macintosh like Address Book, or by the built-in functions on your portable device like a mobile phone's contact list. This information may be stored as part of a single file, or it may be spread out among several files, or, on some handheld devices, it may not even be stored in something called a "file" at all. How and where it's stored doesn't matter, though: when you sync it, you're usually not interested in copying the container that holds the structured information but only in those pieces of information that have changed, no matter where or how they happen to be stored on the device.

  • Files: You know what these are—you've been opening, copying, and dragging files around ever since you started using a Mac. When you sync a file among devices, you want to be sure that every device you sync with ends up with the most recent version of the file.

Syncing whole files and syncing chunks of structured information require different syncing approaches—Choose How to Sync, in the full e-book, provides a summary of the applications you'll use for these two intrinsically different kinds of syncing.

Pages: 1, 2, 3

Next Pagearrow