Live data from Hacker News

View Counting at Reddit

redditblog.com

51–60 of 121 posts

Re: View Counting at Reddit

#51

Wouldn't it had been easier to simply increment a counter for each visit and then set a short lived cookie in the browser for that post? And put the spam detection system before the counter increment

A browser cookie that can be trivially deleted by the client? What's the purpose of the cookie?

Re: View Counting at Reddit

#52
post #48

So how do they determine whether a user has viewed a post already? I would think that unique counting is accomplished using the hyperloglog counter, but the article says that this decision is made by the Nazar system, which doesn't use the hyperloglog counter in Redis.

Thats true, I am thinking that Nazar is more like spam filter and monitors the user behavior.

Re: View Counting at Reddit

#53
post #5

Weird thing I have been seeing on Reddit is comment upvotes being off-by-one periodically on page refreshes. Reload, you get 3. Reload again, you get 4. Again, you get 3. Seems like a replication issue?

I believe they are using cassandra to store the upvotes

That one is in postgres

Re: View Counting at Reddit

#54
post #48

So how do they determine whether a user has viewed a post already? I would think that unique counting is accomplished using the hyperloglog counter, but the article says that this decision is made by the Nazar system, which doesn't use the hyperloglog counter in Redis.

Bloom Filters? It has false positives but no false negatives

Re: View Counting at Reddit

#55

Earlier quoted context omitted.

You are correct, but HyperLogLog has many buckets counting the longest run of zeros in order to avoid the problem of outliers. I recently studied these probabilistic algorithms and did a notebook with code and plots to show their performance: https://github.com/lucasschmidtc/Probabilistic-Algorithms/bl...

Thanks for sharing that! Just skimmed through it and seems pretty interesting. I'll read it more in depth later.

No problem. If there are mistakes or a segment is not clear, let me know

Re: View Counting at Reddit

#56
post #35

Earlier quoted context omitted.

How about, here and on reddit, being able to mark threads you're interested in, and having a page where you can see those sorted by last reply. On HN, make that page refresh every 15 or 60 minutes or whatever. Heck, once every 24 hours would be enough... sometimes I just want to talk about the things that interest me, with the people that are interested in them. I would love to be able to think on something for a few…

Actually, reddit has that. You can save threads or comments, and sort by latest.

And with reddit gold you can even have it hilight all new replies regardless of sort order. This can be really useful for viewing older discussions and see what's been added.

Re: View Counting at Reddit

#57

Earlier quoted context omitted.

How do you concurrently update a counter?

Redis writes are atomic - you just use the increment function

Writes are atomic in redis because redis is single threaded. So you are bounded by how fast redis can write. If you try to write any faster then redis can handle you'll get queueing or errors.

Re: View Counting at Reddit

#58

Earlier quoted context omitted.

Redis writes are atomic - you just use the increment function

Writes are atomic in redis because redis is single threaded. So you are bounded by how fast redis can write. If you try to write any faster then redis can handle you'll get queueing or errors.

Run enough redis servers to handle the load. Choose a server by hashing a user id. Total = sum of counts from all servers.

Re: View Counting at Reddit

#59
post #9

I love the article on hyperloglog! It is really quite good to read even if you're not interested in algorithms. I always liked number theory and I think that it's very interesting that you can guess how many uniques there are by counting how long your longest run of zeroes in a hash is. I suppose this could be broken by injecting in a unique visitor id that would hash to something with an absurd amount of zeroes? Tha…

You are correct, but HyperLogLog has many buckets counting the longest run of zeros in order to avoid the problem of outliers. I recently studied these probabilistic algorithms and did a notebook with code and plots to show their performance: https://github.com/lucasschmidtc/Probabilistic-Algorithms/bl...

Thanks for sharing guy! Interesting repo.

Re: View Counting at Reddit

#60
post #42
post #30

Forgive my ignorance, but isn't this what Google Analytics is for?

Google Analytics is not accurate (its sampled), or realtime (48 hour turn around).

^ For big sites like reddit, which is why you don't typically run into this when using GA on your personal blog
Post reply on HN