Skip to content

This is an example of using PM2 together with Next.js to optimise CPU usage. Using k6 we can run a load test to check how the app performs with high traffic with and without PM2. It uses the Next.js. App Router and has an example of a static as well as a dynamic page that does some main thread blocking work.

Notifications You must be signed in to change notification settings

j-hit/pm2-nextjs-k6

Repository files navigation

Getting started

Installing dependencies

npm install

Installing pm2

npm install
npm install -g pm2

Installing k6 for load testing

brew install k6

Running the load test

Static Next.js pages

Without PM2

npm run build
node .next/standalone/server.js
k6 run ./load-tests/static.js

With PM2

npm run build
pm2 start .next/standalone/server.js -i 0
k6 run ./load-tests/static.js

Dynamic Next.js pages

Without PM2

npm run build
node .next/standalone/server.js
k6 run ./load-tests/dynamic.js

With PM2

npm run build
pm2 start .next/standalone/server.js -i 0
k6 run ./load-tests/dynamic.js

About

This is an example of using PM2 together with Next.js to optimise CPU usage. Using k6 we can run a load test to check how the app performs with high traffic with and without PM2. It uses the Next.js. App Router and has an example of a static as well as a dynamic page that does some main thread blocking work.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published