Skip to content

ExpediaGroup/mittens

Repository files navigation

Mittens

Build Status Go Report Card License GitHub site Docker

Mittens

Mittens is a tool that can be used to warm up an http application over REST or gRPC. For a more detailed overview and the background behind this project you can read our blogpost.

Features

Mittens can run as a standalone command-line tool, as a linked Docker container, or even as a sidecar in Kubernetes.

Its main features are summarised below:

  • Sends requests continuously for X seconds
  • Supports REST and gRPC
  • Supports HTTP/1.1, HTTP/2 and HTTP/2 Cleartext protocol for REST
  • Supports placeholders for random elements in requests
  • Supports concurrent requests
  • Provides files or/and endpoints that can be used as liveness/readiness probes in Kubernetes
  • Allows readiness to fail if unable to warm up target app

Usage

The application receives a number of command-line flags. Read the documentation for more context.

How to build and run

Mittens is written in Go and the simplest way to run it is as a cmd application. It receives a number of command line arguments (see Flags).

The project uses Go Modules. We provide a Makefile which can be used to generate an executable binary and a Dockerfile if you prefer to run using Docker.

Binary

To build the binary make sure you've installed Go 1.21.

Build binary executable & run tests

To build the project run the following:

    make test

This will run the unit tests and generate a binary executable.

Run the executable

To run the binary:

    ./mittens -target-readiness-http-path=/health -target-grpc-port=6565 -max-duration-seconds=60 -concurrency=3 -http-requests=get:/hotel/potatoes -grpc-requests=service/method:"{\"foo\":\"bar\",\"bar\":\"foo\"}"

Docker

Build image

To build a Docker image named mittens:

    make docker

Run container

To run the container:

    docker run mittens:latest -target-readiness-http-path=/health -target-grpc-port=6565 -max-duration-seconds=60 -concurrency=3 -http-requests=get:/hotel/potatoes -grpc-requests=service/method:"{\"foo\":\"bar\",\"bar\":\"foo\"}"

Note: If you use Docker for Mac/Windows you might need to set the target host (target-http-host, target-grpc-host) to host.docker.internal so that your container can resolve localhost. If you use an older version of Docker (< 18.03), the value will depend on your Operating System, e.g. docker.for.mac.host.internal or docker.for.win.host.internal. For target-http-host, you need to prefix the host with the scheme, e.g. http://host.docker.internal.

Contributing

Please refer to our CONTRIBUTING file.

Use Cases

References

Legal

This project is available under the Apache 2.0 License.

Copyright 2024 Expedia, Inc.