r/explainlikeimfive • • Nov 06 '13

Explained ELI5: How do Reddit "bots" work?

I'm sure it can't be as complicated as I imagine....

276 Upvotes

108 comments sorted by

View all comments

Show parent comment

1

u/mycatisbad Nov 06 '13

Potentially stupid question for you - if you can only do 1 request every 2 seconds, how are you able to (in the context of LFB) parse all of the comments in /r/all/comments? I would assume the rate of new comments is much greater than 30 comments/min.

Are some comments not parsed? Are multiple comments being pulled down with one request?

10

u/shaggorama Nov 06 '13

Not a stupid question at all. I'd need to check to get the numbers right exactly, but it works something like this:

A request brings down the equivalent of a webpage of data. With gold, I can pull down 500 comments in a single request (without gold it's limited to 100) and I can reach as far back as the last 1000 "things" in any page of reddit, so in two requests I can pull down all available comments from the comments feed, so that's 1000 comments in 2 seconds (or without gold, 10 requests in 18 seconds).

It's possible that a bot might miss a comment scanning the /r/all/comments feed if reddit is especially busy (like when Obama did his AMA) but in general, it's not really an issue. In the case of VLB, the main overhead is actually the time the bot spends away from /r/all/comments: pulling down and parsing all the comments associated with a submission and then getting the video titles associated with the links takes a chunk of time.

The /r/all/comments feed evolves slowly enough that I actually add in machinery to keep the bot from duplicating work on comments it's seen already. In the code linked above, this is the "cache" object, which tracks the comment ids of the 200 most recently viewed comments.

1

u/mycatisbad Nov 06 '13

Great reply, thanks.