golang的beego框架开发时出现的问题纪录
1.数据库并发时
问题:
[ORM]2017/02/20 23:44:05 -[Queries/default] - [FAIL / db.Query / 15.9ms] - [SELECT mp_wx_account.app_id, mp_wx_account.app_secret FROM mp_wx_develop INNER JOIN mp_wx_account ON mp_wx_account.app_id = mp_wx_develop.appid WHERE mp_wx_develop.key = ? LIMIT 1 OFFSET 0] - `123` - dial tcp 127.0.0.1:3306: socket: too many open files
解决方法:
注册时填加上参数4和参数5
// 参数4(可选) 设置最大空闲连接
// 参数5(可选) 设置最大数据库连接 (go >= 1.2)
maxIdle := 30
maxConn := 30
orm.RegisterDataBase("default", dbType, dsn, maxIdle, maxConn)
2.http并发请求时
问题:
Get https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token=ZsVx8PhlJH0TUEh7I3yq2g88cpGbxo2MqGIxBgfD9D7H9_geKhJlCAbWebOlt9HWkTQBW7TRBI5VCizgg4ZF2q40h42rUlJNo4yMMM7kVQdMz6Rrmvmh_C18qK2bKYfVQVGeAIABGR: dial tcp 183.61.49.149:443: socket: too many open files
解决方法:
open files只有256,对应的调高就可以了
临时 如: unlimit -n 65535
liugx@liugx test$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 256
pipe size (512 bytes, -p) 1
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 709
virtual memory (kbytes, -v) unlimited