-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Add are you alive example #5646
Changes from 6 commits
615dc52
fa96b50
ec2a1ce
0ac2441
1809bfc
05affe0
cc7ea16
86ceabe
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 @@ | ||
vendor | ||
are-you-alive |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# We are using the public "planetscale-vitess" registry for this | ||
NAME := "us.gcr.io/planetscale-vitess/are-you-alive" | ||
TAG := $$(git log -1 --pretty=%H) | ||
IMG := ${NAME}:${TAG} | ||
LATEST := ${NAME}:latest | ||
|
||
.PHONY: build push | ||
|
||
build: | ||
@docker build -f build/release/Dockerfile -t ${IMG} . | ||
@docker tag ${IMG} ${LATEST} | ||
|
||
push: | ||
@docker push ${IMG} | ||
@docker push ${LATEST} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Are You Alive? | ||
|
||
What does it mean to be alive? | ||
|
||
Well we don't know what it means for you, but we know what it means for our | ||
Cloud Database! | ||
|
||
This project contains a simulated client application that can be used to measure | ||
the health of a Vitess cluster over time. | ||
|
||
## Design | ||
|
||
For now, there is a specific database schema and vschema that you must apply to | ||
the database that you are using for this test. | ||
|
||
This client application: | ||
|
||
1. Hammers the database with random data (not a load test though). | ||
1. Measures all the important things: | ||
- Client connection errors | ||
- Write latency | ||
- Read latency from masters | ||
- Read latency from replicas | ||
- Write errors | ||
- Read errors on masters | ||
- Write errors on replicas | ||
- Errors in other operations on masters and replicas (e.g. COUNT) | ||
- Latency on other operations on masters and replicas (e.g. COUNT) | ||
- Data loss (by writing predictable data and testing for that) | ||
1. Reports all these metrics to Prometheus. | ||
|
||
That's it! Keep it as simple and generic as possible, and someday our customers | ||
can use this to test their clusters too! | ||
|
||
sverch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
## Usage | ||
|
||
First, [initialize your database with the correct schemas](schemas/README.md). | ||
|
||
Run `are-you-alive --help` for usage. You can us the command line flags to | ||
control the dataset size, whether to target reads at masters and replicas, your | ||
mysql connection string, and the rate at which to send requests. | ||
|
||
Example: | ||
|
||
``` | ||
./are-you-alive --mysql_connection_string <mysql_connection_string> | ||
``` | ||
|
||
Where `<mysql_connection_string>` points to the database you are trying to test, | ||
and everything else will be set to defaults. | ||
|
||
## Building | ||
|
||
``` | ||
go build vitess.io/vitess/examples/are-you-alive/cmd/are-you-alive | ||
``` | ||
|
||
## Testing | ||
|
||
First, [install docker compose](https://docs.docker.com/compose/install/) and | ||
make sure it's working. Then run: | ||
|
||
``` | ||
docker-compose build | ||
docker-compose up | ||
``` | ||
|
||
This will create a local mysqld and a local prometheus to scrape the app. It | ||
will also start the app with the `--initialize` flag which tells it to | ||
automatically create the test database. You might have to run this twice to | ||
give mysql a chance to do its first initialization. | ||
|
||
After you run docker compose, navigate to `http://localhost:9090` to see | ||
Prometheus and `http://localhost:8080/metrics` to see the raw metrics being | ||
exported. | ||
|
||
## Push to Registry | ||
|
||
``` | ||
make build | ||
make push | ||
``` | ||
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. do we want to include this? most people won't have the necessary access. 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'll add a note about access here, but I think documenting the commands makes sense. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Use a [multi stage | ||
# build](https://docs.docker.com/develop/develop-images/multistage-build/) to | ||
# build [reflex](https://github.com/cespare/reflex), a tool that will allow us | ||
# to automatically rerun the project when any files change. | ||
FROM golang:1.12.5 AS build | ||
# Build reflex as a static binary (CGO_ENABLED=0) so we can run it in our final | ||
# container. | ||
RUN CGO_ENABLED=0 go get -v github.com/cespare/reflex | ||
|
||
FROM golang:1.12.5-alpine AS runtime | ||
COPY --from=build /go/bin/reflex /go/bin/reflex | ||
COPY reflex.conf / | ||
ENTRYPOINT ["/go/bin/reflex", "-c", "/reflex.conf"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Rerun "go run" every time a ".go" file changes. | ||
-r '(\.go$)' -s -- go run vitess.io/vitess/examples/are-you-alive/cmd/are-you-alive --initialize |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM golang:1.12.5 AS build | ||
COPY . /go/src/vitess.io/vitess/examples/are-you-alive | ||
RUN CGO_ENABLED=0 go install vitess.io/vitess/examples/are-you-alive/cmd/are-you-alive | ||
|
||
FROM debian:stretch-slim AS runtime | ||
COPY --from=build /go/bin/are-you-alive /go/bin/are-you-alive | ||
ENTRYPOINT ["/go/bin/are-you-alive"] |
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.
Maybe delete these lines?
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.
Changing from "Cloud Database" to "Vitess Cluster".