tideaways可视化性能跟踪

安装 mongodb扩展

pecl install mongodb

[mongodb]
extension=mongodb.so

安装 tideaways扩展

https://github.com/tideways/php-xhprof-extension

git clone

phpize

./configure

make

make install

[tideways]
extension=tideways_xhprof.so
;不需要自动加载,在程序中控制就行
tideways.auto_prepend_library=0
;频率设置为100,在程序调用时能改
tideways.sample_rate=100

重启php

/etc/init.d/php-fpm restart

安装 mongodb

vim /etc/yum.repos.d/mongodb-org-3.2.repo

[mongodb-org-3.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc

yum -y install mongodb-org

/etc/init.d/mongod start

安装 xhgui

git clone https://github.com/laynefyc/xhgui-branch.git

cd xhgui-branch

composer install –prefer-dist

# 配置文件
config/config.default.php

‘extension’ => ‘tideways_xhprof’,

# 入口文件增加时区设置
date_default_timezone_set(“Asia/Shanghai”);

测试 MongoDB连接情况并优化索引

use xhprof

db.results.ensureIndex( { ‘meta.SERVER.REQUEST_TIME’ : -1 } )
db.results.ensureIndex( { ‘profile.main().wt’ : -1 } )
db.results.ensureIndex( { ‘profile.main().mu’ : -1 } )
db.results.ensureIndex( { ‘profile.main().cpu’ : -1 } )
db.results.ensureIndex( { ‘meta.url’ : 1 } )

配置nginx

# UI访问地址
server {
listen 80;
server_name x.fengfeng.com;
root /data/www/xhgui-branch/webroot;

location / {
index index.php;
if (!-e $request_filename) {
rewrite . /index.php last;
}
}

location ~ \.php$ {
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
access_log /data/logs/x.fengfeng.com.log access;
}

# 在 fastcgi_param 中添加 auto_prepend_file
location ~ [^/]\.php(/|$)
{
fastcgi_param PHP_VALUE “auto_prepend_file=/data/www/xhgui-branch/external/header.php”;
}

Charles抓包

Charles作用
Charles 通过将自己设置成系统的网络访问代理服务器,使得所有的网络访问请求都通过它来完成,从而实现了网络封包的截取和分析

Charles主要的功能包括
截取 Http 和 Https 网络封包
支持重发网络请求,方便后端调试
支持修改网络请求参数
支持网络请求的截获并动态修改
支持模拟慢速网络
授权抓取电脑的请求包
Proxy -> Mac OS X Proxy -> 输入电脑密码

默认端口
127.0.0.1:8888

设置浏览器代理(可忽略,一般只抓手机包)
在 Chrome 中设置成使用系统的代理服务器设置即可,或者直接将代理服务器设置成 127.0.0.1:8888 也可达到相同效果

界面视图
Structure 视图将网络请求按访问的域名分类
Sequence 视图将网络请求按访问的时间排序

过滤
Sequence -> Filter
Proxy -> Include -> Add
右键 -> Focus & 勾选 Focused

手机抓包
Proxy -> Proxy Settings -> 勾选 HTTP proxying

手机设置
设置->无线局域网->当前连接WIFI->详情->配置代理->手动
填入电脑的IP和端口

Charles确认
iphone请求连接,Charles点击Allow后即完成设置

https
电脑https
Help -> SSL Proxying -> Install Charles Root Certificate
选中请求地址 -> 右键 -> Enable SSL Proxying
钥匙串 -> 系统 -> 将证书设置为始终信任

手机https
Help -> SSL Proxying -> Install Charles Root Certificate On Mobile Device or Remote Browser
手机打开安装证书地址 -> http://charlesproxy.com/getssl -> 安装
设置 -> 通用 -> 描述文件能查看证书 设置 -> 通用 -> 关于本机 -> 证书信任设置 -> 完全信任

模拟慢网络
Proxy -> Throttle Setting -> Enable Throttling

模拟并发
右键 -> Repeat Advanced

修改网络请求内容
右键 -> Breakpoints
右键 -> Repeat 重新发起请求 -> Edit Request -> 修改参数 -> Execute

参考
https://blog.csdn.net/lmmilove/article/details/50244537

gdb简单使用

 

 

 

Wireshark简单了解

Wireshark(前称Ethereal)是一个网络数据包分析软件。网络数据包分析软件的功能是截取网络数据包,并尽可能显示出最为详细的网络数据包数据。Wireshark使用WinPCAP作为接口,直接与网卡进行数据报文交换。可以直接双击打开tcpdump保存的.pcap文件

常用功能键,以及IO图功能,见下图:

3

抓包设置和预设过滤条件等,见下图:

wireshark

过滤条件表达式设置,当然也可以不通过Expression选项直接在左边文本框输入,如下图:

w2

tcpdump简单了解

 

strace简单了解