Fulmine.js: a faster drop-in Express 5 replacement on uWebSockets.js
Fulmine.js is a drop in replacement for Express 5 that runs on uWebSockets.js instead of node:http . You change one line, your middleware keeps working, and the routing gets between 2x and 20x faster. This post explains where that number comes from, and where it does not apply. const express = require ( " fulmine.js " ); // instead of require("express") Why the Express router is the part that…
Fulmine.js is a drop-in replacement for Express 5 that runs on uWebSockets.js instead of node:http. It offers between 2x and 20x faster routing, but its performance improvements depend on the size of the application.
Express's router works by walking a list of routes, scanning each one until a match is found. This means that as the number of routes increases, the processing time for each request also increases. Fulmine.js, on the other hand, registers routes on uWebSockets.js's own router, which matches the path in C++ and hands over a pre-compiled chain. This eliminates the need to scan the routes on every request, resulting in significant performance gains.
The benchmarks show that Fulmine.js can outperform Express 5 by up to 20x on applications with a thousand routes, especially those with parameters or mounted routers. The advantage grows with the size of the application, making Fulmine.js particularly useful for generating API layers or multi-tenant backends. However, the benefits are less pronounced on smaller applications or those with simple routes.
One of the key advantages of Fulmine.js is its ability to compile handlers simple enough to be read at registration time into a uWS response written once at startup. These handlers can then respond without entering JavaScript at all, resulting in faster response times for certain types of requests, such as health and readiness probes, configuration endpoints, feature flags, and static files.
Despite its impressive performance, Fulmine.js is not faster than Express in every scenario. It is not faster when the cost of a request is primarily the work done by the server, as the processing time will be similar for both servers. However, in cases where the framework is doing the work, Fulmine.js can provide a significant performance boost.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.