Google perf tools for nginx

注意:本教程仅适用于Linux。

下面为大家介绍google-perftools的安装,并配置Nginx和MySQL支持google-perftools。

首先,介绍如何优化Nginx:

1,首先下载并安装google-perftools:

注意,如果是64位系统:

那么你需要做:
1)先安装libunwind或者2)在configure时添加--enable-frame-pointers.

那么首先说说如何安装libunwind:

复制代码代码如下:

wget http://download.savannah.gnu.org/releases/libunwind/libunwind-0.99.tar.gz
tar zxvf libunwind-0.99.tar.gz
cd libunwind-0.99/
CFLAGS=-fPIC ./configure --prefix=/usr
make CFLAGS=-fPIC
make CFLAGS=-fPIC install

到这里安装libunwind完成.

如果是使用添加--enable-frame-pointers的方式,先不管,咱们往下走.

下载并安装google-perftools:

复制代码代码如下:

wget http://google-perftools.googlecode.com/files/google-perftools-1.7.tar.gz
tar xzvf google-perftools-1.7.tar.gz
cd google-perftools-1.7

然后开始配置:

复制代码代码如下:

./configure --prefix=/usr --enable-frame-pointers

在这里注意这步,如果是32位系统,可以不添加 --enable-frame-pointers,如果是64位系统,并且你之前没有安装libunwind,那么你一定要添加这个:--enable-frame-pointers

编译并安装:

复制代码代码如下:

make
make install

到这里安装google-perftools完成了但未生效,接下来需要使google-perftools生效:

复制代码代码如下:

echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
/sbin/ldconfig

注意,这里的双引号是英文的。

到这里安装google-perftools完成.

为了使Nginx支持google-perftools,需要加上--with-google_perftools_module重新编译Nginx,如果不知道如何安装Nginx,可以从这里查看Nginx安装教程.

例如:

复制代码代码如下:

./configure --user=www --group=www --prefix=/usr/local/nginx \
--with-http_stub_status_module \
--with-http_ssl_module --with-openssl= \
--with-http_addition_module \
--with-zlib= \
--with-google_perftools_module
make
make install

添加Nginx快速重启脚本,请从wpadm.com下载.
到这里安装Nginx完成.

接下来为google-perftools添加线程目录:

复制代码代码如下:

mkdir /tmp/tcmalloc
chmod 0777 /tmp/tcmalloc

修改/usr/local/nginx/conf/ncing.conf
在pid这行的下面添加

复制代码代码如下:

#pid   logs/nginx.pid;
google_perftools_profiles /tmp/tcmalloc;

重新启动nginx:

复制代码代码如下:

service nginx restart

验证是否正在运行:

复制代码代码如下:

[[email protected] ~]# lsof -n | grep tcmalloc
nginx     13101    www   45w      REG                8,1          0    4014748 /tmp/tcmalloc.13101
nginx     13102    www  47w      REG                8,1          0    4014742 /tmp/tcmalloc.13102
nginx     13103    www   49w      REG                8,1          0    4014746 /tmp/tcmalloc.13103
nginx     13105    www   51w      REG                8,1          0    4014745 /tmp/tcmalloc.13105
nginx     13106    www   53w      REG                8,1          0    4014743 /tmp/tcmalloc.13106
nginx     13107    www   55w      REG                8,1          0    4014749 /tmp/tcmalloc.13107
nginx     13108    www   57w      REG                8,1          0    4014754 /tmp/tcmalloc.13108
nginx     13109    www   59w      REG                8,1          0    4014750 /tmp/tcmalloc.13109
nginx     13110    www   61w      REG                8,1          0    4014747 /tmp/tcmalloc.13110
nginx     13111    www   63w      REG                8,1          0    4014755 /tmp/tcmalloc.13111
nginx     13112    www   65w      REG                8,1          0    4014753 /tmp/tcmalloc.13112
nginx     13113    www   67w      REG                8,1          0    4014756 /tmp/tcmalloc.13113
nginx     13114    www  69w      REG                8,1          0    4014757 /tmp/tcmalloc.13114
nginx     13115    www   71w      REG                8,1          0    4014751 /tmp/tcmalloc.13115
nginx     13116    www   73w      REG                8,1          0    4014744 /tmp/tcmalloc.13116
nginx     13117    www   75w      REG                8,1          0    4014752 /tmp/tcmalloc.13117

