Live data from Hacker News

How F5Bot Slurps All of Reddit

intoli.com

41–50 of 91 posts

Re: How F5Bot Slurps All of Reddit

#41

This is mostly why I left Reddit. The API allows far too much control and I started questioning what was even real. Being able to quickly find keywords and then have a network of bots that creates replies/upvotes/downvotes is very disturbing thought to me. I can't even imagine something like that on a large scale to change opinions.

The API is a reason why I _love_ Reddit. Being able to moderate my communities tools I can write has been a savior more times than I can count.

Re: How F5Bot Slurps All of Reddit

#42
> So here’s the approach I ended up using, which worked much better: request each post by its ID. That’s right, instead of asking for posts in batches of 100, we’re going to need to ask for each post individually by its post ID. We’ll do the same for comments.

Seems a bit over the top imho. Maybe a better approach is to ask for a 1,000 and look for any missing — which you can grab individually.

I’d be a little annoyed at people not using batch mode and making so many request but that’s just me.

Re: How F5Bot Slurps All of Reddit

#43
post #29

> The other 95% of it is just wasted bandwidth. You can save a lot of bandwith by requesting compressed responses: $ curl -s --user-agent moo/1 -H 'Accept-Encoding: gzip' "$pretty_long_url" > test.gz $ wc -c (OK, that's 85% saved, not 95%, but hey.)

Trading cpu for bandwidth, so optimize for what you want.

Re: How F5Bot Slurps All of Reddit

#44

> So here’s the approach I ended up using, which worked much better: request each post by its ID. That’s right, instead of asking for posts in batches of 100, we’re going to need to ask for each post individually by its post ID. We’ll do the same for comments. Seems a bit over the top imho. Maybe a better approach is to ask for a 1,000 and look for any missing — which you can grab individually. I’d be a little annoye…

Each request still returns 100 posts. It's just that you have to specify the 100 post IDs individually.

Their default listing mode works very poorly. It would certainly be more requests to use a hybrid system like you're talking about.

Re: How F5Bot Slurps All of Reddit

#45
post #37
post #6

It is difficult for me to describe just how angry it makes me that reddit doesn't provide a way for users to even do basic things like "see all of my own comments" or "see all of the posts made to the subreddit I moderate". They keep nerfing the search APIs and claim it is so they could make the indexes more efficient, but while that might make sense for a full-text search interface, that is entirely unreasonable for…

(I worked at reddit) It's not really related to search, most of the cause is a pretty bizarre optimization method that reddit decided to implement fairly early on. The database structure is unusual and not very conducive to indexing (it's similar to an EAV model), so at some point they decided to basically write their own "secondary indexing"-like system that stores the "listing indexes" in memcached/Cassandra (with…

Thanks for the explanation. The APIs make a lot more sense in light of it. It seems odd they didn't just use Postgres indexing though. Do you know if they benchmarked it at any point?

Re: How F5Bot Slurps All of Reddit

#46
post #37

Earlier quoted context omitted.

(I worked at reddit) It's not really related to search, most of the cause is a pretty bizarre optimization method that reddit decided to implement fairly early on. The database structure is unusual and not very conducive to indexing (it's similar to an EAV model), so at some point they decided to basically write their own "secondary indexing"-like system that stores the "listing indexes" in memcached/Cassandra (with…

Thanks for the explanation. The APIs make a lot more sense in light of it. It seems odd they didn't just use Postgres indexing though. Do you know if they benchmarked it at any point?

I have no idea, this system was created years before I started working there.

Re: How F5Bot Slurps All of Reddit

#47
post #27

Aho-Corasick is really great. It’s a bit complicated to set up, but once you have the modified true set up it’s really fast. By the way, > Basically I use the selftext, subreddit, permalink, url and title. The other 95% of it is just wasted bandwidth. It’d probably be better for Reddit if they allowed for specifying the fields we care about rather than just returning the whole thing…

I only took a quick skim, but it doesn't look like they do the optimization to aho-corasick where you store connections directly to "leaf" nodes (ie: nodes where you can have a finished match). If I'm right, that would probably speed things up significantly.

Sorry, what optimization are you talking about? If you're just path compression, then I don't think this works because you miss out on generating failure links as you go along.

Re: How F5Bot Slurps All of Reddit

#48
post #37

Earlier quoted context omitted.

(I worked at reddit) It's not really related to search, most of the cause is a pretty bizarre optimization method that reddit decided to implement fairly early on. The database structure is unusual and not very conducive to indexing (it's similar to an EAV model), so at some point they decided to basically write their own "secondary indexing"-like system that stores the "listing indexes" in memcached/Cassandra (with…

Thanks for the explanation. The APIs make a lot more sense in light of it. It seems odd they didn't just use Postgres indexing though. Do you know if they benchmarked it at any point?

For a lot of queries EAV type schemas are really hard to index efficiently. E.g. searching for something like a = ? and b = ? where a and b are dynamic attributes you can't just have a multi-column index when using EAV. So you instead end up with two intermediate query results that then are intersected. If you need even semi-efficient querying EAV usually isn't the answer.

Re: How F5Bot Slurps All of Reddit

#49
post #29

> The other 95% of it is just wasted bandwidth. You can save a lot of bandwith by requesting compressed responses: $ curl -s --user-agent moo/1 -H 'Accept-Encoding: gzip' "$pretty_long_url" > test.gz $ wc -c (OK, that's 85% saved, not 95%, but hey.)

Trading cpu for bandwidth, so optimize for what you want.

Decompression is usually cheaper (CPU-wise) than compression so technically you’re trading their CPU for less of your bandwidth and CPU.

If you do it right you can even keep the content stored compressed without re-compressing by saving the compressed byte stream directly.

Re: How F5Bot Slurps All of Reddit

#50
post #25
post #14

> I mean do you really want subreddit name and subreddit_name_prefixed? They’re the same, one just has an “r/” in front of it. This is (unfortunately) not quite true. Since Reddit introduced "profile posts," there can be a post where the subreddit name is something like "u_Shitty_Watercolour" but the subreddit_name_prefixed is actually "u/Shitty_Watercolour", rather than "r/u_Shitty_Watercolour". Example: https://www…

I'm not sure that's true. I think they both work, see: https://www.reddit.com/r/u_Shitty_Watercolour/ Maybe one is just an alias though? I wonder if you can make a r/u_$unused_username and then later register $unused_username edit: nope, you can't make a sub that starts with "u_"

Users can post to their own profile subreddit, or any of the other subreddits that they have permission to post to. That's relatively new, and came with the new profiles and part of the redesign. Both are needed, information could be missed.
Post reply on HN