Reduce Application Latency with Facebook’s New Batch API

January 23, 2008

Facebook just announced the addition of its batch API into the PHP client library. This addition is intended to combine individual operations into a single request, thereby improving application latency and reducing Facebook server loads.

Previously, a series of requests made via the Facebook client library might have looked something like the following.

$friends = $facebook->api_client->friends_get();
$notifications = $facebook->api_client->notifications_get();

With the introduction of the batch API, this code can be rewritten as the following.

$facebook->api_client->begin_batch();
$friends =& $facebook->api_client->friends_get();
$notifications =& $facebook->api_client->notifications_get();
$facebook->api_client->end_batch();

In addition, Facebook will soon be releasing an update to the JavaScript client library. This update will allow batch operations to be performed with the FB.BatchSequencer object. After passing a collection of batched operations, an execute method can be called within the object that will complete the request.

Full details regarding the batch API can be found at the Using Batch API wiki page.

Share on Facebook      Share This

Comments

Got something to say?





Close
E-mail It