Skip to content

Commit 10ebf70

Browse files
authored
Implement dynamic tier-based rate limiting (eclipse-openvsx#1569)
* add dyanmic tier-based rate-limiting * update ratelimit header names * only use standard Retry-After header
1 parent 92fdd64 commit 10ebf70

69 files changed

Lines changed: 5617 additions & 71 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docker-compose.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ services:
6060
command: redis-server /etc/redis.conf
6161
volumes:
6262
- ./redis.conf:/etc/redis.conf
63-
- /redis/node-1:/data
63+
- ./data/redis/node-1:/data
6464
environment:
6565
- REDISCLI_AUTH=openvsx
6666
healthcheck:
@@ -81,7 +81,7 @@ services:
8181
command: redis-server /etc/redis.conf
8282
volumes:
8383
- ./redis.conf:/etc/redis.conf
84-
- /redis/node-2:/data
84+
- ./data/redis/node-2:/data
8585
environment:
8686
- REDISCLI_AUTH=openvsx
8787
healthcheck:
@@ -102,7 +102,7 @@ services:
102102
command: redis-server /etc/redis.conf
103103
volumes:
104104
- ./redis.conf:/etc/redis.conf
105-
- /redis/node-3:/data
105+
- ./data/redis/node-3:/data
106106
environment:
107107
- REDISCLI_AUTH=openvsx
108108
healthcheck:
@@ -123,7 +123,7 @@ services:
123123
command: redis-server /etc/redis.conf
124124
volumes:
125125
- ./redis.conf:/etc/redis.conf
126-
- /redis/node-4:/data
126+
- ./data/redis/node-4:/data
127127
environment:
128128
- REDISCLI_AUTH=openvsx
129129
healthcheck:
@@ -144,7 +144,7 @@ services:
144144
command: redis-server /etc/redis.conf
145145
volumes:
146146
- ./redis.conf:/etc/redis.conf
147-
- /redis/node-5:/data
147+
- ./data/redis/node-5:/data
148148
environment:
149149
- REDISCLI_AUTH=openvsx
150150
healthcheck:
@@ -165,7 +165,7 @@ services:
165165
command: redis-server /etc/redis.conf
166166
volumes:
167167
- ./redis.conf:/etc/redis.conf
168-
- /redis/node-6:/data
168+
- ./data/redis/node-6:/data
169169
environment:
170170
- REDISCLI_AUTH=openvsx
171171
healthcheck:
@@ -223,7 +223,7 @@ services:
223223
profiles:
224224
- openvsx
225225
- backend
226-
226+
227227
webui:
228228
image: node:18
229229
working_dir: /app

redis.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ appendonly yes
77
maxmemory 64mb
88
maxmemory-policy allkeys-lru
99
user default off
10-
user openvsx on >openvsx ~* +@all
10+
user openvsx on >openvsx ~* +@all allchannels
1111
masteruser openvsx
1212
masterauth openvsx

server/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ dependencies {
104104

105105
implementation libs.bucket4j.spring
106106
implementation libs.bucket4j.redis
107+
implementation libs.ipaddress
107108

108109
implementation libs.jobrunr.spring
109110

server/gradle/libs.versions.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
aws = "2.29.29"
33
azure = "12.23.0"
44
bouncycastle = "1.80"
5-
bucket4j-spring = "0.12.7"
5+
bucket4j-spring = "0.12.10"
66
bucket4j = "8.10.1"
77
commons-lang3 = "3.20.0"
88
flyway = "11.20.3"
99
gatling = "3.14.9"
1010
gcloud = "2.62.1"
1111
hibernate = "6.6.42.Final"
12+
ipaddress = "5.5.1"
1213
jackson = "2.15.4"
1314
java = "25"
1415
jaxb-api = "2.3.1"
@@ -50,6 +51,7 @@ flyway-database-postgresql = { module = "org.flywaydb:flyway-database-postgres
5051
gatling-app = { module = "io.gatling:gatling-app", version.ref = "gatling" }
5152
gatling-core = { module = "io.gatling:gatling-core", version.ref = "gatling" }
5253
google-cloud-storage = { module = "com.google.cloud:google-cloud-storage", version.ref = "gcloud" }
54+
ipaddress = { module = "com.github.seancfoley:ipaddress", version.ref = "ipaddress"}
5355
jackson-annotations = { module = "com.fasterxml.jackson.core:jackson-annotations", version.ref = "jackson" }
5456
jackson-core = { module = "com.fasterxml.jackson.core:jackson-core", version.ref = "jackson" }
5557
jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "jackson" }
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- add basic tier and assign customer for loopback IP to it
2+
3+
INSERT INTO tier (id, name, description, tier_type, capacity, duration, refill_strategy) VALUES (1, 'free', '', 'FREE', 50, 60, 'GREEDY');
4+
INSERT INTO tier (id, name, description, tier_type, capacity, duration, refill_strategy) VALUES (2, 'safety', '', 'SAFETY', 200, 60, 'GREEDY');
5+
INSERT INTO tier (id, name, description, tier_type, capacity, duration, refill_strategy) VALUES (3, 'basic', '', 'NON_FREE', 100, 60, 'GREEDY');
6+
INSERT INTO customer (id, name, tier_id, state, cidr_blocks) VALUES (1, 'loopback', 3, 'EVALUATION', '127.0.0.1/32');

0 commit comments

Comments
 (0)