Skip to content

RAM utilization when using default in-memory storage for express-rate-limit #346

Answered by nfriedly
aoyshi asked this question in Q&A
Discussion options

You must be logged in to vote

The default memory store now stores only an IP address a a number of hits since the current window started, so your memory usage goes up with the number of unique IPs, but not the total amount of traffic. 10000 hits from a given IP takes up the same amount of memory as a single hit from that IP.

The hits number is always a 64-bit float, and an IPv4 address is 7-15 characters at 16 bits each, plus there will be a little memory taken up for the mapping of IP => hits. So, call it ~320 bits or 40 bytes per unique IP. If your window size is 1 hour, and you get hits from a million unique IPs per hour, then the memory store will use around 40 megabytes of RAM. (And then it will be reset to ~0 at…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@aoyshi
Comment options

Answer selected by aoyshi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants