• Stars
    star
    386
  • Rank 110,565 (Top 3 %)
  • Language
    Go
  • License
    MIT License
  • Created almost 5 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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/slidingwindow

Design

slidingwindow is an implementation of the scalable rate limiting algorithm used by Kong.

Suppose we have a limiter that permits 100 events per minute, and now the time comes at the "75s" point, then the internal windows will be as below:

slidingwindow

In this situation, the limiter has permitted 12 events during the current window, which started 15 seconds ago, and 86 events during the entire previous window. Then the count approximation during the sliding window can be calculated like this:

count = 86 * ((60-15)/60) + 12
      = 86 * 0.75 + 12
      = 76.5 events

Test Utility

prom_reports

For details, see testutil.

Documentation

For usage and examples see the Godoc.

License

MIT

More Repositories

1

timingwheel

Golang implementation of Hierarchical Timing Wheels.
Go
652
star
2

validating

A Go library for validating structs, maps and slices.
Go
221
star
3

caddy-ext

Various Caddy v2 extensions (a.k.a. modules).
Go
93
star
4

kun

A communication toolkit for Go services.
Go
89
star
5

pdfbookmarker

Add bookmarks into PDF using PyPDF2
Python
80
star
6

protoc-go-plugins

Some useful Go's protoc plugins.
Go
57
star
7

forum

a simple forum based on web.py
Python
40
star
8

goodtimer

Golang timer for humans.
Go
39
star
9

grpc-pytools

Some useful Python's gRPC tools.
Python
28
star
10

micron

A minimal implementation of the fault-tolerant job scheduler.
Go
22
star
11

rpubsub

Reliable implementation of Publish–subscribe messaging pattern backed by Redis Streams.
Go
20
star
12

caddy-mesh

Caddy service mesh based on the host/node architecture.
Go
20
star
13

ratelimiter

A distributed token-bucket rate limiter backed by Redis.
Go
19
star
14

dbtest

Database testing made easy in Go.
Go
18
star
15

resource

A Python library concentrated on the Resource layer of RESTful APIs.
Python
18
star
16

superdiscoverer

A Supervisor backed service discoverer for automatic service-discovery.
Go
15
star
17

structool

A codec for Go structs with support for chainable encoding/decoding hooks.
Go
12
star
18

hats

Communicating with NATS using the HTTP protocol.
Go
12
star
19

pyprof-timer

A timer for profiling a Python function or snippet.
Python
8
star
20

crest

A simple REST client for Python.
Python
8
star
21

fieldmask

Partial reads and updates made easy for REST APIs in Go.
Go
6
star
22

easyconfig

A simple library for loading configurations easily in Python, inspired by `flask.config`.
Python
5
star
23

pymwa

MetaWeblog API (MWA) implemented in Python
Python
4
star
24

appx

An application framework that makes it easy to build pluggable and reusable applications.
Go
3
star
25

PiL3-notes

《Lua 程序设计 3》的读书笔记
3
star
26

gopt

Generic Functional Options for Go.
Go
3
star
27

pyawk

A simple variant of AWK in Python.
Python
2
star
28

orchestrator

A Go library for service orchestration.
Go
2
star
29

olaf

Configuration Manager for Caddy.
Go
2
star
30

miniweb

miniweb is a minimal web framework for Python, inspired by web.py.
Python
2
star
31

workitem

A specific audit-system with MVC-like architecture, and it's demo.
Python
1
star
32

cooly

A utility that helps you deploy Python projects.
Python
1
star
33

jsonsir

A serializer for JSON-like data in Python.
Python
1
star
34

gotask

The minimal Go library for implementing an asynchronous task worker.
Go
1
star
35

chatinhttp

Chat in HTTP between client and server.
Python
1
star
36

goku

Go
1
star
37

jsonform

Form validation for JSON-like data (i.e. document) in Python.
Python
1
star
38

vext

Extension validator factories for validating.
Go
1
star
39

gosignal

A Golang library for in-process signal dispatching.
Go
1
star