µExpress: A Drop‑in Express Replacement with 5‑10× Speed Gains

µExpress is a micro‑Express framework built on µWebSockets that offers full Express 4 compatibility while delivering 5‑10× higher request throughput across routing, middleware, and static‑file scenarios, as demonstrated by detailed wrk benchmarks and best‑practice guidelines.

Full-Stack Cultivation Path
Full-Stack Cultivation Path
Full-Stack Cultivation Path
µExpress: A Drop‑in Express Replacement with 5‑10× Speed Gains

Overview

µExpress (Micro‑Express) is an open‑source Node.js HTTP server built on µWebSockets. It re‑implements the Express 4 API, allowing a drop‑in replacement by changing require('express') to require('ultimate-express') without modifying application code.

Features

Full compatibility : Nearly all Express 4 features and middleware work unchanged.

High performance : Uses an event‑driven model and deep integration with the native µWebSockets engine, delivering substantially lower latency and higher request rates than vanilla Express.

Installation

npm install ultimate-express

Basic Usage

const express = require('ultimate-express');
const app = express();
app.get('/', (req, res) => {
  res.send('Hello, µExpress!');
});
app.listen(3000, () => {
  console.log('Server is running on port 3000');
});

More complex applications can use routing, middleware, and template engines exactly as with Express, e.g.:

const express = require('ultimate-express');
const app = express();
app.use(express.json());               // JSON body parser
app.use(express.static('public'));    // static file server
app.get('/api', (req, res) => {
  res.json({ message: 'Welcome to api!' });
});
app.post('/data', (req, res) => {
  console.log(req.body);
  res.send('Data received');
});
app.listen(3000, () => {
  console.log('Server is running on port 3000');
});

Performance Benchmarks

Benchmarks were run with wrk on Ubuntu 22.04, Node 20.17, AMD Ryzen 5 3600, 64 GB RAM. Across seven scenarios µExpress achieved 4.9‑11.8× higher request rates and 4.9‑14.5× higher throughput. Selected results:

routing/simple‑routes: Express 11.16 k req/s, µExpress 75.14 k req/s (6.73× speedup).

routing/lot‑of‑routes: Express 4.63 k req/s, µExpress 54.57 k req/s (11.78×).

middlewares/express‑static: Express 6.58 k req/s, µExpress 32.45 k req/s (4.87×).

engines/ejs: Express 5.50 k req/s, µExpress 40.82 k req/s (7.42×).

Comparison with Other Frameworks

Average requests per second (rps) across ping, query, and body tests:

uws: 94.3 k rps

hyper‑express: 66.4 k rps

ultimate‑express (µExpress): 57.3 k rps

fastify: 33.1 k rps

hono: 26.6 k rps

koa: 24.0 k rps

express: 10.4 k rps

Optimization Guidelines

Route Optimisation

Enable case‑sensitive routing (more efficient than the default case‑insensitive mode).

Avoid regex characters ( *, +, ( ), { }) in path strings; plain strings are optimised.

Keep route depth to a single level; deeper nesting degrades performance.

Middleware Optimisation

Prefer the built‑in static file middleware ( express.static()) over external serve-static.

Use native body parsers ( express.text(), express.json()) instead of the separate body‑parser package.

Do not read the request body for GET requests; unnecessary reads reduce endpoint speed by roughly 15%.

Thread Optimisation

By default µExpress creates one worker thread (zero on single‑core CPUs). The thread count can be changed via the threads option in express() or disabled with threads: 0. Example: const app = express({ threads: 0 }); Threads are shared across all express() instances. More threads do not guarantee better performance; empirical testing is recommended.

IP‑Address Handling

Reading req.connection.remoteAddress or req.ip after the response is slow in µWebSockets. Avoid these calls unless trust proxy is enabled, as they can dramatically slow subsequent requests.

Repository

GitHub: https://github.com/dimdenGD/ultimate-express

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

backendperformanceNode.jsExpressµWebSocketsµExpress
Full-Stack Cultivation Path
Written by

Full-Stack Cultivation Path

Focused on sharing practical tech content about TypeScript, Vue 3, front-end architecture, and source code analysis.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.