Open
Description
Description
use WRK test three types of web frame to read one recorder in postgresql database
: 1、Sanic+gino, 2、flask+sqlalchemy+gevent+gunicorn, 3、Golang gin+gorm.
test machine: MacBook Pro 8GB
- concurrence result :
- sanic+gino: 1700 requests/seconds
- flask+sqlalchemy:1100 requests/seconds
- Golang : 5000+ requests/seconds
use Same Configration test purl web performance:
- concurrence result :
- Sanic : 20000 requests/seconds
- flask: 3300 requests/seconds
- Golang : 80000 requests/seconds
Why it has nearly performance between sanic+gino and flask+sqlalchemy ?
What I Did
Sanic + gino :
@app.route('/testdb', methods=['GET'])
async def 测试数据库功能(request):
data = await UserModel.query.where(UserModel.accountID == "test").gino.first()
if data is None:
user = await UserModel.create(accountID='test')
data = await UserModel.query.where(UserModel.accountID == "test").gino.first()
return response.text(data.openID)
if __name__ == '__main__':
app.run(debug=False, port=7005, host='0.0.0.0', workers=5, access_log=False)
Flask + SQLalchemy:
@app.route("/testdb", methods=["GET"])
def test_db():
data = UserModel.query.filter(UserModel.accountID == "test").first()
if data is not None:
return data.accountID
return "None"
run:
gunicorn main:app --bind 0.0.0.0:7005 --worker-class gevent --workers 9 --threads 8