A little ping pong service that implements rate limiting with golang

Build Status

Fred the Guardian

Introduction

Writing a little ping pong service that implements rate limiting with the programming language golang.

Requirements

Web application

  • Runs in a docker container
  • implements the following throttling policy:
    • maximum of 10 “ping” requests are allowed per x-secret-key and per minute
    • maximum of 2 requests per second are allowed, regardless of the x-secret-key

CLI tool

  • Sends 1 “ping” request per second
  • Stops sending “ping” requests when limit of allowed requests is reached
  • Starts sending “ping” requests again when throttling is expired

API

Endpoint /ping

Request

Payload example:

{ "request": "ping" }

Required headers:

x-secret-key: str

“x-secret-key”: a random string

Response

response payload (when not throttled):

{ "response": "pong" }

Expected response payload(when throttled):

{ "message": "request throttled request", "throttle_age": int }

Response attributes:

“message” - friendly message explaining what is happening

“throttle_age” - the elapsed time(in seconds) since the throttling has been applied

Administration

There a couple of web servers and ingress controllers out there they implement different rate limiting algorithm already.

  • apache
  • nginx (experience with)
  • kong
  • istio
  • ...

In my opinion its better to use one of those above if rate limiting itself is not the core of the companies business.

Development

This would be the road map for a self developed rate limiting service.

To do

Version 1

  • implement the ping web server API without rate limiting
  • implement the pong client interface
  • setup local minibike for first deployment

Version 2

  • implement the first simple rate limiting based on in memory counters

Version 3

  • implement the rate limiting with counters stored in redis

Version 4

Version 5

Version 6

Version 7

Similar Resources

Simple-request-limiter - Example of limiting API requests using standard Go library

Route: http://localhost:8080/urls example of body in POST request that was used:

Feb 2, 2022

Ping library for Golang with multi-host support

pingo Fast and lightweight ping library for Golang with multi-host support. Features ICMP sockets: UDP port 0 means "let the kernel pick a free number

Nov 9, 2022

ping 和 http get 请求探测 适配 nightingale

n9e-probe 功能 ping 和 http get 请求探测 适配 nightingale 指标 ping metric 说明 ping.latency ping 请求的延迟,单位是毫秒。-1 表示 ping 不通 tag 说明 ip 探测的目标 ip region 如果配置了,则插入 reg

Sep 27, 2022

🚥 Yet another pinger: A high-performance ICMP ping implementation build on top of BPF technology.

yap Yet-Another-Pinger: A high-performance ICMP ping implementation build on top of BPF technology. yap uses the gopacket library to receive and handl

Nov 9, 2022

DNS Ping: to check packet loss and latency issues with DNS servers

DNSping DNS Ping checks packet loss and latency issues with DNS servers Installation If you have golang, easiest install is go get -u fortio.org/dnspi

Nov 18, 2022

[FORK] ICMP Ping library for Go

forked from go-ping/ping go get -u github.com/gandaldf/ping go-ping A simple but powerful ICMP echo (ping) library for Go, inspired by go-fastping. He

Oct 21, 2021

Prometheus exporter for ping metrics such as RTT, packet loss, and jitter to any number of hosts.

ping_exporter Command ping_exporter provides a Prometheus exporter for ping metrics such as RTT, packet loss, and jitter to any number of hosts. Usage

Sep 24, 2022

Implementation of Minecraft protocols : ping, query and icon.

Implementation of Minecraft protocols : ping, query and icon.

mcutils - Implementation of Minecraft protocols in Go Informations General All protocols are implemented in Go, without any external dependency. All p

Dec 19, 2022

PinGo is a standalone and feature-rich tool for common IP-based reachability checking tasks. Ping or Trace and Observe in real-time the statistics.

pingo As a network champion from designing and implementing to troubleshooting large scale networks - I know that is usually not easy for administrato

Sep 26, 2022
Comments
  • Set k8s cpu and memory resource limits

    Set k8s cpu and memory resource limits

    Its a good practice to set resource limits in kubernetes to avoid let kubernetes manage the cpu and memory resources of a cluster properly.

    The values are just kind of defaults and has to be adjusted after profiling or monitoring experiences of the service.

  • Add local deployment instruction to set kubeconfig

    Add local deployment instruction to set kubeconfig

    In the 'deploy/local' folder is a configuration file for kubectl. Add instrcution how to configure kubectl to use the 'kubectl.config' file by setting the KUBECONFIG environment variable.

    See the README

C-ping is a very simple and small ping tool that sends ICMP Echo datagram to a host.

C-ping is a very simple and small ping tool that sends ICMP Echo datagram to a host.

Aug 9, 2022
Golang implementation of Sliding Window Algorithm for distributed rate limiting.
Golang implementation of Sliding Window Algorithm for distributed rate limiting.

slidingwindow Golang implementation of Sliding Window Algorithm for distributed rate limiting. Installation $ go get -u github.com/RussellLuo/slidingw

Dec 27, 2022
HTTP rate limiting module for Caddy 2

This module implements both internal and distributed HTTP rate limiting. Requests can be rejected after a specified rate limit is hit.

Jan 3, 2023
Light weight http rate limiting proxy

Introduction Light weight http rate limiting proxy. The proxy will perform rate limiting based on the rules defined in the configuration file. If no r

Dec 23, 2022
A Caddy v2 extension to apply rate-limiting for HTTP requests

ratelimit A Caddy v2 extension to apply rate-limiting for HTTP requests. Installation $ xcaddy build --with github.com/owlwang/caddy-ratelimit Caddyfi

Jan 28, 2022
This small service will pong the headers provided in the request as json response

This small service will pong the headers provided in the request as json response server will run on port 5000 content will be served at path /request

Dec 9, 2021
Pacemaker - Rate limit library. Currently implemented rate limits are

PaceMaker Rate limit library. Currently implemented rate limits are Fixed window

Nov 5, 2022
Redis-rate-limiter - An abstraction over redist rate/v9 package

RATE_LIMIT_POC Notes This POC is based on github.com/go-redis/redis_rate/v9 pack

Feb 14, 2022
Gcra - Package gcra implements the generic cell rate algorithm

gcra Package gcra implements the generic cell rate algorithm (GCRA). Example opt

Jan 23, 2022
Go forward proxy with bandwidth limiting.
Go forward proxy with bandwidth limiting.

Goforward Go forward proxy with rate limiting. The code is based on Michał Łowicki's 100 LOC forward proxy. Download Releases can be downloaded from h

Nov 13, 2022