{"id":13514581,"url":"https://github.com/GavinRay97/graphql-bench","last_synced_at":"2025-03-31T03:31:07.372Z","repository":{"id":42266499,"uuid":"268437450","full_name":"GavinRay97/graphql-bench","owner":"GavinRay97","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-11T02:55:51.000Z","size":29014,"stargazers_count":7,"open_issues_count":9,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-30T22:06:22.514Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GavinRay97.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-01T05:57:14.000Z","updated_at":"2021-08-06T15:23:36.000Z","dependencies_parsed_at":"2023-02-09T00:03:21.759Z","dependency_job_id":null,"html_url":"https://github.com/GavinRay97/graphql-bench","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GavinRay97%2Fgraphql-bench","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GavinRay97%2Fgraphql-bench/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GavinRay97%2Fgraphql-bench/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GavinRay97%2Fgraphql-bench/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GavinRay97","download_url":"https://codeload.github.com/GavinRay97/graphql-bench/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246413377,"owners_count":20773053,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T05:00:58.048Z","updated_at":"2025-03-31T03:31:02.361Z","avatar_url":"https://github.com/GavinRay97.png","language":"HTML","funding_links":[],"categories":["HTML"],"sub_categories":[],"readme":"# GraphQL Benchmarking Toolset\n\n## Introduction\n\nThis repo contains four top-level folders, and a Makefile. This is the significance of each:\n\n- `/containers`: Has the `docker-compose.yaml` manifest for Hasura + Postgres 12. By default, Hasura is bound to `localhost:8085` not to conflict, and postgres to `localhost:5430`. Feel free to modify these if you like. It also contains a SQL script for creating the Chinook database, and a bash script for loading it into Postgres as-configured.\n\n- `/queries`: This folder contains the code for benchmarking GraphQL queries. Two different benchmarking tools are used to get a better estimate. Autocannon, written in Node, and K6, written in Go (with a JS scripting API).\n\n- `/subscriptions`: Contains the code for benchmarking subscriptions (this contains it's own README and set of instructions, please see it for details).\n\n- `/reports`: The output of both JSON and HTML reports when running benchmarks goes here. It contains two folders, `/k6` and `/autocannon` which each hold their respective report data.\n\nThere is a makefile in the root of the project, with a help command available. Running `make` without arguments or `make help` will prompt it:\n\n```\n❯ make\n00README                       RECOMMENDED PROCESS: \"make setup_containers\" -\u003e \"make create_chinook_database\" -\u003e \"make benchmark_all_then_serve_reports\"\nbenchmark_all_then_serve_reports Runs benchmarks with Autocannon \u0026 K6, then serves their reports on http://localhost:5000\nbenchmark_autocannon           Runs benchmarks using Autocannon, outputs HTML \u0026 JSON reports per-query to './reports/autocannon'\nbenchmark_k6                   Runs benchmarks using K6, outputs JSON reports per-query to './reports/k6'\nclean_reports                  Remove previously generated bench reports\ncreate_chinook_database        Sets up Chinook database in Hasura for testing\ndo_everything_for_me           Sets up containers, creates Chinook database, runs benchmarks with Autocannon \u0026 K6, then serves reports\ninstall_node_modules           Installs nodes modules for query dependencies\nserve_reports                  Starts a webserver to display the output of Autocannon and K6 reports on http://localhost:5000\nsetup_all                      Sets up containers and then creates Chinook database\nsetup_containers               Sets up Hasura and Postgres Docker containers\n```\n\nThe easiest path, as the recommendation states, is likely to run `make setup_container`, `make_create_chinook_database`, and then `make benchmark_all_then_serve` to see if any issues arise at one of those points. You can also run `make do_everything_for_me` and cross your fingers though.\n\n## Requirements\n\n- Node\n- Docker\n- Docker Compose\n- Unix-based OS or Dockerize the setup/run in VM\n\n## Queries\n\n### Configuration\n\nThe query configuration is done in a file `./queries/config.yaml`. Below is an explanation of each setting:\n\n```yaml\n# URL to Hasura endpoint\nurl: http://localhost:8085/v1/graphql\n# (Optional) Headers object\nheaders:\n  X-Hasura-Admin-Secret: my-secret\n# Array of query objects\nqueries:\n  # Name identifies it on the output reports\n  - name: SearchAlbumsWithArtist\n    # Duration is a timestring\n    duration: 10s\n    # Requests per second\n    rps: 400\n    # (Optional) Assert that the number of results returned by query matches a number\n    assert:\n      results: 7\n    # Query string\n    query: |\n      query SearchAlbumsWithArtist {\n        albums(where: {title: {_like: \"%Rock%\"}}) {\n          id\n          title\n          artist {\n            name\n            id\n          }\n        }\n      }\n  - name: AlbumByPK\n    duration: 10s\n    rps: 400\n    assert:\n      results: 1\n    query: |\n      query AlbumByPK($id: Int!) {\n        albums_by_pk(id: $id) {\n          id\n          title\n        }\n      }\n    # (Optional) Variables object, easier just to send direct queries\n    variables:\n      id: 5\n```\n\n### Running\n\nYou can call any of the following to run benchmarks:\n\n- `make benchmark_k6`\n- `make benchmark_autocannon`\n- `make benchmark_all_then_serve_reports`\n\nIf you want to run the entire process of benchmarking manually, you can do:\n\n- `make benchmark_k6 benchmark_autocannon serve_reports`\n\nAfter running this process, during the benchmarking, you should have gotten terminal stdout output like this:\n\n| Autocannon                               | K6                               |\n| ---------------------------------------- | -------------------------------- |\n| ![](readme_images/autocannon-output.png) | ![](readme_images/k6-output.png) |\n\nAnd if you chose to run `make benchmark_all_then_serve_reports`, then finally it should be serving the finished reports on `http://localhost:5000`:\n\n| Output                                  | Web index                          |\n| --------------------------------------- | ---------------------------------- |\n| ![](readme_images/npx-serve-output.png) | ![](readme_images/serve-index.png) |\n\nInside of the `autocannon` directory, you should see several HTML files with query names, one per query, with reports like below:\n\n![](readme_images/autocannon-report.png)\n\nClicking on `k6` will take you to the generated plot from the aggregate query data:\n\n![](readme_images/k6s-report.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGavinRay97%2Fgraphql-bench","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGavinRay97%2Fgraphql-bench","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGavinRay97%2Fgraphql-bench/lists"}