Giter VIP home page Giter VIP logo

graphql-benchmarks's Introduction

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

Server Requests/sec Latency (ms)
Caliban 9,108.97 11.37
async-graphql 7,910.16 12.65
Tailcall 7,554.72 13.22
Gqlgen 2,188.72 47.30
Apollo GraphQL 1,829.68 54.49
Netflix DGS 1,656.97 64.27

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. Here is the complete GraphQL query:

{
  posts {
    title
  }
}

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!
}

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!

graphql-benchmarks's People

Contributors

a-n-uraag avatar actions-user avatar amitksingh1490 avatar ayewo avatar kyri-petrou avatar miaxos avatar ologbonowiwi avatar renovate[bot] avatar tailcall-bot avatar tusharmath avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

graphql-benchmarks's Issues

Fix CI Workflow for Benchmark Execution and Result Handling

Description

The CI workflow requires enhancements to handle benchmark execution and updating the README file correctly. We need to address the following scenarios:

  1. Main Branch: When changes are pushed to the main branch, the CI should run benchmarks and update the README file with the results, committing these changes back to the main branch.
  2. Pull Requests: For pull requests, the CI should run benchmarks but not update the README or commit any changes. This step is to ensure benchmarks run successfully without altering the repository.
  3. Failure Handling: The CI should fail if it encounters any issues in generating or updating benchmark results, making these failures visible for prompt resolution.

Expected Behavior

  • On Main Branch:

    • Run benchmarks.
    • If benchmarks run successfully, update the README file with the results and commit these changes to the main branch.
    • If there is a failure in running benchmarks or updating the README, the CI should fail and report the error.
  • On Pull Requests:

    • Run benchmarks without updating the README or committing any changes.
    • CI should fail if there is an issue in generating benchmark results.

Acceptance Criteria

  1. CI updates to run benchmarks on the main branch and update the README file with the results, followed by committing these changes.
  2. CI updates to run benchmarks on pull requests without updating the README or committing any changes.
  3. Ensure CI fails and reports errors if benchmark generation or README update fails.

Disable file updates on PRs

Running the build on PRs is constantly causing merge conflicts because all of them keep updating the README and the image files.

Technical Requirements

  • Run the benchmarks as it is without committing anything into git.
  • Once the results are ready print them on the CI logs, as a separate step.

Install node from a non-deprecated source

Here is the log on the benchmark job:

[2023-11-17T14:55:22.168Z] #8 0.296 
#8 0.296   The NodeSource Node.js Linux distributions GitHub repository contains
#8 0.296   information about which versions of Node.js and which Linux distributions
#8 0.296   are supported and how to install it.
#8 0.296   https://github.com/nodesource/distributions
#8 0.296 
#8 0.296 
#8 0.296                           SCRIPT DEPRECATION WARNING
#8 0.296 
#8 0.296 ================================================================================
#8 0.297 ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
#8 0.297 ================================================================================
#8 0.297 
#8 0.297 TO AVOID THIS WAIT MIGRATE THE SCRIPT

This slows down the benchmark as the script sleeps for 60 seconds before continuing.

Start all servers on port 8000

Currently all servers start on different ports.

.devcontainer/Dockerfile

EXPOSE 8080 8081 8082 8083 8084 3000

Ideally we would like to expose every service on a single port 8000. While running the tests, we will start the service, run the benchmark and stop the service completely only after which move on to the next service.

Run the benchmarks automatically on `benchmarking-runner`

Technical Requirements

  • Run benchmarks for all PRs on benchmarking-runner runner.
  • It should follow the steps we have documented and automatically generate
    1. The current README.md with a table sorted highest to lowest in terms by RPS.
    2. A histogram of RPS
    3. A histogram of Latency

Nginx proxy is not working

Hi, it seems that since #28 the Nginx proxy doesn't work as expected, which means that the graphql endpoints are returning errors. This largely explains why both Taillcall and Gqlgen saw a massive increase in throughput and RPS after the PR was merged in, since their underlying server / client is more performant than Caliban's. Also likely explains why DGS is crashing (probably doesn't handle the client failures well).

Steps to reproduce:

./nginx/run.sh
./graphql/tailcall/run.sh &
sleep 2
./test_query.sh

Running the above returns:

{"data":null,"errors":[{"message":"IOException: Request error: error sending request for url (http://jsonplaceholder.typicode.com/posts): error trying to connect: tcp connect error: Connection refused (os error 111)","locations":[{"line":1,"column":2}]}]}

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

cargo
graphql/async_graphql/Cargo.toml
  • anyhow 1.0.82
  • async-graphql 7.0.3
  • async-graphql-axum 7.0.3
  • axum 0.7.5
  • tokio 1.37.0
  • reqwest 0.12.4
  • serde 1.0.200
  • serde_json 1.0.116
dockerfile
.devcontainer/Dockerfile
github-actions
.github/workflows/bench.yml
  • actions/checkout v4
  • devcontainers/ci v0.3
  • peter-evans/commit-comment v3
  • stefanzweifel/git-auto-commit-action v5
gomod
graphql/gqlgen/go.mod
  • go 1.22.2
  • github.com/99designs/gqlgen v0.17.48
  • github.com/vektah/gqlparser/v2 v2.5.12
  • golang.org/x/sync v0.7.0
gradle
graphql/netflix_dgs/settings.gradle
graphql/netflix_dgs/build.gradle
  • org.springframework.boot 3.3.0
  • io.spring.dependency-management 1.1.5
  • com.netflix.graphql.dgs:graphql-dgs-platform-dependencies 9.0.0
  • io.projectreactor:reactor-bom 2023.0.6
  • org.apache.httpcomponents.core5:httpcore5 5.2.4
  • org.apache.httpcomponents.client5:httpclient5 5.3.1
gradle-wrapper
graphql/netflix_dgs/gradle/wrapper/gradle-wrapper.properties
  • gradle 8.8
npm
graphql/apollo_server/package.json
  • @apollo/server ^4.9.3
  • axios ^1.5.0
  • graphql ^16.8.0
  • http-proxy-agent ^7.0.0
  • pm2 ^5.3.0
graphql/tailcall/package.json
  • @tailcallhq/tailcall 0.86.0
sbt
graphql/caliban/build.sbt
  • scala 3.4.2
  • com.github.ghostdogpr:caliban-quick 2.7.1
  • com.github.plokhotnyuk.jsoniter-scala:jsoniter-scala-core 2.30.1
  • com.github.plokhotnyuk.jsoniter-scala:jsoniter-scala-macros 2.30.1
  • org.apache.httpcomponents.client5:httpclient5 5.3.1
  • dev.zio:zio 2.1.2
graphql/caliban/project/build.properties
  • sbt/sbt 1.10.0

  • Check this box to trigger a request for Renovate to run again on this repository

Improve project quality

  • Use consistent naming convention for files. Stick to kebab case.
  • Move images to a separate folder
  • Display images on the readme
  • Update readme with steps to run it on code spaces
  • Add a link to setup and run on codespaces
  • Double the resolution of the images
  • Add the actual data in tabular format also on the Readme
  • Fix the legend getting clipped.
  • Add website links instead of github links
  • Need a way to configure load externally
  • Add architecture diagram
  • Add benchmark description

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.