tailcallhq / graphql-benchmarks

Setup to compare graphql frameworks
32 stars 22 forks source link

GraphQL Benchmarks

Open in GitHub Codespaces

Explore and compare the performance of the fastest GraphQL frameworks through our comprehensive benchmarks.

Introduction

This document presents a comparative analysis of several renowned GraphQL frameworks. Dive deep into the performance metrics, and get insights into their throughput and latency.

NOTE: This is a work in progress suite of benchmarks, and we would appreciate help from the community to add more frameworks or tune the existing ones for better performance.

Quick Start

Get started with the benchmarks:

  1. Click on this link to set up on GitHub Codespaces.
  2. Once set up in Codespaces, initiate the benchmark tests:
./setup.sh
./run_benchmarks.sh

Benchmark Results

Query Server Requests/sec Latency (ms) Relative
1 { posts { id userId title user { id name email }}}
Tailcall 30,731.30 3.24 108.23x
async-graphql 1,748.25 57.58 6.16x
Caliban 1,533.14 65.09 5.40x
Hasura 1,528.73 65.21 5.38x
Gqlgen 662.59 150.51 2.33x
Netflix DGS 361.82 164.52 1.27x
Apollo GraphQL 283.94 346.80 1.00x
2 { posts { title }}
Tailcall 62,781.70 1.58 39.12x
Caliban 9,206.32 11.23 5.74x
async-graphql 8,679.90 11.56 5.41x
Hasura 2,542.85 39.31 1.58x
Gqlgen 2,270.77 45.08 1.42x
Apollo GraphQL 1,790.88 55.76 1.12x
Netflix DGS 1,604.71 68.88 1.00x
3 { greet }
Tailcall 65,204.50 1.55 25.47x
Gqlgen 50,124.00 5.35 19.58x
async-graphql 49,848.30 2.07 19.47x
Caliban 46,625.10 2.47 18.21x
Netflix DGS 8,306.34 14.78 3.24x
Apollo GraphQL 8,131.77 12.50 3.18x
Hasura 2,560.30 38.96 1.00x

1. {posts {title body user {name}}}

Throughput (Higher is better)

Throughput Histogram

Latency (Lower is better)

Latency Histogram

2. {posts {title body}}

Throughput (Higher is better)

Throughput Histogram

Latency (Lower is better)

Latency Histogram

3. {greet}

Throughput (Higher is better)

Throughput Histogram

Latency (Lower is better)

Latency Histogram

Architecture

Architecture Diagram

A client (wrk) sends requests to a GraphQL server to fetch post titles. The GraphQL server, in turn, retrieves data from an external source, jsonplaceholder.typicode.com, routed through the nginx reverse proxy.

WRK

wrk serves as our test client, sending GraphQL requests at a high rate.

GraphQL

Our tested GraphQL server. We evaluated various implementations, ensuring no caching on the GraphQL server side.

Nginx

A reverse-proxy that caches every response, mitigating rate-limiting and reducing network uncertainties.

Jsonplaceholder

The primary upstream service forming the base for our GraphQL API. We query its /posts API via the GraphQL server.

GraphQL Schema

Inspect the generated GraphQL schema employed for the benchmarks:

schema {
  query: Query
}

type Query {
  posts: [Post]
}

type Post {
  id: Int!
  userId: Int!
  title: String!
  body: String!
  user: User
}

type User {
  id: Int!
  name: String!
  username: String!
  email: String!
  phone: String
  website: String
}

Contribute

Your insights are invaluable! Test these benchmarks, share feedback, or contribute by adding more GraphQL frameworks or refining existing ones. Open an issue or a pull request, and let's build a robust benchmarking resource together!