Skip to content

Simple, distributed rate limiter service built with Go and Redis.

Notifications You must be signed in to change notification settings

mistakenot/ratelimiter

Repository files navigation

Rate limiter

A simple, distributed rate limiter service built with Go, Redis, Terraform and GCP.

Usage

The service exposes a REST api described in the Openapi document. It exposes the following endpoints:

  • GET / and GET /healthz perform a health check and returns 200 if the service can connect to Redis.
  • GET /token/{token_id} will increment the request count for the given token, and will return a response that details the number of tokens remaining, and the number of seconds until reset.

Features

Developers

  • make build builds the binary.
  • make test runs unit tests. Note that this requires an instance of Redis 4 to be running locally.
  • make up starts a full local environment with docker-compose.
  • make deploy runs the cloud init and deployment scripts, powered by Terraform.

Todo

  • There are a few TODO's in the code base for small code improvements. (grep -r TODO .)
  • Functions are deployed to public endpoints, without IAM authentication.
  • Cloud functions have a warm up time that can sometimes be a few seconds. This could be unsuitable in production if consistent latency is important.

About

Simple, distributed rate limiter service built with Go and Redis.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published