Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
What happens when your service is overwhelmed with traffic? Your server can do one of two things:
This library helps you do the latter.
toobusy
polls the node.js event loop and keeps track of "lag",
which is long requests wait in node's event queue to be processed.
When lag crosses a threshold, toobusy
tells you that you're too busy.
At this point you can stop request processing early
(before you spend too much time on them and compound the problem),
and return a "Server Too Busy" response.
This allows your server to stay responsive under extreme load,
and continue serving as many requests as possible.
npm install toobusy
var toobusy = require('toobusy'),
express = require('express');
var app = express();
// middleware which blocks requests when we're too busy
app.use(function(req, res, next) {
if (toobusy()) {
res.send(503, "I'm busy right now, sorry.");
} else {
next();
}
});
app.get('/', function(req, res) {
// processing the request requires some work!
var i = 0;
while (i < 1e5) i++;
res.send("I counted to " + i);
});
var server = app.listen(3000);
process.on('SIGINT', function() {
server.close();
// calling .shutdown allows your process to exit normally
toobusy.shutdown();
process.exit();
});
The one knob that the library exposes is "maximum lag". This number represents the maximum amount of time in milliseconds that the event queue is behind, before we consider the process too busy.
// set maximum lag to an aggressive value
require('toobusy').maxLag(10);
The default value is 70ms, which allows an "average" server to run at 90-100% CPU and keeps request latency at around 200ms. For comparison, a value of 10ms results in 60-70% CPU usage, while latency for "average" requests stays at about 40ms.
These numbers are only examples, and the specifics of your hardware and application can change them drastically, so experiment! The default of 70 should get you started.
FAQs
Don't fall over when your Node.JS server is too busy.
The npm package toobusy receives a total of 11 weekly downloads. As such, toobusy popularity was classified as not popular.
We found that toobusy 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.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.