关于pv的那些事!!
遗留问题:whid=1969的日志记录是什么意思?
网站站点信息未分配的时候,会用1969去代替站点信息。
PV:页面浏览量(page view),用户每次打开或刷新一次网页即被计算一次.
关于pv的计算,我们首先考虑下最简单的情况:计算易迅网每天的的pv,这个pv不分站点和渠道.
我们打开跳板机,进入75机器的shell目录.
打开shell目录里的siteKeyData_AllSite.sh,开始研究这个文件.
我们注意到这个脚本文件里,有一个getPV函数,我们来看下这个函数.
pv计算规则:
①页面跳转,并且当前页面id合法;
②网站端的,不计无线;
③IFrame内嵌页卡不计入PV;
④外部投放的页卡不计入PV;
⑤符合以上4点的就算做一条pv,pv数加1.
我们根据以上5点,写一个测试脚本vic_AllSite_pv.sh.算一下20140909号的的一天的易迅网的pv量.
#!/bin/bash ## file name: vic_AllSite_pv.sh ## example: ./vic_AllSite_pv.sh #获取当前脚本所在路径
currdir=$(cd "$(dirname "$")"; pwd) #进入脚本所在目录
cd $currdir ## PHP path
PHP_BIN="/usr/local/php/bin/php" ## 显示脚本的正确用法
function showUsage()
{
echo "Usage: sh vic_AllSite_pv.sh [log_file_time]" >&
exit ;
} ## 如果参数为0,则显示该脚本的用法
if [ $# = ]; then
showUsage
fi ## 变量初始化
start_time=`date "+%Y-%m-%d %H:%M:%S.%N"`
if [ $# = ]; then
log_file_time=$
fi ## 处理结果的存储文件名
result_pv_filename="../data_today/""vic_ALLSITE_PV""_""$log_file_time" ## site_key
## warehouseid - 各分站总体数据
## warehouseid_1 - 各分站商品详情页数据 ## get PV
function getPV()
{ log_file_time=$
log_filename="row_data_"$
log_filename=$log_filename"*" awk -v fdate=$log_file_time -v ftype=$period_type -F"\t" '{
## 不是页面跳转或者当前页面id不合法的请求,过滤掉
if($ != || int($) < ) next; ## 不计无线
wh_id = int($);
## if ( (wh_id == ) || (wh_id == ) || (wh_id == ) || (wh_id == ) ) next;
if ( (wh_id != ) &&
(wh_id != ) &&
(wh_id != ) &&
(wh_id != ) &&
(wh_id != ) &&
(wh_id != ) &&
(wh_id != ) ) next; ## IFrame内嵌页卡不计入PV
if( (int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ) next; ## 外部投放的页卡不计入PV
if( == $ && !match($, /buy\.(51buy|yixun)\.com/)) next; if((int($) % == ) || match($, /item\.(51buy|yixun)\.com/)) {
pvArr["0_1"] = pvArr["0_1"] + ;
} if((int($) == ) || match($, /buy\.(51buy|yixun)\.com\/cart\.html/)) {
pvArr["0_2"] = pvArr["0_2"] + ;
} if((int($) == ) || (int($) == ) || match($, /buy\.(51buy|yixun)\.com\/order.html/)) {
pvArr["0_3"] = pvArr["0_3"] + ;
} ## key: 分站ID
pvArr[""] = pvArr[""] + ;
} END {
for(key in pvArr)
{
print key"\t"pvArr[key] > "../data_today/""ALLSITE_PV_"ftype"_"fdate
}
}' ../data_today/$log_filename
} ## start execute
getPV $log_file_time ## store result to DB
##${PHP_BIN} -c . -f siteKeyDataStore_AllSite.php $result_pv_filename $result_uv_filename $result_btnuv_filename ## process end time
end_time=`date "+%Y-%m-%d %H:%M:%S.%N"` echo -e "ALLSITE_PV_Data:""["",""$log_file_time""]:""$start_time""~""$end_time"
vic_AllSite_pv.sh
计算结果如下:
0 3430852 //全站一天的pv
0_1 1071985 //商品详情页pv
0_2 76135 //购物车pv
0_3 40871 //下单页pv
全站的pv比较好算,那么各分站的pv又该怎么去算呢.
其实有了前面的基础,分站的计算就比较简单了,我们更改一下脚本.
#!/bin/bash ## file name: vic_Sites_pv.sh ## example: ./vic_Sites_pv.sh #获取当前脚本所在路径
currdir=$(cd "$(dirname "$")"; pwd) #进入脚本所在目录
cd $currdir ## PHP path
PHP_BIN="/usr/local/php/bin/php" ## 显示脚本的正确用法
function showUsage()
{
echo "Usage: sh vic_Sites_pv.sh [log_file_time]" >&
exit ;
} ## 如果参数为0,则显示该脚本的用法
if [ $# = ]; then
showUsage
fi ## 变量初始化
start_time=`date "+%Y-%m-%d %H:%M:%S.%N"`
if [ $# = ]; then
log_file_time=$
fi ## 处理结果的存储文件名
result_pv_filename="../data_today/""vic_SITES_PV""_""$log_file_time" ## site_key
## warehouseid - 各分站总体数据
## warehouseid_1 - 各分站商品详情页数据 ## get PV
function getPV()
{ log_file_time=$
log_filename="row_data_"$
log_filename=$log_filename"*" awk -v fdate=$log_file_time -v ftype=$period_type -F"\t" '{
## 不是页面跳转或者当前页面id不合法的请求,过滤掉
if($ != || int($) < ) next; ## 不计无线
wh_id = int($);
## if ( (wh_id == ) || (wh_id == ) || (wh_id == ) || (wh_id == ) ) next;
if ( (wh_id != ) &&
(wh_id != ) &&
(wh_id != ) &&
(wh_id != ) &&
(wh_id != ) &&
(wh_id != ) &&
(wh_id != ) ) next; ## IFrame内嵌页卡不计入PV
if( (int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ) next; ## 外部投放的页卡不计入PV
if( == $ && !match($, /buy\.(51buy|yixun)\.com/)) next; if((int($) % == ) || match($, /item\.(51buy|yixun)\.com/)) {
pvArr[$"_1"] = pvArr[$"_1"] + ;
} if((int($) == ) || match($, /buy\.(51buy|yixun)\.com\/cart\.html/)) {
pvArr[$"_2"] = pvArr[$"_2"] + ;
} if((int($) == ) || (int($) == ) || match($, /buy\.(51buy|yixun)\.com\/order.html/)) {
pvArr[$"_3"] = pvArr[$"_3"] + ;
} ## key: 分站ID
pvArr[$] = pvArr[$] + ;
} END {
for(key in pvArr)
{
print key"\t"pvArr[key] > "../data_today/""SITES_PV_"ftype"_"fdate
}
}' ../data_today/$log_filename
} ## start execute
getPV $log_file_time ## store result to DB
##${PHP_BIN} -c . -f siteKeyDataStore_AllSite.php $result_pv_filename $result_uv_filename $result_btnuv_filename ## process end time
end_time=`date "+%Y-%m-%d %H:%M:%S.%N"` echo -e "SITES_PV_Data:""["",""$log_file_time""]:""$start_time""~""$end_time"
计算结果如下:
2001_3 5789
1_3 16977
4001_1 76058
2001 550962
1969_1 22
4001_2 4795
3001 314763
1969_2 1
4001_3 2252
4001 239516
5001 134831
3001_1 93959
3001_2 6710
1001_1 291933
3001_3 3231
5001_1 40875
1001_2 19668
5001_2 2934
1001_3 11163
5001_3 1459
1969 19877
1 1283055
2001_1 181135
1_1 388003
2001_2 10970
1_2 31057
1001 887848
剩下的就是渠道pv数据的计算了.我们另起一章,详细解说.
关于pv的那些事!!的更多相关文章
- BI任务列表
了解点击流系统和pv/uv的相关计算 关于pv的那些事!! ···············································2014-09-10 homework做了些什 ...
- @ConfigurationProperties 配置详解
文章转自 https://blog.csdn.net/qq_26000415/article/details/78942494 前言新的一年到了,在这里先祝大家新年快乐.我们在上一篇spring bo ...
- 网络服务器搭建的那些事(PV QPS Throughput) 转载
一.前言: 从事后台sever开发的同学,代码开发完成之后,上线之前,总会进行各种黑盒白盒测试,压测.正确性测试... 而测试同学,会给开发同学一份测试报告,需要开发同学进行确认...问题来了,里面好 ...
- Pinterest 架构:两年内月 PV 从零到百亿【翻译】
原文地址 这篇文章,采用 Markdown 方式,写的还是比较实在的,要是有架构图就好了. Pinterest 是图片版的 Twitter,用户把自己感兴趣的东西用图钉(Pins)钉在钉板(PinBo ...
- 从100PV到1亿级PV网站架构演变
如果你对项目管理.系统架构有兴趣,请加微信订阅号"softjg",加入这个PM.架构师的大家庭 一个网站就像一个人,存在一个从小到大的过程.养一个网站和养一个人一样,不同时期需要不 ...
- 两年内从零到每月十亿 PV 的发展来谈 Pinterest 的架构设计(转)
原文:Scaling Pinterest - From 0 To 10s Of Billions Of Page Views A Month In Two Years 译文:两年内从零到每月十亿 PV ...
- [转载]从100PV到1亿级PV网站架构演变
原文地址:http://www.uml.org.cn/zjjs/201307172.asp 一个网站就像一个人,存在一个从小到大的过程.养一个网站和养一个人一样,不同时期需要不同的方法,不同的方法下有 ...
- 关于Redis的那些事
1. MySql+Memcached架构的问题 Memcached采用客户端-服务器的架构,客户端和服务器端的通讯使用自定义的协议标准,只要满足协议格式要求,客户端Library可以用任何语言实现. ...
- Pinterest架构:两年内月PV从零到百亿
Pinterest正经历了指数级曲线般的增长,每隔一个半月就翻番.在这两年里,Pinterest,从 每月PV量0增长到100亿,从两名c创始人和一个工程师成长为四十个工程师,从一台MySQL 服务器 ...
随机推荐
- 安卓天天练练(十五)改造BasicSyncAdapter
谷歌的官方示例BasicSyncAdapter是Android Studio工程, 把它依样画葫芦到Eclipse上,然后改造成我需要的样式. 看官方示例源码的时候,看到EntryListActivi ...
- 如何修改Ubuntu双系统的默认开机启动项
转自:http://jingyan.baidu.com/article/ed15cb1b05d0311be369818a.html 对 于安装Ubuntu系统和windows系统(windows xp ...
- I2C总线之(三)---以C语言理解IIC
为了加深对I2C总线的理解,用C语言模拟IIC总线,边看源代码边读波形: 如下图所示的写操作的时序图: 读时序的理解同理.对于时序不理解的朋友请参考“I2C总线之(二)---时序” 完整的程序如下: ...
- poj3233
这道题其实算是把快速幂的思想用在多项式之中 A+A^2+A^3+…+A^n=(A+A^1…+A^[n/2])+A^[n/2](A+A+A^1…+A^[n/2])+n mod 2*A^n 然后就是打码的 ...
- WordPress Event Easy Calendar插件多个跨站请求伪造漏洞
漏洞名称: WordPress Event Easy Calendar插件多个跨站请求伪造漏洞 CNNVD编号: CNNVD-201309-083 发布时间: 2013-09-11 更新时间: 201 ...
- TFS 2012使用简介(一)
最近,一直想让团队加入敏捷开发,但TFS2010用下来,并不是令人满意,还好,TFS2012横空出世了.相比TFS2010,TFS2012改进太多了,主要体现在以下方面: Team Web Acces ...
- 这次GDC China 2015的总结与关卡设计教程的梳理
去年关卡教程总结链接:听了GDC2014关于关卡设计的讲座的总结与自己的理解 24 号去了GDC china听了讲座,没有听unity没有听VR,听了一天关卡教程,和上次的关卡教程还是有区别的,这次的 ...
- 如何优雅的输出PHP调试信息
经常因为出现紧急bug而被老板骂的同事,为了更快的修复而直接利用线上的错误环境现场debug,并直接在页面上echo和dump.结果被老板发现了,又是一通臭骂.那么有没有什么办法更优雅的输出PHP调试 ...
- UILabel的使用方法
UILabel 就是一个显示文字的控件,可以设置文字的各种属性. 构造方法: //通过设置Label的边框来初始化UILabel labelOfSlider = [[UILabelal ...
- 简单之美 | ZooKeeper应用案例
简单之美 | ZooKeeper应用案例 ZooKeeper应用案例