Joke Collection Website - Public benefit messages - (9) 9) How does 9)9)Redis restrict the sending of short messages?

(9) 9) How does 9)9)Redis restrict the sending of short messages?

Title: The same IP can only be sent 100 times a minute.

Summary: 1, window, 2 token bucket, redis+lua 3 funnel.

1. Fixed window: string is saved, IP is the key, and the value is self-increasing, which is limited to > 100. Set the timeout 1 minute, and the key will disappear after 1 minute.

Good performance, simple implementation and low memory consumption.

Inaccurate: the first request arrived in 0s, the remaining 99 in 60s, 6 100 requests came 199 from 60-6 100.

2. Sliding window: IP is key, and value =list (time stamp of each visit). Every time you visit the query list, compare the first 100 with the current time stamp.

Incorrect time control, poor performance, relatively complex implementation and large memory consumption.

Token bucket: In addition to limiting the average transmission rate, it also allows burst traffic.

Funnel: Forcibly limiting the transmission rate

RateLimit current limit? 、redis+Lua:blogs.com/orangesea/articles/ 1 1299557.html

Funnel? /s/3d_USEzLf-eLSBj_qS9jng