ab 带参数测试

ab -r -n200 -c50 -H “Cookie: _lc=0f5934d347f4ab60ee898ca57a900b83$$3$$1509857368$$81bfb8c4958f8b4559822101651f782a03cf8499;” “http://api-test1.staging.tengyue360.com/api/common/homedata/v2?app_version=47&app_version_name=2.9.0&_exps={%22EXP_RECOMMENDATION_V2%22:%22es_control%22,%22EXP_HOME_CATEGORY_CONTENT%22:%22function%22}&device_id=10710446-e37c-3703-b1cc-21c69b5208d8&device_type=3&device_model=HUAWEI%20NXT-TL00&platform=3&os_version=7.0&app_id=1&app_version=53&app_version_name=2.9.0&screen_width=1080&screen_height=1812&screen_dpi=480&token=d7a30404716478496603b0f594f1beaa&_exps={%22EXP_RECOMMENDATION_V2%22:%22es_control%22,%22EXP_HOME_CATEGORY_CONTENT%22:%22function%22}”

发表在 漏洞 | 留下评论

查看linux上的zombie进程

ps -A -o stat,ppid,pid,cmd |grep -e “^[Zz]”

貌似kill不管用,只能是重启系统才行

发表在 运维 | 留下评论

php-fpm慢查询日志

线上有很长一段时间经常出现nginx 504超时的错误,但是线下测试一直不能复现这个问题,困扰很久,主要是不能定位到php脚本到底慢在了哪一步,后来发现了下面这个方法,可以帮助定位慢的原因:

以下其实是php-fpm的配置:

slowlog = /home/$pool/logs/php/fpm.slow.log
request_slowlog_timeout = 5s

发表在 php异常 | 留下评论

一些不错的网站,可以用来自己参考

商城类

https://www.mankind.co.uk/accountHome.account

https://www.lookfantastic.cn/accountHome.account

发表在 产品 | 留下评论

Mysql生成随机串

select substring(MD5(RAND()),1,20)

发表在 mysql | 留下评论

vim将一列数据复制到文件另一列

有两个文件:file1、file2

wenzg@localhost:~/Downloads/Chrome$ cat ~/Downloads/Chrome/file2
title1
title2
title3
title4

wenzg@localhost:~/Downloads/Chrome$ cat ~/Downloads/Chrome/file1
1,desc1
2,desc2
3,desc3
4,desc4

现在向将file2中的内容对应放到file1中的第二列,即对应数字后面,比如

1,title1,desc1
2,title2,desc2
3,title3,desc3
4,title4,desc4

方法1:(这种方式很快,但是只适用字符长度相同的,或者将要插入的列在首或尾的)
1、vim -O ~/Downloads/Chrome/file1 ~/Downloads/Chrome/file2
2、将光标移动到file2中的title1的t,然后ctrl+v,然后shift+v,向右拖拉,全部选中后,y复制
3、将光标移动到file1中的1,desc1中的,然后按ctrl+v,shift+v左右只选中“,”这一列,然后shift+a,输入“,”,再按esc,可以看到所有行都插入成功,然后光标移动到1,desc1中的,直接按p,这贴成功

方法2:
export no=0; while read line; do no=`expr $no + 1`; arr1[$no]=$line; done < ~/Downloads/Chrome/file1; no=0; while read title; do no=`expr $no + 1`; if [ -z ${arr1[$no]} ];then str=’null’; else str=${arr1[$no]}; fi; id=`echo $str |cut -d”,” -f1`; desc=`echo $str |cut -d”,” -f2`; echo $id”,”$title”,”$desc; done < ~/Downloads/Chrome/file2;

发表在 vim | 留下评论

接口返回内容过大,导致内容被截断

https://segmentfault.com/a/1190000007513677

发表在 nginx | 留下评论

apr_socket_recv: Connection reset by peer (104)

ab压力测试报错

Benchmarking 10.88.88.190 (be patient)
apr_socket_recv: Connection reset by peer (104)
Total of 1 requests completed

解决办法:
加个 -r 参数

#ab压力测试 900个并发 2000次请求 (本地)
ab -r -n2000 -c500 http://10.88.88.190:8888/test/array_sort.php

发表在 nginx | 留下评论

mysql update 另外一个表的结果

update orders a,(select max(id) id from orders) b set a.status = 3 where a.id = b.id;

发表在 mysql | 留下评论

多维度数组排序思路

