Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
celerity
Advanced tools
Readme
celerity uses redis to do centralized rate limiting for applications running on multiple heroku dynos (or processes).
npm install celerity
see example.js for a simple rate limited webserver using celerity
var celerity = require('celerity');
var redis = require('redis');
var config = {
redis: redis.createClient(),
timespan: 10 * 1000,
bucketCount: 10
};
celerity keeps the rate for the last timespan
milliseconds.
timespan
is divided into bucketCount
buckets.
the rate is stored in the buckets.
buckets older than timespan
expire every timespan / bucketCount
milliseconds.
a higher bucketCount
increases the frequency and accuracy of the expires
but uses more memory and results in slower read operations.
if timespan
is several seconds long it is usually enough to have
a bucket for every second.
use the prefix
property to set a prefix for all redis keys used by celerity.
the default prefix is celerity:
.
celerity.increment(config, 'event', 1, function(err) {
});
atomic. complexity: O(1).
celerity.read(config, 'event', function(err, rate) {
});
atomic. complexity: O(n) where n is bucketCount
.
celerity.incrementAndRead(config, 'event', 1, function(err, rate) {
});
atomic. complexity: O(n) where n is bucketCount
.
FAQs
celerity uses redis to do centralized rate limiting for applications running on multiple heroku dynos
The npm package celerity receives a total of 1 weekly downloads. As such, celerity popularity was classified as not popular.
We found that celerity demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.