Stories of the Week
State of Node.js Performance 2023
- Node Internal Benchmark: An opinionated set of benchmarks grouped by module targeting high-impact operations for Node developers.
- nodejs-bench-operations: An open source repository with benchmark operations for all major Node versions, including the last three releases of each version line.
- HTTP Servers: A pragmatic HTTP benchmark that uses Express and Fastify to send requests to various routes and return JSON, plain text, and errors. The results for this group will be published in a subsequent article.
The analysis used an AWS Dedicated Host with a
c6i.xlarge computing-optimized instance. The benchmarks covered various Node modules/namespaces, such as
fs (file system), events (
http (HTTP server + parser), and more.
The statistical method applied in the study required performing each benchmark several times. The data was analyzed to determine the percentage of performance improvement along with a level of confidence in the improvements. Key findings include:
- File System (
fs): An improvement of 67% was observed when upgrading from Node 16 to 18 using
asciiencoding. However, there was a regression of 27% in Node 20 which is expected to be addressed in future minor releases. Other
readdirshowed improvement from Node 18 to 20.
EventTarget: Event dispatching performance improved by about 15% when upgrading from Node 16 to 18 and up to 200% when upgrading from Node 18 to 20 with a single listener.
- HTTP Servers: An 8% improvement was noticed from Node 16 to 18 and a seemingly massive 96.13% improvement was found from Node 18 to 20. However, other more reliable benchmarking tools only showed an improvement of 9%, suggesting limitations or errors in the previous benchmarking method.
startup.js: Significant improvement in the Node process lifecycle was observed with a 27% boost from Node 18 to 20 and 34.75% from Node 16 to 20.
trace_events: Observed a 7% improvement from Node 16 to 20 and a 2.39% improvement from Node 18 to 20.
require(): Observed improvements between Node 18 and 20 when requiring
.jsonfiles (6.58%), and reading directories (9.50%), thus contributing to faster startup times.
- Streams: Some operations related to streams became slower between Node 16 and 18. Also, certain types of streams (like
Transform) regressed in Node 20.
- URL Parsing: The introduction of the Ada URL parser in Node 18 resulted in performance improvements of up to 400% when parsing URLs, with further enhancements observed in Node 20 due to an upgrade to Ada 2.0.
- Buffers: Node 20 fixed two major regressions from Node 18 and showcased significant improvements in handling binary data, particularly in
Buffer.toJSON()functions, making it the fastest version for dealing with buffers.
- Text Decoding and Encoding: Node 20 brought substantial performance improvements in
TextEncoderover Node 18, with the addition of
simdutffor UTF-8 parsing leading to a 364% improvement in decoding and a 25% performance boost in comparison to Node 18.
While the overall benchmark results show a few setbacks, most of the areas of concern demonstrate that significant improvements were made in Node's performance across versions 16, 18, and 20. Most importantly, these benchmark results can help guide future optimizations and assist in avoiding regressions.
The bundler is seen as the first step towards
Bun.App, an integrated API combining Bun's bundler, HTTP server, and file system router. The bundler can be used through the
bun build CLI command or the new
import.meta.maincan be used to check if the current file is the entry point that started Bun.
- New testing methods were added and
bun testnow reports test run times.
- Performance enhancements include a 20% speed increase for
- Improvements to Node.js and Web API compatibility.
- Hoh Shen Yien - The Next.js 13 App Directory and Server Components: What You Need to Know
- Ryan Toronto - Building a users table with a server component
- Artem Zakharchenko - My Struggle With Remix
- Danny Moerkerke - How To Hydrate A Server-Side Rendered Web Component
- Dominic Elm - The Atomic Waltz: Unraveling WebAssembly Issues in V8 and SpiderMonkey
- Jaimie McMahon - Why the modern web loves Astro and Eleventy
- Tammy Everts - A Complete Guide to Performance Budgets
In Thomas Heinrichs' talk, Loosely or Lousily Coupled, Thomas aims to explore various composable communication methods in modern distributed architectures, including event streaming, asynchronous messaging, and REST. He discusses their limitations, tradeoffs, and impacts on component coupling while emphasizing how these concepts influence architecture and team productivity.
Podcasts of the Week
- SyntaxFM - WTF are Signals and Why is Everyone So Hot on Them?
- The Vanilla JS Podcast - Accessibility with Ben Myers
- Frontend First - What Problems do React Server Components Solve?
- PodRocket - Next.js 13.4 with Tim Neutkens
One More Thing
While at Remix Conf, I had the pleasure of interviewing Glauber Costa (CEO of Turso) and Igor Minar (Senior Director of Engineering at Cloudflare). We discussed the future of developing web applications at the edge and how databases and web frameworks will influence the way those applications are built. You can check out the recording here:
Find us online at the following links: