一台 8c32g 的 vultr 云服务,所有服务(redis、sidekiq、rails、openresty、timescaledb)在这台机器上,测试了一下从请求到入库的性能,几乎把机器跑满:
大概的处理结果是:
如果把 sidekiq 关掉,单独测试 http 请求性能,大概可以处理 25k/s,就是说把每个服务单独部署的话,25k/s 算是 hypercable analytics 在 8c32g 单机处理的极限了。
siege -R <(echo connection = keep-alive) -c50 -b -t 50S 'http://10.40.96.5:8000/c7f4edce-58c3-4917-8f18-a2ea6c1b93dc/g/collect?en=page_view&v=2&tid=G-JEX4JP2G1E>m=2oe161&_p=1322479532&sr=1440x900&ul=zh-cn&cid=1162070685.1609784219&dl=https%3A%2F%2Fhypercable.github.io%2Fsite%2F%3Fto%3Dget-start&dr=https%3A%2F%2Fhypercable.github.io%2Fsite%2F%3Fto%3Dlearn-more&dt=ga%20test&sid=1611145231&sct=34&seg=1&_s=1' -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36' -H 'content-type: text/plain;charset=UTF-8' -H 'accept: */*' -H 'origin: https://hypercable.github.io' -H 'referer: https://hypercable.github.io/' -H 'accept-language: zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7' -A 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36'a
** SIEGE 4.0.4
** Preparing 50 concurrent users for battle.
The server is now under siege...
Lifting the server siege...
Transactions: 1236030 hits
Availability: 100.00 %
Elapsed time: 49.41 secs
Data transferred: 0.00 MB
Response time: 0.00 secs
Transaction rate: 25015.79 trans/sec
Throughput: 0.00 MB/sec
Concurrency: 49.40
Successful transactions: 1236030
Failed transactions: 0
Longest transaction: 0.04
Shortest transaction: 0.00
一些参数:
docker-compose -f docker-compose.production.yaml up -d --scale sidekiq=6
启动 6 个 sidekiq 容器,sidekiq 并发设置 25,数据库连接池设置 25,MAX_BATCH_SIZE=50,EXECUTION_INTERVAL=5
所有服务都在容器内,可能直接放主机上的话,会稍微有些提升?