NOTE: This repository contains important submodules. Either clone with the
--recursive
flag or do git submodule update --init
after cloning.
A demo of profiling Hasura's graphql-engine
using
ghc-eventlog-socket
and
eventlog-live
. Components:
- A
graphql-engine
executable that has been instrumented usingghc-eventlog-socket
to stream its eventlog over a socket during execution. - Another executable (
eventlog-influxdb
) which reads data from the eventlog socket and inserts it into an InfluxDB database. - A benchmarking tool (in ./bench) copied from the existing
graphql-engine
benchmark suite to generate traffic and make the profile more interesting. - A Grafana instance to view the live eventlog data on a pretty webpage.
- A Docker Compose configuration to tie all of this together and run it all with a single command.
NOTE: There are
linux/amd64
andlinux/arm64
images published on Docker Hub which are already listed in thedocker-compose.yml
, but they may be out of date or otherwise unacceptable, hence these instructions. Skip to Start the containers to use the prebuilt images.
git submodule init --update
before these steps
Begin by building the base benchmarking image:
docker build ./bench/graphql-bench/app -t finleymcilwaine/graphql-bench:base
Then build the benchmarking image:
docker build ./bench -t finleymcilwaine/graphql-bench:main
Now build the base graphql-engine
image:
docker build ./engine -f ./engine/base.Dockerfile -t finleymcilwaine/graphql-engine:base
Then build the graphql-engine
image:
docker build ./engine -f ./engine/main.Dockerfile -t finleymcilwaine/graphql-engine:main
With the images built, the steps below should now work for you.
Run everything with just:
docker compose up
If it's your first time pulling the images, it may take a while (the
graphql-engine
image is about 1GB in compressed size).
The benchmark will just run on a loop. There will be a lot of docker compose log
output from the the PostgreSQL and graphql-engine
instances as they handle the
requests from the benchmark.
Navigate to localhost:3000
for the Grafana instance.
Enter username admin
and password admin
.
The dashboards from ./grafana/dashboards
are
automatically loaded into the instance. To view and interact with them, select
the "Dashboards" tab:
To check the data in the InfluxDB instance directly, you can submit queries from your local command-line, e.g.:
curl -G 'localhost:8086/query?pretty=true&u=admin&p=admin' --data-urlencode "db=eventlog" --data-urlencode "q=SHOW MEASUREMENTS ON eventlog"
Outputs the available measurements.
curl -G 'localhost:8086/query?pretty=true&u=admin&p=admin' --data-urlencode "db=eventlog" --data-urlencode "q=SELECT * FROM \"gauge.eventlog.heap_size\""
Outputs the heap size measurement data.