/**
* Filename: array_sort.php.
* User: George
* Date: 2017/11/10
* Time: 下午3:42
*/

$arr1 = array (
0 => ’1_93′,
1 => ’2_46′,
2 => ’1_151′,
);

$arr2 = array (
0 =>
array (
‘document_id’ => ’93′,
‘id’ => ‘b2e62e0214684938fe6ee9827ccdc649′,
‘title’ => ‘添加文章1′,
‘tags’ => ’10,75′,
‘score’ => 1001,
‘description’ => ‘添加文章’,
‘cover_pic_url’ => ‘http://bootfirst-oss02.img-cn-beijing.aliyuncs.com/tmp_cover_pics/73/53/5d/f3/73535df3b7200dddb17fd399ea01da3e.jpg’,
‘price’ => 0,
‘level’ => 0,
‘type’ => 1,
‘url’ => ‘http://m-shiting.office.tengyue360.com/content/document/article?id=b2e62e0214684938fe6ee9827ccdc649′,
‘is_series’ => false,
‘create_ts’ => 1468576809,
‘is_new’ => false,
‘view_count’ => 2644,
‘share_count’ => 0,
‘fav_count’ => 1,
‘comment_count’ => 97,
‘recommend_type’ => ‘manual’,
‘unique_key’ => ’1_93′,
‘unique_id’ => ’112′,
‘ordinal’ => ’201711102′,
),
1 =>
array (
‘document_id’ => ’151′,
‘id’ => ’1cb1e65e8cf5e1a8537a1750c4cdb223′,
‘title’ => ‘实战经验 培训机构新老师培养秘籍’,
‘tags’ => ’3,9,10,11,12,109,18,122,38′,
‘score’ => 100,
‘description’ => ‘各位校长大家好,我是腾飞教育英语教研组长卢宇徽。今天和大家分享的主题是“新老师的培养”。’,
‘cover_pic_url’ => ”,
‘price’ => 0,
‘level’ => 0,
‘type’ => 1,
‘url’ => ‘http://m-shiting.office.tengyue360.com/content/document/article?id=1cb1e65e8cf5e1a8537a1750c4cdb223′,
‘is_series’ => true,
‘create_ts’ => 1468916705,
‘is_new’ => false,
‘view_count’ => 623,
‘share_count’ => 4,
‘fav_count’ => 6,
‘comment_count’ => 14,
‘recommend_type’ => ‘manual’,
‘unique_key’ => ’1_151′,
‘unique_id’ => ’88′,
‘ordinal’ => ’0′,
),
2 =>
array (
‘id’ => ‘b88541b279e17c24f4d6eb03512a40aa’,
‘title’ => ’11′,
‘author_name’ => ’1′,
‘author_title’ => ’1′,
‘author_photo’ => ‘http://bootfirst-oss02.img-cn-beijing.aliyuncs.com/dailyaudio_author_photo/a9/96/87/7e/a996877e252644424015eec4c9ade991.jpg’,
‘duration’ => 1,
‘outer_url’ => ‘http://bootfirst-oss02.oss-cn-beijing.aliyuncs.com/dailyaudio/bb99d7a81e665b089f926f517c0dcbe2.jpg’,
‘content_url’ => ‘http://m-shiting.office.tengyue360.com/content/document/dailyaudiocontent?id=b88541b279e17c24f4d6eb03512a40aa’,
‘view_count’ => 15,
‘fav_count’ => 0,
‘share_count’ => 0,
‘publish_ts’ => 1501948800,
‘unique_key’ => ’2_46′,
‘type’ => 4,
‘unique_id’ => ’89′,
‘ordinal’ => ’0′,
‘cover_pic_url’ => ‘http://bootfirst-oss02.oss-cn-beijing.aliyuncs.com/dailyaudio/bb99d7a81e665b089f926f517c0dcbe2.jpg’,
‘url’ => ‘http://m-shiting.office.tengyue360.com/content/document/dailyaudiocontent?id=b88541b279e17c24f4d6eb03512a40aa’,
),
);

usort($arr2, function($a, $b) use ($arr1) {
$pos_a = array_search($a['unique_key'], $arr1);
$pos_b = array_search($b['unique_key'], $arr1);
if($pos_a == $pos_b) {
return 0;
}
return ($pos_a < $pos_b) ? -1 : 1;
});

print_r($arr2);

发表在 涨姿势 | 留下评论