Boost Node.js Serverless Cold Starts 150% Faster with Alinode PGO

Alinode PGO leverages profile‑guided optimization to generate a cache of hot startup code for Node.js functions, cutting cold‑start latency by up to 61% (150% speed‑up) and allowing further reductions by launching solely from the PGO cache, as demonstrated with real‑world benchmarks.

Node Underground
Node Underground
Node Underground
Boost Node.js Serverless Cold Starts 150% Faster with Alinode PGO

What Is Alinode PGO

PGO (Profile Guided Optimization) is a technique that uses runtime profiling data to guide optimizations. Alinode PGO collects hotspot data during an initial execution, creates a cache file, and then loads this efficient cache on subsequent starts, delivering 100%‑200% improvement in user‑code cold‑start performance. The feature is available in Alibaba Cloud Function Compute starting with Node.js 14.

Usage Effect Example

We validate Alinode PGO with a simple test program that loads several common NPM modules, illustrating the optimization’s impact on user‑code loading speed.

Sample Code

require('eslint');
require('lodash');
require('midway');
require('webpack');
require('jsdom');
require('mysql2');
require('sequelize');

exports.handler = (event, context, callback) => {
  callback(null, {
    versions: process.versions
  });
};

Normal Cold Start

Without PGO and with only production dependencies installed, the cold‑start request time reaches 3069.39 ms .

PGO Optimized Cold Start

Adding the PGO cache file to the function package reduces cold‑start time to 1254.43 ms , a ~61% reduction and roughly a 150% speed‑up.

Advanced PGO: Cache‑Only Startup (Remove node_modules)

When business code is controllable and all module dependencies are imported during initialization, you can keep only the PGO cache file and delete node_modules. This halves the package size and reduces the number of small files, dramatically lowering download and extraction time. In load‑testing scenarios, percentile metrics (P50‑P99) show significant drops.

Existing package with added PGO cache:

Cache‑only startup (node_modules removed):

How to Use – Through Serverless Devs

Alinode’s current release supports Node.js 14 on Alibaba Cloud Function Compute. A Serverless Devs plugin is provided to simplify trying this user‑code acceleration technique. The feature is still experimental and community‑driven; thorough testing is recommended before production use.

Plugin repository and documentation: https://github.com/midwayjs/pgo . The implementation can be adapted to other environments as needed.

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.

Performance OptimizationserverlessNode.jscold startPGO
Node Underground
Written by

Node Underground

No language is immortal—Node.js isn’t either—but thoughtful reflection is priceless. This underground community for Node.js enthusiasts was started by Taobao’s Front‑End Team (FED) to share our original insights and viewpoints from working with Node.js. Follow us. BTW, we’re hiring.

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.