-
Notifications
You must be signed in to change notification settings - Fork 845
Description
According to #106 performance has not been a key concern at the moment over functionality, with which I completely agree. However, out of interest I started running some simple and contrived load testing using wrk. I compared an absolutely barebones graphql setup in graphql-go and express-graphql (code in gists linked to below) and here are some results for a test with 12 threads, 400 connections over a 30 second period.
Notable points are:
- graphql-go has a much lower failure rate
- graphql-go is roughly one third slower on average
- graphql-go has a max request time of 2.97s vs 543.76ms (6 times slower)
- Despite graphql-go managing 90% of the number of requests as express-graphql in 30 seconds, the data read from the responses is roughly only 55% in graphql-go than express-graphql. I have no idea why this is. I've checked headers to see if node was returning significantly more but this does not seem to the case. Any ideas anyone?
Given the claim of no real optimisations so far I think this is an excellent starting point, especially given the significantly lower failure rate. However, I think for such a trivial test case the timing should be must closer.
I'm pretty new to go but I'm looking to further my skills. I'm going to try and tackle some of the other open issues first but I would like to come back to this and help where I can. Perhaps in the meantime we could start a discussion on how to improve and discover some areas of code that could be investigated.
I have also attached a flame graph at the bottom that was sampled for 15 seconds during the middle a 30 second load test. This indicates that most of the time spent in graphql-go is spent inside graphql.ValidateDocument()
and specifically vistor.Visit()
Query Used
{
hello
}
express-graphql
$ ./wrk -t12 -c400 -d30s --timeout 10s "http://localhost:3002/graphql?query={hello}"
Running 30s test @ http://localhost:3002/graphql?query={hello}
12 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 233.70ms 59.29ms 543.76ms 73.81%
Req/Sec 136.11 72.90 430.00 64.76%
47934 requests in 30.09s, 10.65MB read
Socket errors: connect 0, read 416, write 17, timeout 0
Requests/sec: 1592.86
Transfer/sec: 362.44KB
graphql-go
$ ./wrk -t12 -c400 -d30s --timeout 10s "http://localhost:3003/graphql?query={hello}"
Running 30s test @ http://localhost:3003/graphql?query={hello}
12 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 324.12ms 302.86ms 2.97s 72.19%
Req/Sec 118.76 43.91 300.00 70.50%
42635 requests in 30.10s, 5.86MB read
Socket errors: connect 0, read 203, write 0, timeout 0
Requests/sec: 1416.43
Transfer/sec: 199.18KB