我的服务器因为有8核,所以开启了8个Nginx线程,每个线程会有一行类似的记录。
至些,nginx下的google-perftools优化安装完成,供朋友们学习参考。

时间: 2024-08-03 10:27:01

Google perf tools for nginx的相关文章

Google PageSpeed Tools 性能测试分析

今天给大家介绍下一个工具:Google PageSpeed Tools,根据官方的介绍,简单梳理如下: Page Speed Insights能针对移动设备和电脑设备衡量网页的性能.该工具会抓取网址两次,一次是通过移动设备进行分析,另一次是通过桌面设备进行分析. PageSpeed得分范围是从0到100分.分数越高,代表性能越好.85分或更高分表明网页性能良好. PageSpeed Insights能根据以下内容衡量网页如何提升其性能: 首屏加载时间:从用户请求新页面到浏览器呈现首屏内容所用的时

Google Optimization Tools实现加工车间任务规划【Python版】

上一篇介绍了<使用.NET Core与Google Optimization Tools实现加工车间任务规划>,这次将Google官方文档python实现的版本的完整源码献出来,以满足喜爱python的朋友. from __future__ import print_function # Import Python wrapper for or-tools constraint solver. from ortools.constraint_solver import pywrapcp def

Android perf tools

文档,也可以直接在你的SDK的源代码找. http://lxr.free-electrons.com/source/tools/perf/Documentation/ 更加深入(深奥)的文档 https://perf.wiki.kernel.org/index.php/Tutorial 如何采集一个小程序的样本?这招特别管用 #perf stat -r 10 zip -o kernel.gz.zip kernel.gz #perf stat -r 10 unzip -o kernel.gz.zi

NGINX源码安装配置详解(./configure),最全解析

NGINX ./configure详解 在"./configure"配置中,"--with"表示启用模块,也就是说这些模块在编译时不会自动构建"--without"表示禁用模块,也就是说这些模块在编译时会自动构建,若你想Nginx轻量级运行,可以去除一些不必要的模块. [[email protected] nginx-1.14.0]# ./configure --help => 查看安装配置项 --help 打印帮助信息. --prefix

nginx-1.13.12 源码配置清单

configure命令支持以下参数: --help打印帮助信息. --prefix=安装路径定义一个将保留服务器文件的目录.这个相同的目录也将被用于由configure(由库源创建的路径除外)和nginx.conf配置文件中设置的所有相对路径.它/usr/local/nginx默认设置为目录. --sbin-path=path设置一个nginx可执行文件的名称.该名称仅在安装期间使用.默认情况下该文件被命名 prefix/sbin/nginx. --modules-path=模块路径定义一个将安

Nginx Announcing NGINX Plus R7

https://www.nginx.com/blog/nginx-plus-r7-released/?_ga=1.70204696.981062698.1445605275 https://www.nginx.com/ Announcing NGINX Plus R7 NGINX, Inc. is proud to announce the availability of NGINX Plus Release 7 (R7), the latest release of our applicati

系统级性能分析工具 — Perf

离2.6.31内核开始.linux核心配备了性能分析工具perf,它可以是功能级和指令级热外表. perf Performance analysis tools for Linux. Performance counters for Linux are a new kernel-based subsystem that provide a framework for all things performance analysis. It covers hardware level (CPU/PM

perf工具-linux下性能分析工具

从2.6.31内核开始,linux内核自带了一个性能分析工具perf,能够进行函数级与指令级的热点查找. perf Performance analysis tools for Linux. Performance counters for Linux are a new kernel-based subsystem that provide a framework for all things performance analysis. It covers hardware level (CP

安装nginx 配置虚拟主机

nginx安装 #查看操作系统版本 [[email protected] ~]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) #查看内核版本和64位还是32位 [[email protected] ~]# uname -a Linux master1 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Li