-
Notifications
You must be signed in to change notification settings - Fork 0
Setup for remote relationship benchmarks using sportsdb #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: add-remote-relationship-no-op
Are you sure you want to change the base?
Changes from 1 commit
fbb8263
50819b1
ca5d294
053a074
7c33183
f87ccb1
ce965a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| __pycache__ | ||
| test_output |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
|
|
||
|
|
||
| ### Setup ### | ||
|
|
||
| The test setup includes two Postgres databases with [sportsdb](https://www.thesportsdb.com/) schema and data, and two GraphQL engines running on the Postgres databases. Then one of the GraphQL engines is added as a remote schema to another GraphQL engine. | ||
|
|
||
| The data will be same in both the databases. But the tables will reside in different database schema in-order to avoid GraphQL schema conflicts. | ||
|
|
||
| The Python script `test_with_sportsdb.py` will help in setting up the databases, starting the Hasura GraphQL engines, and setting up relationships (both local and remote). This script will run databases on docker, and the GraphQL engines are run with `stack exec`. | ||
|
|
||
| #### Setup GraphQL Engines #### | ||
|
|
||
| Inorder to start GraphQL engines with sportsdb, run | ||
| ```sh | ||
| python3 test_with_sportsdb.py | ||
| ``` | ||
|
|
||
| This will setup Postgres databases and runs the main and remote GraphQL servers | ||
| Pressing enter will teardown both Postgres database | ||
|
|
||
| The initial setup will take some time. The subsequent ones will be faster. The Postgres data is bind mounted from a volume in the host, which will be reused. | ||
|
|
||
| ### Benchmarking ### | ||
|
|
||
| We may employ https://github.com/hasura/graphql-bench to do the benchmarks. | ||
|
|
||
| Create the `bench.yaml` file | ||
| ``` | ||
| - name: events_remote_affilications | ||
| warmup_duration: 60 | ||
| duration: 300 | ||
| candidates: | ||
| - name: hge-with-remote | ||
| url: http://127.0.0.1:8081/v1/graphql | ||
| query: events_remote_affiliations | ||
| queries_file: queries.graphql | ||
| rps: | ||
| - 20 | ||
| - 40 | ||
| ``` | ||
|
|
||
| To run the benchmark, do | ||
| ```sh | ||
| cat bench.yaml | docker run -i --rm -p 8050:8050 -v $(pwd)/queries.graphql:/graphql-bench/ws/queries.graphql hasura/graphql-bench:v0.3 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be convenient if this
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An example benchmark file is included in the directory (example-bench.yaml)
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be nice to remove the inline yaml from the Readme.md and just say "you can copy the example
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like to understand what this is doing a little better. e.g. are we testing throughput? latency at different concurrency levels? If I run this script on a two-core machine will I receive sensible output? etc. I'm sure some of this would be obvious if I got successful output. But maybe there are some docs that could be linked here.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is mainly testing the latency, the average, variance, 95 percentile etc. We can vary the number of request per second though. |
||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import threading | ||
| import socket | ||
|
|
||
|
|
||
| class PortAllocator: | ||
|
|
||
| def __init__(self): | ||
| self.allocated_ports = set() | ||
| self.lock = threading.Lock() | ||
|
|
||
| def get_unused_port(self, start): | ||
| port = start | ||
| if self.is_port_open(port) or port in self.allocated_ports: | ||
| return self.get_unused_port(port + 1) | ||
| else: | ||
| return port | ||
|
|
||
| def is_port_open(self, port): | ||
| with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: | ||
| res = sock.connect_ex(('127.0.0.1', port)) | ||
| return res == 0 | ||
|
|
||
| def allocate_port(self, start): | ||
| with self.lock: | ||
| port = self.get_unused_port(start) | ||
| self.allocated_ports.add(port) | ||
| return port |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| query events_affiliations { | ||
| hge_events(limit: 50){ | ||
| event_status | ||
| last_update | ||
| affiliations_events_by_event_id(limit: 2) { | ||
| affiliation{ | ||
| publisher{ | ||
| publisher_name | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| query events_remote_affiliations { | ||
| hge_events(limit: 50){ | ||
| event_status | ||
| last_update | ||
| remote_affiliations_events_by_event_id(limit: 2) { | ||
| affiliation{ | ||
| publisher{ | ||
| publisher_name | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| requests-cache | ||
| docker | ||
| psycopg2 | ||
| colorama | ||
| inflection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to add instructions for installing dependencies in a virtual environment:
and also to add that
venvdirectory to the gitignore (there is probably a better name than "venv").Also for some reason when I do the above I get some error messages:
...but the overall
pip3command returns 0 status and the script seemed to start fine.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified readme to add the instructions for installing dependencies in a virtual environment
I did not face the bdist_wheel error. Probably because I am using Python 3.7