我的项目源码

https://github.com/helloJiu/o...

openresty源码装置(ubuntu为例)

apt install gcc libpcre3-dev libssl-dev perl make build-essential zlib1g-devwget https://openresty.org/download/openresty-1.19.9.1.tar.gztar -zxvf openresty-1.19.9.1.tar.gzcd openresty-1.19.9.1/./configuremake && make install

装置luarocks

wget https://luarocks.github.io/luarocks/releases/luarocks-2.4.3.tar.gztar -xzvf luarocks-2.4.3.tar.gzcd luarocks-2.4.3/./configure --prefix=/usr/local/openresty/luajit     --with-lua=/usr/local/openresty/luajit/     --lua-suffix=jit     --with-lua-include=/usr/local/openresty/luajit/include/luajit-2.1make && make install

配置环境变量

vim /etc/profileexport PATH=$PATH:/usr/local/openresty/bin:/usr/local/openresty/luajit/binsource /etc/profile# 设置lua软链到luajitln -s  /usr/local/openresty/luajit/bin/luajit luamv lua /usr/bin/

装置lapis

  • https://leafo.net/lapis/
/usr/local/openresty/luajit/bin/luarocks install lapis

装置redis依赖包和http-client依赖包以及其余依赖

opm install lua-resty-stringopm install openresty/lua-resty-redisopm install ledgetech/lua-resty-http

微信公众平台筹备

测试号申请

https://mp.weixin.qq.com/debu...

内网穿透工具

https://www.cpolar.com/

cpolar.exe http 8123

配置

# 测试号信息appID xxxappsecret xxx#接口配置信息批改内网穿透失去的地址 如https://444aece.r6.cpolar.top/wechat/accept# 验证Token  对应配置里的wechat.verifyTokenhelloworld

配置app/config/config.lua

    -- 微信相干配置    wechat = {        appId = "xxx",  --公众号id        appSecret = "xxx", -- 公众号秘钥        verifyToken = "helloworld", -- 验证Token     },    -- redis相干配置    redis = {        host = "127.0.0.1",        port = 6379,        password = "",        db_index = 0,        max_idle_time = 30000,        database = 0,        pool_size = 100,        timeout = 5000,    },

启动我的项目

lapis server

压力测试

## autocannon压测命令须要应用npm装置autocannon -c 100 -d 30 -p 2 -t 2 http://127.0.0.1:8123/wechat/checkLogin?scene=NHAK5ElJqz73YHaYhltG## 运行后果Running 30s test @ http://10.254.39.195:8123/wechat/checkLogin?scene=NHAK5ElJqz73YHaYhltG100 connections with 2 pipelining factor┌─────────┬───────┬────────┬────────┬────────┬───────────┬───────────┬─────────┐│ Stat    │ 2.5%  │ 50%    │ 97.5%  │ 99%    │ Avg       │ Stdev     │ Max     │├─────────┼───────┼────────┼────────┼────────┼───────────┼───────────┼─────────┤│ Latency │ 12 ms │ 314 ms │ 652 ms │ 701 ms │ 316.26 ms │ 186.86 ms │ 3094 ms │└─────────┴───────┴────────┴────────┴────────┴───────────┴───────────┴─────────┘┌───────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┐│ Stat      │ 1%      │ 2.5%    │ 50%     │ 97.5%   │ Avg     │ Stdev   │ Min     │├───────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤│ Req/Sec   │ 7259    │ 7259    │ 8807    │ 9207    │ 8714.94 │ 436.3   │ 7258    │├───────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤│ Bytes/Sec │ 1.58 MB │ 1.58 MB │ 1.92 MB │ 2.01 MB │ 1.9 MB  │ 95.1 kB │ 1.58 MB │└───────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┘Req/Bytes counts sampled once per second.# of samples: 30267k requests in 30.03s, 57 MB read55 errors (0 timeouts)## QPS大略8700+