GithubHelp home page GithubHelp logo

django-graphene-benchmarks's Introduction

Benchmarking for graphql-python/graphene-django#1394

TL;DR

16.547s vs 83.194s for i/o bound queries. 5x faster. async wins


Methodology

  1. project is a simple django project with a single app.
  2. sqlite3 is used as the database, with 3 tables filled in with data (up to a million records)
  3. two endpoints are created, one for sync and one for async.
  4. versions:
    • Django==5.0
    • uvicorn==0.27.0
    • gunicorn==21.2.0
  5. ab - 1000 requests, 10 concurrent requests.

Async

Server run:

uvicorn octopus.asgi:application --host 0.0.0.0 --port 8000

AB command

ab -n 1000 -c 10 -p ./request.txt -T application/json http://127.0.0.1:8000/graphql-async/

or ./run-async.sh.

Results:

This is ApacheBench, Version 2.3 <$Revision: 1903618 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        uvicorn
Server Hostname:        127.0.0.1
Server Port:            8000

Document Path:          /graphql-async/
Document Length:        974 bytes

Concurrency Level:      100
Time taken for tests:   13.670 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      1246000 bytes
Total body sent:        245000
HTML transferred:       974000 bytes
Requests per second:    73.15 [#/sec] (mean)
Time per request:       1367.026 [ms] (mean)
Time per request:       13.670 [ms] (mean, across all concurrent requests)
Transfer rate:          89.01 [Kbytes/sec] received
                        17.50 kb/s sent
                        106.51 kb/s total

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.9      0       4
Processing:    49 1327 200.0   1386    1597
Waiting:       43 1309 198.4   1369    1586
Total:         49 1327 200.0   1386    1597

Percentage of the requests served within a certain time (ms)
  50%   1386
  66%   1425
  75%   1446
  80%   1459
  90%   1486
  95%   1502
  98%   1530
  99%   1540
 100%   1597 (longest request)

Sync

Server run:

gunicorn octopus.wsgi -w 4 -p 8000

AB command:

ab -n 1000 -c 10 -p ./request.txt -T application/json http://127.0.0.1:8000/graphql/

or ./run-sync.sh.

Results:

This is ApacheBench, Version 2.3 <$Revision: 1903618 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        gunicorn
Server Hostname:        127.0.0.1
Server Port:            8000

Document Path:          /graphql/
Document Length:        47489 bytes

Concurrency Level:      100
Time taken for tests:   24.465 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      47913000 bytes
Total body sent:        239000
HTML transferred:       47489000 bytes
Requests per second:    40.87 [#/sec] (mean)
Time per request:       2446.534 [ms] (mean)
Time per request:       24.465 [ms] (mean, across all concurrent requests)
Transfer rate:          1912.50 [Kbytes/sec] received
                        9.54 kb/s sent
                        1922.04 kb/s total

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   1.7      0       7
Processing:   350 2293 355.0   2375    2715
Waiting:      340 2292 355.1   2374    2714
Total:        350 2294 353.5   2375    2717

Percentage of the requests served within a certain time (ms)
  50%   2375
  66%   2405
  75%   2434
  80%   2447
  90%   2473
  95%   2498
  98%   2531
  99%   2552
 100%   2717 (longest request)

More tests

Async:

ab -n 1000 -c 100 -p ./request.txt -T application/json http://127.0.0.1:8000/graphql-async/ uvicorn octopus.asgi:application --host 0.0.0.0 --port 8000

Concurrency Level:      100
Time taken for tests:   13.411 seconds
Complete requests:      1000
Failed requests:        0

Mem usage: 80mb, 100threads

Sync:

ab -n 1000 -c 100 -p ./request.txt -T application/json http://127.0.0.1:8000/graphql/ gunicorn octopus.wsgi -w 9 -p 8000

Concurrency Level:      100
Time taken for tests:   23.384 seconds
Complete requests:      1000
Failed requests:        0

Mem usage: 80mb*9, one thread per process.


Comparison table

Sync Async Sync Async Sync Async
Requests 1000 1000 1000 1000 1000 1000
Concurrency 100 100 100 100 100 100
Processes 9 1 4 1 9 9
Threads per process 1 100 1 100 1 1-30
Mem ~720mb ~80mb ~320mb ~80mb ~720mb ~720mb
Time 23.384s 13.411s 24.465s 13.670s 23.384s 4.719s

django-graphene-benchmarks's People

Contributors

dima-kov avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

superlevure

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.