开发者

Is facebook faster or local database?

In my facebook application, I use p开发者_StackOverflow中文版eoples friends names in the application. I can either get the names from facebook. Or save them the first time the person logs in. So everytime his/her friends received from the database.

Which method is faster?


Storing the friends names in the database will almost certainly be faster - Facebook's API is not particularly fast, and since the query needs to go across the internet there's added latency.

However, storying the friends names retrieve directly from the API on first use for more than 24 hours as in breach of the developers terms of service. So you should expect to have to query the API regularly, either on every view of the page or else implement a more complex data caching system of your own.


As a rule local Db connections are usualy much faster to access than webservice calls. I would suggest you setup both options and record some time metrics to test this, but keep in mind the response of Facebook is also going to change at diffent times of the day under different loads.

Dont forget the friends list are always changing too, I would suggest you fetch the list in the background on every login to update your database copy too.


Obviously pulling the names from your local database would be faster.

But that doesn't matter. Being out of sync with facebook is the overriding concern.

Let's say they use the facebook site to remove a friend. Will they then have to click a "sync" button in your app to remove them as well? So my recommendation is not to worry about performance and always get the latest from facebook.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