{"id":19888623,"url":"https://github.com/postgrest/postgrest-benchmark","last_synced_at":"2025-07-03T05:01:49.673Z","repository":{"id":82625139,"uuid":"280705152","full_name":"PostgREST/postgrest-benchmark","owner":"PostgREST","description":"Reproducible benchmark for PostgREST","archived":false,"fork":false,"pushed_at":"2025-05-28T03:08:15.000Z","size":401,"stargazers_count":4,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-29T12:50:43.945Z","etag":null,"topics":["benchmark","nix","nixops","postgresql","postgrest"],"latest_commit_sha":null,"homepage":"","language":"Nix","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PostgREST.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-07-18T17:25:29.000Z","updated_at":"2025-05-28T03:08:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"8ac9f0cf-59e9-4c02-a24a-b8704ff3625e","html_url":"https://github.com/PostgREST/postgrest-benchmark","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/PostgREST/postgrest-benchmark","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PostgREST%2Fpostgrest-benchmark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PostgREST%2Fpostgrest-benchmark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PostgREST%2Fpostgrest-benchmark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PostgREST%2Fpostgrest-benchmark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PostgREST","download_url":"https://codeload.github.com/PostgREST/postgrest-benchmark/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PostgREST%2Fpostgrest-benchmark/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263264641,"owners_count":23439246,"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":["benchmark","nix","nixops","postgresql","postgrest"],"created_at":"2024-11-12T18:07:44.679Z","updated_at":"2025-07-03T05:01:49.587Z","avatar_url":"https://github.com/PostgREST.png","language":"Nix","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PostgREST Benchmark\n\nReproducible benchmark for PostgREST by using [Nix](https://nixos.org/) and [NixOps](https://github.com/NixOS/nixops).\n\nNixOps provisions AWS EC2 instances on a dedicated VPC and deploys the different components for load testing.\n\nThe default setup includes:\n\n- A `m5a.8xlarge` PostgreSQL server instance. Tuned according to [PGTune](https://pgtune.leopard.in.ua/) recommendations.\n- A `t3a.nano` client instance with PostgREST + Nginx. The size of this EC2 instance, can be modified with environment variables.\n  + PostgREST pool size is tuned according to the EC2 instance size.\n- A `t3a.nano` client instance with k6. The size of this EC2 instance, can be modified with environment variables.\n- All networking is setup so the client instances can reach the server instance.\n\n## Requirements\n\n- [Nix](https://nixos.org/).\n\n- [AWS](https://aws.amazon.com) account with an `~/.aws/credentials` file in place (can be created with `aws-cli`). The \"default\" profile is picked up by default but you can change it by doing:\n  ```\n  export PGRSTBENCH_AWS_PROFILE=\"another_profile\"\n  ```\n\n## Quickstart\n\nRun `nix-shell`. This will provide an environment where all the dependencies are available.\n\n```\n$ nix-shell\n\u003e\n```\n\nDeploy with:\n\n```\n$ postgrest-bench-deploy\n\npgrstBenchVpc.....\u003e creating vpc under region us-east-2\n..\n\npg................\u003e activation finished successfully\npgrstbench\u003e deployment finished successfully\n\n# this command will take a couple minutes, it will deploy the client and server AWS machines VPC stuff\n```\n\nRun a `k6` test on the client instance and get the output:\n\n```\n$ postgrest-bench-k6 20 k6/GETSingle.js\n```\n\nDestroy all the setup and the AWS instances:\n\n```\n$ postgrest-bench-destroy\n```\n\n## SSH\n\nTo connect to the PostgreSQL instance:\n\n```\n$ postgrest-bench-ssh pg\n\n# Check the installed services\n$ systemctl list-units\n\n## connect to postgres\n$ psql -U postgres\n$ \\d\n```\n\nThe postgresql server comes loaded with the [chinook database](https://github.com/xivSolutions/ChinookDb_Pg_Modified).\n\nTo connect to the PostgREST instance:\n\n```\n$ postgrest-bench-ssh pgrst\n\n# Check the installed services\n$ systemctl list-units\n\n# Do a request\n$ curl localhost:80/artist\n```\n\nYou can also get info (like the IPs) of the instances with:\n\n```\n$ postgrest-bench-info\n```\n\n## K6\n\nK6 runs on the client instance, but you can get the output of the load test on your machine:\n\n```\n## k6 will run with 10 VUs on the AWS client instance and load test the t3anano instance with the local k6/GETSingle.js script\n$ postgrest-bench-k6 20 k6/GETSingle.js\n\n## You will see the k6 logo and runs here\n```\n\nThere are different scripts on `k6/` which test different PostgREST requests.\n\n## Pgbench\n\npgbench also runs on the client instance, you can get its output with:\n\n```\n$ postgrest-bench-pgbench pgbench/GETSingle.sql\n```\n\nThe `GETSingle.sql` runs an equivalent SQL statement to what PostgREST generates for `GETSingle.js`. The motivation for this comparison is to see how much PostgREST performance differs from direct SQL connections.\n\n## Varying Scripts\n\nThere are scripts that help with varying the environment while load testing. You can use these to get a report once the command finishes running:\n\nRun k6 with a different qty of VUs:\n\n```\n$ postgrest-bench-k6-vary k6/GETSingle.js\n```\n\nRun k6 with varied vus and with varied ec2 instances for the client and pgrst instances (this will involve reprovisioning/redeploying the client and pgrst instance, it will take a while):\n\n```\n$ postgrest-bench-vary-instances postgrest-bench-k6-vary k6/GETSingle.js \u003e K6_GET_SINGLE.txt\n```\n\n## Different Setups\n\n### Nginx included (default)\n\nTo load test with nginx included do:\n\n```bash\nexport PGRSTBENCH_WITH_NGINX=\"true\"\npostgrest-bench-deploy\n```\n\nTo only have PostgREST listening directly on port 80:\n\n```bash\nexport PGRSTBENCH_WITH_NGINX=\"false\"\npostgrest-bench-deploy\n```\n\n### Unix socket (default)\n\nTo load test connecting pgrest to pg with unix socket, and pgrest to nginx with unix socket.\n\n```bash\nexport PGRSTBENCH_WITH_UNIX_SOCKET=\"true\"\npostgrest-bench-deploy\n```\n\nTo use tcp instead, you can do:\n\n```bash\nexport PGRSTBENCH_WITH_UNIX_SOCKET=\"false\"\npostgrest-bench-deploy\n```\n\n### Separate PostgreSQL instance (default)\n\nTo load test with a pg on a different ec2 instance.\n\n```bash\nexport PGRSTBENCH_SEPARATE_PG=\"true\"\npostgrest-bench-deploy\n```\n\nTo use the same instance for both PostgreSQL and PostgREST.\n\n```bash\nexport PGRSTBENCH_SEPARATE_PG=\"false\"\npostgrest-bench-deploy\n```\n\n### Different EC2 instance types\n\nTo change PostgreSQL and PostgREST EC2 instance types(both `t3a.nano` by default):\n\n```bash\nexport PGRSTBENCH_PG_INSTANCE_TYPE=\"t3a.xlarge\"\nexport PGRSTBENCH_PGRST_INSTANCE_TYPE=\"t3a.xlarge\"\n\npostgrest-bench-deploy\n```\n\n## Limitations\n\n- The instances tested for this benchmark are the `t3a` series and the `m5a` series.\n  ARM-based instances, haven't been tested.\n\n## Other benchmarks\n\n+ [majkinetor/postgrest-test](https://github.com/majkinetor/postgrest-test): PostgREST benchmark on Windows.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostgrest%2Fpostgrest-benchmark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpostgrest%2Fpostgrest-benchmark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostgrest%2Fpostgrest-benchmark/lists"}