给nginx装上lua扩展
|
|
curl命令格式化输出请求各阶段的时间
curl 有一个参数 -w, --write-out <format> 可以在一次请求成功结束之后将跟该次请求相关的数据写到标准输出。
我们可以利用该功能将一次请求的各个阶段的时间格式化输出到屏幕以便查看分析问题。
首先, 我们查看man手册文档, 通过搜索定位到文档关于参数 -w, --write-out <format> 的描述位置,
可以看到关于这个文档的描述:
Defines what to display on stdout after a completed and successful operation. The format is a string that may contain plain text mixed with any number of vari‐
ables. The string can be specified as “string”, to get read from a particular file you specify it “@filename” and to tell curl to read the format from stdin you
write “@-“.The variables present in the output format will be substituted by the value or text that curl thinks fit, as described below. All variables are specified as
%{variable_name} and to output a normal % you just write them as %%. You can output a newline by using \n, a carriage return with \r and a tab space with \t.
大致的意思如下:
定义在一次操作成功结束之后再标准输出中显示什么. 参数的格式可以是普通文本夹杂着预先定义好的变量.
参数可以通过命令行参数 “output format string” 来指定, 也可以通过 “@filename” 的格式来指定一个
文件, curl可以从该文件内读取 format 字符串, 或者也可以通过 “@-“ 的形式来告诉curl从标准输入内读取
format string .curl会用合适的值或者文本来替换输出格式字符串中定义的变量. 所有的变量都以 %{variable_name} 的方式
来定义, 如果你想输出一个百分号(%), 写两个百分号(%%) 就好了. 你可以通过使用 \n 来输出一个换行, 也
可以使用 \r 来输出一个回车, 使用 \t 输出一个制表符.
在了解了该参数的含义后,我们从该参数后的变量列表里找出我们需要用到的预定义变量.
我需要用到的变量如下:(查看完整版的预定义变量列表请使用man curl 查看)
|
|
结合上面这些信息, 我们可以写出一个长长的format字符串来输出一个格式化的时间信息:
|
|
下图是我的一个测试:

在 *UNIX 系统下, 我们可以将这个长长的命令保存为一个别名(alias), 方便以后的使用.
编辑 ~/.bashrc 文件, 添加如下一行:
|
|
好了,以后打开命令终端窗口, 需要的时候我们就可以以 curltime命令来代替curl命令从而获得额外的格式化过的时间统计数据的输出了.
注: 增加 -s 参数是为了让curl的输出变得更干净一点
收集RESTful API请求日志
基于 tornado 做RESTful API 开发的时候, 研究使用了基于 redis 的 pub/sub 功能来实时的收集API请求日志
详细实现查看这个Gist记录
pip vs easy_install
查询每一个时间点数据同前一个时间点数据变化
有一个表里存放了每五分钟的一些统计数据, 希望通过一个SQL来查询每五分钟数据点同前一个数据点的变化.
采用查询同一张表两次的方式, 将两个结果集的结果的时间字段使用固定差值关系join在一起(比如我的数据中前一个数据与后一个数据时间相差5分钟),
然后将关联到的记录的数据做统计运算.
示例SQL如下:
|
|
redis几个常见操作的性能测试
redis 的 set/mset/get/mget/hset/hmset/hget/hmget/hgetall 等操作的性能测试
|
|
结论很明显啦
Try/catch or validation for speed?
在 stackoverflow 上看到的一篇帖子:
安装 subversion
下载 svn
wget http://ftp.tsukuba.wide.ad.jp/software/apache/subversion/subversion-1.8.13.tar.gz
查看根目录下的 INSTALL 文件
执行 ./autogen.sh
根据提示,下载 autoconf, libtool
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
wget http://ftp.jaist.ac.jp/pub/GNU/libtool/libtool-2.4.6.tar.gz
安装 autoconf 提示需要 GNU M4
wget http://ftp.gnu.org/gnu/m4/m4-1.4.17.tar.gz
执行 subversion 目录中的 ./configure (指定 prefix)
提示:configure: error: no suitable APR found
下载 apr
wget http://ftp.jaist.ac.jp/pub/apache//apr/apr-1.5.2.tar.gz
下载 apr-util
wget http://ftp.jaist.ac.jp/pub/apache//apr/apr-util-1.5.4.tar.gz
又提示需要 SQLite
wget https://www.sqlite.org/2015/sqlite-autoconf-3081002.tar.gz
最后
./configure –prefix=/home/myth/tmp/subversion –with-apr=/home/myth/software/apr-1.5.2 –with-apr-util=/home/myth/software/apr-util-1.5.4
编译安装成功
使用python在终端输出带有样式的文本
|
|