docs: add worker threads and Node.js LTS guidance to performance best practices - #2473
Conversation
✅ Deploy Preview for expressjscom-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Maybe we should rename all |
I thought I'd already done that, but apparently I hadn't. And yes, we should rename it to .mdx so all the plugins work correctly. |
…o-op for plain markdown
… and Node.js version recommendations
…ensure no-op for plain markdown" This reverts commit fb58cd2.
…ease for improved performance
…edundant list items
Data passed to a worker via workerData or postMessage is copied, not shared; sharing requires transferring objects or SharedArrayBuffer. Also remove a duplicated worker_threads link and a redundant cluster cross-reference.
Frame the raw worker_threads snippet as an illustration and add a worker pool example using piscina, since creating a worker per request is expensive and the Node.js docs recommend pooling instead. Link Node's "Don't Block the Event Loop" guide for further guidance.
|
@GroophyLifefor @krzysdz , could you take a look and see if there's anything that needs correcting? |
|
I didn't see any problems, good job |
|
thanks @GroophyLifefor ! |
krzysdz
left a comment
There was a problem hiding this comment.
Every time an external package is suggested, I'm little concerned, but I see that piscina is developed by Node.js TSC members, so I guess it's trustworthy.
|
|
||
| ### Use the latest LTS version of Node.js | ||
|
|
||
| Running your app on a recent Node.js release is one of the easiest ways to improve performance. Each new version of Node.js ships with cumulative improvements to the V8 JavaScript engine and the runtime itself, so the same Express app can handle significantly more requests simply by upgrading. Benchmarks such as NodeSource's [Node.js Performance Report](https://nodesource.com/pages/content-node-performance-report-wb.html) show how much throughput can improve from one Node.js version to the next. For production, use the latest [LTS release](https://nodejs.org/en/about/previous-releases) of Node.js, and keep it up to date as new versions come out. |
There was a problem hiding this comment.
Each new version of Node.js ships with cumulative improvements to the V8 JavaScript engine and the runtime itself, so the same Express app can handle significantly more requests simply by upgrading.
Upgrading what? The object is missing and the sentence reads weird. "runtime" and "Node.js" would be repetitions and "it" is a bit ambiguous (could refer to the app), so I don't have any suggestion how to improve it.
There was a problem hiding this comment.
Since it isn't a single sentence, it's connected to the part before the comma, and the part before the comma clearly refers to upgrading Node.js, I think it's clear.

Add Node.js 24 and worker threads guidance to performance best practices
Add two new sections to the production best practices: performance and reliability page:
worker_threads, with a small code example and a note distinguishing it from clustering.Fix
CodeTabsimport leaking into rendered content on.mdpagesremark-code-tabs.mjsemits MDX constructs (anmdxjsEsmimport forCodeTabsand a JSX<CodeTabs>wrapper) whenever it groupscjs/mjscode fences. The plugin was registered in the shared markdown processor, so it also ran on plain.mdfiles — wheremdast-util-to-hastserialized the injected import node as literal text, causingimport CodeTabs from '@components/primitives/Tabs/CodeTabs.astro';to appear in the rendered page (visible on/en/advanced/best-practice-performance).Changes
src/plugins/remark-code-tabs.mjs: the plugin is now a no-op for non-MDX files (detected via the VFile path/extname)..mdpages rendercjs/mjsblocks as normal highlighted code;.mdxpages keep working tabs.tests/unit/remark-code-tabs.test.mjs: added coverage for the.mdno-op behavior and MDX detection.Test plan
npm run test:unit— 52 tests pass/en/advanced/best-practice-performanceno longer leaks the import (required clearing the stale.astro/content cache)Before
After