questions about running at the rate limit/throttling strategies

16 views
Skip to first unread message

George Ludwig

unread,
May 18, 2011, 6:36:19 PM5/18/11
to jt...@googlegroups.com
Daniel,

I'm working on the best strategy for running at the rate limit. Currently, I've isolated every Twitter call by wrapping access to the Twitter object in a method that supplies the desired number of api calls, and checks the rate limit, i.e.:

public Twitter getTwitter(int callCount) {

throttle(callCount);

return twitter;

}


private void throttle(int callCount) {

if (twitter.isRateLimited(KRequestType.NORMAL, callCount)) {

                      RateLimit rateLimit = twitter.getRateLimit(KRequestType.NORMAL);

                      rateLimit.waitForReset();

                }

}


For simple calls everything is good, however I'm hitting some challenges in working with lists.


To get a list of the people I'm following, I assume something like this is necessary:


followedIdList=getTwitter(1).getFriendIDs();

followedUserList=getTwitter(100).bulkShowById(followedIdList); // 100 is the fetch batch size in Twitter.bulkShow2


If I'm following a lot of people, I may never be able to execute the second call because there doesn't appear to be any rate limit checking in Twitter.bulkShow2. And if it works, I would still be concerned about hard-coding the batch size, since in bulkShow2 it is a private variable that could change without notice.


A couple more examples...the question is, does it only use 1 api call, or is it 1 call + 1 call for every list returned:

myLists=getTwitter(1).getLists(); 

otherListsContainingMe=getTwitter(1).getListsContainingMe();

myListsContainingUser =getTwitter(1).getListsContaining(user.getScreenName(), true);


If I am unable to predict the number of api calls required, I have no idea how to rate limit properly!


Best,


George

Reply all
Reply to author
Forward
0 new messages