vitess-gh/examples/are-you-alive
Matt Lord d0a2245bbc
Update vtctl help output to use double dashes for long flag names (#10405)
* Update vtctl help output to use double dashes for long flag names

* Update any spots missed in examples

* Catch any missed spots in tests

Signed-off-by: Matt Lord <mattalord@gmail.com>
2022-06-01 21:15:15 -04:00
..
build ci: remove remaining references to `go get -u` 2022-03-17 10:40:20 +01:00
cmd/are-you-alive all: fix some typos (#9815) 2022-03-03 07:44:26 -08:00
pkg/client naming: delete old code that was needed for version compatibility + a few other fixes 2022-01-14 16:17:09 -08:00
schemas Update vtctl help output to use double dashes for long flag names (#10405) 2022-06-01 21:15:15 -04:00
.gitignore Use go modules and fix build 2020-02-20 17:05:48 -05:00
Makefile
README.md Inclusive naming: fix are-you-alive example and orc_test.sh 2021-10-27 12:01:20 -07:00
docker-compose.yml Make it easier to test multiple endpoints with aya 2020-05-19 17:57:25 -04:00
go.mod build(deps): bump gopkg.in/yaml.v2 in /examples/are-you-alive 2022-01-04 22:20:51 +00:00
go.sum build(deps): bump gopkg.in/yaml.v2 in /examples/are-you-alive 2022-01-04 22:20:51 +00:00
prometheus.yml

README.md

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 a Vitess Cluster!

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).
  2. Measures all the important things:
    • Client connection errors
    • Write latency
    • Read latency from primaries
    • Read latency from replicas
    • Write errors
    • Read errors on primaries
    • Write errors on replicas
    • Errors in other operations on primaries and replicas (e.g. COUNT)
    • Latency on other operations on primaries and replicas (e.g. COUNT)
    • Data loss (by writing predictable data and testing for that)
  3. Reports all these metrics to Prometheus.

That's it!

Usage

First, initialize your database with the correct schemas.

Run are-you-alive --help for usage. You can use the command line flags to control the dataset size, whether to target reads at primaries 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 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.

Test Specific Tablet Types

Queries can target specific tablet types. In the configuration file you simply need to, for example, put "@primary" or "@replica" on the ends of your connection strings.

Push to Registry

If you have push access to the planetscale public registry, you can use the following commands to build and push the image:

make build
make push