Skip to content

Sanic+Gino and Flask+Sqlalchemy have similar pressure test performance. #631

Description

@sunshineinwater

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 :
  1. sanic+gino: 1700 requests/seconds
  2. flask+sqlalchemy:1100 requests/seconds
  3. Golang : 5000+ requests/seconds

flask + SQLAlchemy :
image

sanic + gino
image

use Same Configration test purl web performance:

  • concurrence result :
  1. Sanic : 20000 requests/seconds
  2. flask: 3300 requests/seconds
  3. 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions