跟踪每个网页的展示次数/访问次数

发布于 2024-09-04 09:00:57 字数 313 浏览 8 评论 0原文

我有一个网站,每个公司都有多个页面,我想展示他们的页面在访问此个人资料的人数方面的表现。

我们已经确保排除机器人。

目前,我们通过插入(针对一天中对配置文件的第一个请求)或更新(针对一天中对配置文件的后续请求)记录数据库中的每次点击。但是,鉴于请求已从每天数千个增加到每天数万个,这些插入/更新正在导致重大性能问题。

假设没有 JS 解决方案,处理这个问题的最佳方法是什么?

我使用 Ruby on Rails、MySQL、Memcache、Apache、HaProxy 来运行整体展示。

任何帮助将不胜感激。

谢谢

I have a site with several pages for each company and I want to show how their page is performing in terms of number of people coming to this profile.

We have already made sure that bots are excluded.

Currently, we are recording each hit in a DB with either insert (for the first request in a day to a profile) or update (for the following requests in a day to a profile). But, given that requests have gone from few thousands per days to tens of thousands per day, these inserts/updates are causing major performance issues.

Assuming no JS solution, what will be the best way to handle this?

I am using Ruby on Rails, MySQL, Memcache, Apache, HaProxy for running overall show.

Any help will be much appreciated.

Thx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

停顿的约定 2024-09-11 09:00:57

http://www.scribd.com/doc/ 49575/Scaling-Rails-Presentation-From-Scribd-Launch
您应该从幻灯片 17 开始阅读。
我认为如果可以为像 scribd 这样大的网站构建这样的解决方案,那么性能不是问题。

http://www.scribd.com/doc/49575/Scaling-Rails-Presentation-From-Scribd-Launch
you should start reading from slide 17.
i think the performance isnt a problem, if it's possible to build solution like this for website as big as scribd.

z祗昰~ 2024-09-11 09:00:57

这里有 4 种方法可以解决这个问题,从简单的估计到复杂而准确的估计:

  1. 仅跟踪一定比例(10% 或 1%)的用户,然后相乘以获得计数估计值。
  2. 在对给定页面进行前 50 次计数后,开始将计数时间的 1/13 更新为计数 13。如果有几个页面执行多次计数,同时保持小计数的准确性,这会有所帮助。 (使用 13 因为很难注意到 incr 不是 1)。
  3. 将精确计数保存在缓存层(例如 memcache 或本地服务器内存)中,并在计数达到 10 次或在缓存中保存一定时间时将其全部保存到磁盘。
  4. 构建一个单独的计数层,1)始终在内存中提供当前计数,2)将计数保留到它自己的表/数据库,3)具有调整两个位置的调用

Here are 4 ways to address this, from easy estimates to complex and accurate:

  1. Track only a percentage (10% or 1%) of users, then multiply to get an estimate of the count.
  2. After the first 50 counts for a given page, start updating the count 1/13th of the time by a count of 13. This helps if it's a few page doing many counts while keeping small counts accurate. (use 13 as it's hard to notice that the incr isn't 1).
  3. Save exact counts in a cache layer like memcache or local server memory and save them all to disk when they hit 10 counts or have been in the cache for a certain amount of time.
  4. Build a separate counting layer that 1) always has the current count available in memory, 2) persists the count to it's own tables/database, 3) has calls that adjust both places
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文