简体   繁体   English

在MongoDB中存储点击数据

[英]Storing Click Data in MongoDB

My application tracks clicks from adverts shown on remote sites, and redirects users to a product sales page. 我的应用程序跟踪来自远程站点上显示的广告的点击,并将用户重定向到产品销售页面。

I'm currently using MySQL to store click information (date, which link was used, ip address, custom data sent from the advertiser etc). 我目前正在使用MySQL存储点击信息(日期,使用的链接,IP地址,从广告商发送的自定义数据等)。 The table is getting so big that it no longer fits our needs, which are: 该表太大了,以致不能满足我们的需求,这些需求是:

  • High throughput (the app is processing 5 - 10M clicks per day and this is projected to grow) 高吞吐量(该应用每天处理5-10M次点击,并且预计还会增长)

  • Ability to report on the data by date range (eg how many clicks for link 1 over the past month grouped by country) 能够按日期范围报告数据(例如,过去1个月中按国家/地区分组的链接1的点击次数)

My initial idea was to move clicks into Redis (we only need to store them for 30 days, at which point they expire if they don't lead to a sale) and then make a new MySQL table to store generated stats by day, where we just update a counter per link when it's clicked. 我最初的想法是将点击次数移入Redis(我们只需要将它们存储30天,如果它们不会带来销售,它们就会过期),然后制作一个新的MySQL表来按日存储生成的统计信息,单击链接后,我们只会更新每个链接的计数器。

When we started using the statistics table the database quickly fell over because of the amount of queries to that table. 当我们开始使用统计表时,由于对该表的查询量很大,数据库很快就崩溃了。

Would it be best to keep the clicks in Redis, and have a separate MongoDB (or other noSQL DB) for the reporting? 最好将点击次数保留在Redis中,并为报告创建单独的MongoDB(或其他noSQL DB)吗? or could Mongo be used to store the whole click (just like we've been doing in MySQL) or is the volume too high? 还是可以使用Mongo来存储整个点击次数(就像我们在MySQL中所做的一样),还是音量太高?

Also I remember reading that MongoDB is not good at reclaiming space from deleted records, would this cause us issues since 90% of the clicks would be deleted after 30 days anyway? 我也记得读过MongoDB不能从已删除的记录中回收空间,这会给我们造成问题,因为90%的点击会在30天后被删除吗?

Thanks 谢谢

MongoDB is enough to solve this problem as compared to store in Radis and move to MongoDB. 与存储在Radis中并迁移到MongoDB相比,MongoDB足以解决此问题。 Since, the amount of data is very large, so you can create a indexes on timestamp or field having high carnality. 由于数据量非常大,因此您可以在时间戳或具有高破坏性的字段上创建索引。 This make you query fast, also MongoDB provide aggregation which help in generating the report. 这使您可以快速查询,而且MongoDB还提供了聚合,有助于生成报告。 I don't think, is there any issue with deletion. 我不认为删除有任何问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM