- 构建服务镜像
docker build -t green-webbench .
# docker run -dit -p 8080:8080 -v /home/wq/workplace/green-final-webbench:/root/green-webbench --name green-webbench green-webbench sh
docker run -dit -v /home/wq/workplace/green-final-webbench:/root/green-webbench --name green-webbench --network=host green-webbench sh
docker exec -it green-webbench sh
- 编译(产物在output目录中)
make all
- apache ab进行压测 并发1000个请求,一共发起100W个请求
ab -n 1000000 -c 1000 -k -r 127.0.0.1:8080/collect_energy/1/2
- 启动服务器
docker exec -it green-webbench sh
cd /root/green-webbench
# 每个连接有一个线程处理
./output/conn_per_thread_server.out
# N个epoll
./output/epoll_server.out
# httplib库, epoll+线程池
./output/httplib_server.out.out
# cinatra库, aio
./output/cinatra_server.out.out
# java-springmvc (参数可能有误,本地跑出来的效果并不好)
java -Xmx4G -Xms4G -Xmn3G -XX:MetaspaceSize=256M -XX:MaxMetaspaceSize=256M -XX:+UseG1GC -XX:+AlwaysPreTouch -XX:+UseFastAccessorMethods -jar ./output/springmvc_server.jar
# java-flux (参数可能有误,本地跑出来的效果并不好)
java -Xmx3G -Xms3G -Xmn3G -XX:MetaspaceSize=256M -XX:MaxMetaspaceSize=256M -XX:+UseG1GC -XX:+AlwaysPreTouch -XX:+UseFastAccessorMethods -jar ./output/flux_server.jar
- apache ab压测工具 100万个请求,1000个链接。
ab -n 1000000 -c 1000 -k -r 127.0.0.1:8080/collect_energy/1/2
# ab -m POST -n 1000000 -c 1000 -k -r 127.0.0.1:8080/collect_energy/1/2
- 实验结果
framework | qps (requests per second) |
---|---|
httplib_server | 21707 |
cinatra_server | 97013 |
conn_per_thread_server | 74274 |
epoll_server | 106323 |
springmvc_server | 6208 |
flux_server | 7292 |