{"id":41319916,"url":"https://github.com/arivum/dynratelimiter","last_synced_at":"2026-01-23T05:50:20.323Z","repository":{"id":36979648,"uuid":"417847954","full_name":"arivum/dynratelimiter","owner":"arivum","description":"Rate limiting based on resource usage - either RAM and/or CPU.","archived":false,"fork":false,"pushed_at":"2023-03-01T04:02:44.000Z","size":9929,"stargazers_count":1,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-22T17:02:07.509Z","etag":null,"topics":["ebpf","golang","kubernetes","rate-limiting","reliability","resilience","resource-management"],"latest_commit_sha":null,"homepage":"https://arivum.de","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arivum.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-10-16T14:13:59.000Z","updated_at":"2023-04-28T09:56:46.000Z","dependencies_parsed_at":"2023-09-25T06:58:09.641Z","dependency_job_id":null,"html_url":"https://github.com/arivum/dynratelimiter","commit_stats":{"total_commits":52,"total_committers":3,"mean_commits":"17.333333333333332","dds":"0.40384615384615385","last_synced_commit":"1724ee1bc7213184eaeb09ba17daebe0991bd3a6"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/arivum/dynratelimiter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arivum%2Fdynratelimiter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arivum%2Fdynratelimiter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arivum%2Fdynratelimiter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arivum%2Fdynratelimiter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arivum","download_url":"https://codeload.github.com/arivum/dynratelimiter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arivum%2Fdynratelimiter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28681361,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T05:48:07.525Z","status":"ssl_error","status_checked_at":"2026-01-23T05:48:07.129Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ebpf","golang","kubernetes","rate-limiting","reliability","resilience","resource-management"],"created_at":"2026-01-23T05:50:15.431Z","updated_at":"2026-01-23T05:50:20.307Z","avatar_url":"https://github.com/arivum.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DynRateLimiter\n\n### About\n![Maintainer](https://img.shields.io/badge/maintainer-arivum-blue)\n![Release](https://img.shields.io/github/v/release/arivum/dynratelimiter)\n![GitHub go.mod Go version (branch)](https://img.shields.io/github/go-mod/go-version/arivum/dynratelimiter) \n![GitHub](https://img.shields.io/github/license/arivum/dynratelimiter)\n\n### CI/CD\n![Go](https://img.shields.io/github/workflow/status/arivum/dynratelimiter/Go?label=Go)\n![Docker](https://img.shields.io/github/workflow/status/arivum/dynratelimiter/Docker%20Image%20CI?label=Docker)\n![Helm](https://img.shields.io/github/workflow/status/arivum/dynratelimiter/Helm?label=Helm)\n\n## Table of contents\n* [Introduction](#introduction)\n* [Run locally ...](#run-locally-)\n  + [... via Go install](#-via-go-install)\n  + [... by downloading latest release](#-by-downloading-latest-release)\n  + [... and show usage](#-and-show-usage)\n  + [... with configuration file](#-with-configuration-file)\n* [Inject into Kubernetes pods](#inject-into-kubernetes-pods)\n  + [Possible annotations for controlling DynRateLimiter](#possible-annotations-for-controlling-dynratelimiter)\n* [Development](#development)\n  + [Run and Test locally](#run-and-test-locally)\n\n## Introduction\n\nRate limiting based on resource usage - either RAM and/or CPU. If resource usage rises above a defined threshold, rate limiting restricts further requests to avoid resource exhaustion by incoming request processing.\n\nAn initial rate limit is used to \"slow start\" the maximum allowed requests.\n\nAs shown in the figures below, DynRateLimiter can increase the total thoughput of requests in high load or high memory server scenarios.\n\n![](tests/loadtest/base.png)\n![](tests/loadtest/spike.png)\n\n## Run locally ...\n\n### ... via Go install\n```bash\ngo install github.com/arivum/dynratelimiter@v0.1.5\n```\n\n### ... by downloading latest release\n```bash\nsudo wget https://github.com/arivum/dynratelimiter/releases/download/v0.1.5/dynratelimiter -O /usr/bin/dynratelimiter\nsudo chmod +x /usr/bin/dynratelimiter\n```\n\n### ... and show usage\n```bash\ndynratelimiter -h\n\nUsage of dynratelimiter:\n  -conf string\n        Path to config file (default \"dynratelimit.yaml\")\n  -cpu string\n        Rate limiting threshold based on CPU usage. Notation must be either e.g. 80%% or 300ms\n  -init-rate-limit int\n        Initial rate limit. It is recommended to start small. (default 10)\n  -loglevel string\n        Set loglevel to one of [info, debug, warn, error, trace] (default \"info\")\n  -ram string\n        Rate limiting threshold based on RAM usage. Notation must be either e.g. 80%%, 2048MiB, 2048MB, 2GiB or 2GB\n  -v    Display version\n```\n\n### ... with configuration file\n```yaml\n# configure thresholds that trigger rate limiting, once hit\nthresholds:\n  # initial request limit. \"slow-starts\" rate limiting\n  initialRateLimit: 10\n  # specify either:\n  # * maximum cpu core fraction: e.g. 1core, 250m, 250mcores, 250000µ, 250000µcores\n  # * maximum usage: e.g 80%\n  cpu: 80%\n  # specify either:\n  # * total maximum RAM size: 4G, 4GB, 4GiB, 4096M, 4096MiB\n  # * maximum percentage: 80%\n  ram: 80%\n# specify a list of interfaces to attach the ratelimiter.\n# If list is empty, the ratelimiter will be attached to all interfaces in the current netns\ninterfaces:\n  - lo\n# specify logging options\nlogging:\n  # loglevel must be one of [info, debug, warn, error, trace].\n  # default: info\n  level: debug\n  # format can be one of [gofmt, json]\n  # default: gofmt\n  format: gofmt\n```\n\n## Inject into Kubernetes pods\n\nTo inject the DynRateLimiter into Kubernetes pods, deploy the DynRateLimiter Operator via Helm.\n\n```bash\n# Add the repository to helm\nhelm repo add arivum https://arivum.github.io/helm-charts\nhelm repo update\n\n# Create your my_values.yaml to adjust default values for the operator\ntouch my_values.yaml\n\n# Deploy the operator\nhelm upgrade --install -f my_values.yaml dynratelimiter-operator arivum/dynratelimiter-operator\n\n# Show if operator came up successfully\nkubectl --namespace dynratelimiter-operator get pods\n```\n\nFor information about all settings for the Helm chart read [values.yaml](./build/helm/dynratelimiter-operator/values.yaml)\n\nAfter the operator is up and running, you can inject the DynRateLimiter into various pods by simply settings pod annotations.\n\n```yaml\napiVersion: v1\nkind: Pod\nmetadata:\n  name: get-injected\n  annotations: \n    dynratelimiter.arifin.io/inject: \"enabled\"\n    thresholds.dynratelimiter.arifin.io/cpu: \"80%\"\nspec:\n  containers:\n  - name: main-container\n    image: registry.hub.docker.com/library/busybox\n    command: [\"/bin/sh\"]\n    args: [\"-c\", \"while true; do sleep 1; date; done\"]\n    resources:\n      requests:\n        memory: 100M\n        cpu: 100m\n      limits:\n        memory: 100M\n        cpu: 100m\n```\n\n### Possible annotations for controlling DynRateLimiter\n\n| Annotation | Possible values |Description |\n| ---------- | --------------- | ---------- |\n| `dynratelimiter.arifin.io/inject` | `enabled` | Enable injection for this pod |\n| `dynratelimiter.arifin.io/loglevel` | `info` (default), `debug`, `warn`, `error`, `trace` | Set logging level for the DynRateLimiter |\n| `thresholds.dynratelimiter.arifin.io/cpu` | `80%`, `300m`, `300mcores` | Specify (percentual or absolute) CPU threshold that triggers rate limiting, once hit. |\n| `thresholds.dynratelimiter.arifin.io/ram` | `80%`, `2048MB`, `2048MiB`, `2GiB`, `2GB` | Specify (percentual or absolute) RAM threshold that triggers rate limiting, once hit. |\n\n## Development\n### Run and Test locally\n\n* Build eBPF object file and go binary (including binary representation of the eBPF object)\n  ```bash\n  go get github.com/cilium/ebpf/cmd/bpf2go\n  make build\n  make build-stressme\n  ```\n* Run with the sample configuration\n  ```bash\n  # run included stressme server e.g. with high load cpu profile\n  ./stressme -cpu \u0026\n\n  # run dynamic rate limiter. eBPF function gets attached to lo interface\n  # if example configuration stays untouched\n  sudo ./dynratelimiter -conf examples/dynratelimit.yaml\n  \n  # simple loadtest using curl.\n  # for more advanced load tests see ./tests/loadtests\n  for i in {0..100}; do curl -q localhost:2000 \u0026; done\n  ```\n\n\u003c!-- ### Rate limit calculation\n```math\n\\begin{aligned}\nt \\in [0,1]     \u0026\u0026\u0026\u0026\u0026\u0026\u0026   \\text{resource threshold} \\\\\nr \\in \\N        \u0026\u0026\u0026\u0026\u0026\u0026\u0026   \\text{rate limit} \\\\\na \\in \\N        \u0026\u0026\u0026\u0026\u0026\u0026\u0026   \\text{accepted requests} \\\\\nm_{max}         \u0026\u0026\u0026\u0026\u0026\u0026\u0026   \\text{available resource maximum} \\\\\nm_{cur}         \u0026\u0026\u0026\u0026\u0026\u0026\u0026   \\text{current resource usage} \\\\\n\\text{}\n\\end{aligned}\n```\n```math\n\\Delta r = \\left\\{\n  \\begin{array}{ c l }\n    r \\cdot (t-\\frac{m_{cur}}{m_{max}}) \u0026 \\quad \\textrm{if } (a \\geq 0.8\\cdot r \\textbf{ || } m_{cur} \\geq t \\cdot  m_{max}) \\\\\n    0                 \u0026 \\quad \\textrm{otherwise}\n  \\end{array}\n\\right.\n``` --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farivum%2Fdynratelimiter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farivum%2Fdynratelimiter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farivum%2Fdynratelimiter/lists"}