我应该使用日志文件还是数据库来跟踪印象?
我在 iframe 中有一张图片(类似于广告),该图片将被放置在多个网站中。我应该使用服务器日志文件来找出印象吗?或者我应该使用数据库来跟踪每次印象?
哪种方式速度更快并且可以处理大流量?谢谢
I have a picture (similar to an ad) in an iframe that will be placed in multiple sites. Should I use the server log file to find out the impression? or should I use DB to keep track of each impression?
which way is faster and can handle large volume of traffic? thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这个问题的答案实际上取决于您使用的数据库类型,以及您的部署环境中 Web 服务器磁盘和数据库的实际繁忙程度;
如果您有一个常规网站,您可以可能会采用第一种方法,因为它很简单。如果没有,那么您还没有在上面花费很多时间。
The answer for this question really depends on what kind of database you are using, and how busy the web servers disk and the database really are in your deployment environment;
If you have a regular website you can probably get away with doing it the first way as it is simple. If it does not, you haven't spent a lot of time on it.
对我来说听起来很合理。使用日志的简单方法可以是使用 grep 从日志中查找正确的调用并对其进行计数。
正如 Knubo 所说,压缩已经处理过的条目是有意义的,因为每小时 1000 万+,您可能会看到相当多的日志文件:) 因此,例如每天执行一个过程:
Sounds reasonable to me. The simple way with logs could be e.g. to use grep to find the correct calls from the log and count them.
As Knubo said, compressing entries that have already been processed makes sense, as with 10M+/hour you could be looking at quite a log-file :) So e.g. daily do a process which: