Skip to content

Commit 2c5dfc4

Browse files
Update Node.js GCP learning path content
1 parent 646ef61 commit 2c5dfc4

File tree

3 files changed

+72
-52
lines changed

3 files changed

+72
-52
lines changed
Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,41 @@
11
---
2-
title: Node.js baseline testing on Google Axion C4A Arm Virtual machine
2+
title: Validate Node.js baseline on Google Axion C4A Arm virtual machine
33
weight: 5
44

55
### FIXED, DO NOT MODIFY
66
layout: learningpathall
77
---
88

9+
## Validate Node.js installation with a baseline test
910

10-
Since Node.js has been successfully installed on your GCP C4A Arm virtual machine, please follow these steps to make sure that it is running.
11+
Confirm that your Node.js installation works as expected before benchmarking performance on your Arm-based VM. Run these baseline tests to verify that Node.js is installed correctly and can execute JavaScript code and serve HTTP requests. Catch setup issues early and ensure your environment is ready for further testing.
1112

12-
## Validate Node.js installation with a baseline test
13+
## Run a simple REPL test
1314

14-
### 1. Run a Simple REPL Test
15-
The Node.js REPL (Read-Eval-Print Loop) allows you to run JavaScript commands interactively.
15+
Start the Node.js REPL (Read-Eval-Print Loop) to run JavaScript commands interactively:
1616

1717
```console
1818
node
1919
```
20-
Inside the REPL, type:
20+
21+
Type the following command inside the REPL:
2122

2223
```console
2324
console.log("Hello from Node.js");
2425
```
25-
You should see an output similar to:
26+
27+
The output is similar to:
2628

2729
```output
2830
Hello from Node.js
2931
undefined
3032
```
31-
This confirms that Node.js can execute JavaScript commands successfully. Please now press "Ctrl-D" to exit node.
3233

33-
### 2. Test a Basic HTTP Server
34-
You can now create a small HTTP server to validate that Node.js can handle web requests.
34+
This confirms that Node.js can execute JavaScript commands successfully. Press "Ctrl-D" to exit node.
35+
36+
## Test a basic HTTP server
3537

36-
Use a text editor to create a file named `app.js` with the code below:
38+
Create a file named `app.js` with the following code to validate that Node.js can handle web requests:
3739

3840
```javascript
3941
const http = require('http');
@@ -47,41 +49,46 @@ server.listen(80, '0.0.0.0', () => {
4749
console.log('Server running at http://0.0.0.0:80/');
4850
});
4951
```
50-
- This server listens on port 80.
51-
- Binding to 0.0.0.0 allows connections from any IP, not just localhost.
5252

53-
Next, we run the HTTP server in the background via sudo:
53+
The server listens for incoming connections on port 80, which is the default port for HTTP traffic. By binding to the IP address 0.0.0.0, the server accepts connections from any network interface, not just from localhost. This configuration enables access from other devices on the network.
54+
55+
Run the HTTP server in the background using sudo:
5456

5557
```console
5658
export MY_NODE=`which node`
5759
sudo ${MY_NODE} app.js &
5860
```
59-
You should see an output similar to:
61+
62+
The expected output is:
6063

6164
```output
6265
Server running at http://0.0.0.0:80/
6366
```
64-
#### Test Locally with Curl
67+
68+
## Test locally with curl
69+
70+
Run the following command to test the server locally:
6571

6672
```console
6773
curl http://localhost:80
6874
```
6975

70-
You should see an output similar to:
76+
The expected output is:
7177

7278
```output
7379
Baseline test successful!
7480
```
7581

76-
#### Test from a Browser
77-
Also, you can access it from the browser with your VM's public IP. Run the following command to print your VM’s public URL, then open it in a browser:
82+
## Test from a browser
83+
84+
Print your VM’s public URL and open it in a browser:
7885

7986
```console
8087
echo "http://$(curl -s ifconfig.me):80/"
8188
```
8289

8390
You should see the following message in your browser, confirming that your Node.js HTTP server is running successfully:
8491

85-
![Node.js Browser alt-text#center](images/node-browser.png)
92+
![Screenshot showing the browser displaying 'Baseline test successful!' from the Node.js HTTP server running on a Google Axion C4A Arm VM. alt-text#center](images/node-browser.png "Browser displaying baseline test successful dialogue message")
8693

87-
This verifies the basic functionality of the Node.js installation before proceeding to the benchmarking.
94+
You have now validated that Node.js is working correctly on your Arm VM. Proceed to benchmarking and performance testing.
Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,53 @@
11
---
2-
title: Node.js Benchmarking
2+
title: Benchmark Node.js performance with Autocannon on Arm and x86_64
33
weight: 6
44

55
### FIXED, DO NOT MODIFY
66
layout: learningpathall
77
---
88

9-
## Node.js Benchmarking by Autocannon
9+
## Benchmark Node.js with Autocannon
1010

11-
After validating that Node.js is installed and your HTTP server is running, you can benchmark it using **Autocannon**.
11+
After validating that Node.js is installed and your HTTP server is running, you can benchmark it using Autocannon. You'll use Autocannon to run a series of tests, analyze the results, and identify areas for optimization. Benchmarking on Arm64 provides valuable insights into how Node.js applications scale and perform in cloud environments, helping you make informed decisions about deployment and resource allocation.
1212

1313
## Install Autocannon
14-
**Autocannon** is a fast HTTP/1.1 benchmarking tool for Node.js, used to measure server throughput, latency, and request handling under concurrent load.
14+
15+
Autocannon is a fast HTTP/1.1 benchmarking tool for Node.js, used to measure server throughput, latency, and request handling under concurrent load. To install Autocannon, run this command:
1516

1617
```console
1718
npm install -g autocannon
1819
```
1920

20-
## Start Your Node.js HTTP Server
21+
## Start the Node.js HTTP server
2122

22-
If your sample HTTP server is not already running from the last section, you can start it by typing:
23+
If your sample HTTP server is still running from the last section, you can start it by using this command:
2324
```console
2425
export MY_NODE=`which node`
2526
sudo ${MY_NODE} app.js &
2627
```
2728

28-
Server should be listening on port 80 in the background:
29+
The server should be listening on port 80 in the background:
2930

3031
```output
3132
Server running at http://0.0.0.0:80/
3233
```
3334

34-
## Run a Basic Benchmark (Local)
35+
## Run a local Node.js benchmark with Autocannon
36+
37+
Now run a local Node.js benchmark with Autocannon:
3538

3639
```console
3740
autocannon -c 100 -d 10 http://localhost:80
3841
```
39-
- `-c 100` → 100 concurrent connections
40-
- `-d 10` → duration 10 seconds
41-
- URL → endpoint to test
42+
{{% notice Tip %}}
43+
These options specify how the benchmarking tool runs the test:
44+
45+
- The `-c 100` flag sets the number of concurrent connections to one hundred, simulating multiple users accessing the endpoint at the same time.
46+
- The `-d 10` flag sets the test duration to ten seconds, so the tool sends requests for that period.
47+
- The URL is the endpoint you're measuring, which could be a web service or API running on your Arm server.
48+
49+
This configuration helps you evaluate how your application performs under load on Arm platforms.
50+
{{% /notice %}}
4251

4352
You should see an output similar to:
4453
```output
@@ -65,48 +74,52 @@ Req/Bytes counts sampled once per second.
6574
707k requests in 10.02s, 137 MB read
6675
```
6776

68-
## Understanding Node.js benchmark metrics and results with Autocannon
77+
## Interpret the Autocannon benchmark metrics
6978

70-
- **Avg (Average Latency)** → The mean time it took for requests to get a response.
71-
- **Stdev (Standard Deviation)** → How much individual request times vary around the average. Smaller numbers mean more consistent response times.
72-
- **Min (Minimum Latency)** → The fastest request observed during the test.
79+
Now have a look at the Autocannon benchmark metrics to get a sense of how Node.js performed. Here is an explanation of the metrics and what they mean:
80+
81+
- The average latency (Avg) shows the mean time it takes for each request to receive a response from the server.
82+
- Standard deviation (Stdev) indicates how much the response times vary around the average; lower values mean the server responds more consistently.
83+
- The minimum latency (Min) represents the fastest response recorded during the benchmark, highlighting the best-case performance for individual requests.
84+
85+
## Review Node.js benchmark results on x86_64
7386

74-
### Benchmark summary on x86_64
7587
To compare the benchmark results, the following results were collected by running the same benchmark on a `x86 - c4-standard-4` (4 vCPUs, 15 GB Memory) x86_64 VM in GCP, running SUSE:
7688

77-
Latency (ms):
89+
### Latency results (ms):
7890

7991
| Metric | 2.5% | 50% (Median) | 97.5% | 99% | Avg | Stdev | Max |
8092
|----------|------|--------------|-------|-----|--------|--------|-------|
8193
| Latency | 0 | 1 | 2 | 2 | 0.73 | 0.87 | 104 |
8294

83-
Throughput:
95+
### Throughput results:
8496

8597
| Metric | 1% | 2.5% | 50% | 97.5% | Avg | Stdev | Min |
8698
|------------|--------|--------|---------|---------|----------|-----------|---------|
8799
| Req/Sec | 70,143 | 70,143 | 84,479 | 93,887 | 84,128 | 7,547.18 | 70,095 |
88100
| Bytes/Sec | 13.6 MB| 13.6 MB| 16.4 MB | 18.2 MB | 16.3 MB | 1.47 MB | 13.6 MB|
89101

90-
### Benchmark summary on Arm64
91-
Results from the earlier run on the `c4a-standard-4` (4 vCPU, 16 GB memory) Arm64 VM in GCP (SUSE):
102+
## Review Node.js benchmark results on Arm64
103+
104+
Here are the results from the earlier run on the `c4a-standard-4` (4 vCPU, 16 GB memory) Arm64 VM in GCP (SUSE):
92105

93-
Latency (ms):
106+
### Latency results (ms):
94107

95108
| Metric | 2.5% | 50% (Median) | 97.5% | 99% | Avg | Stdev | Max |
96109
|----------|------|--------------|-------|-----|------|-------|------|
97110
| Latency | 1 | 1 | 3 | 3 | 1.2 | 0.62 | 24 |
98111

99-
Throughput:
112+
### Throughput results:
100113

101114
| Metric | 1% | 2.5% | 50% | 97.5% | Avg | Stdev | Min |
102115
|------------|--------|--------|---------|---------|----------|----------|---------|
103116
| Req/Sec | 45,279 | 45,279 | 54,719 | 55,199 | 53,798.4 | 2,863.96 | 45,257 |
104117
| Bytes/Sec | 8.78 MB| 8.78 MB| 10.6 MB | 10.7 MB | 10.4 MB | 557 kB | 8.78 MB |
105118

106-
## Node.js performance benchmarking comparison on Arm64 and x86_64
107-
When you compare the benchmarking results, you will notice that on the Google Axion C4A Arm-based instances:
119+
## Evaluate Node.js performance on Arm64
108120

109-
- Average latency is very low (~1.2 ms) with consistent response times.
110-
- Maximum latency spikes are rare, reaching up to 24 ms.
111-
- The server handles high throughput, averaging ~53,798 requests/sec.
112-
- Data transfer rate averages 10.4 MB/sec, demonstrating efficient performance under load.
121+
Now that you have the benchmarking results, you can see how Node.js performs on Arm64:
122+
- The average latency is low, around 1.2 ms, which means your server responds quickly to requests.
123+
- Response times are consistent, with only occasional spikes up to 24 ms.
124+
- The server processes a high volume of traffic, averaging about 53,800 requests per second.
125+
- Data transfer rates are efficient, averaging 10.4 MB per second during the benchmark.

content/learning-paths/servers-and-cloud-computing/node-js-gcp/installation.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ weight: 4
66
layout: learningpathall
77
---
88

9-
## Overview
10-
This section shows you how to install Node.js using Node Version Manager (NVM). NVM lets you choose which Node.js version to use and handles the download and installation for you. You’ll use official Node.js packages, making setup simple and reliable.
11-
129
## Install Node Version Manager (NVM)
10+
To install Node.js on your Arm-based VM, use Node Version Manager (NVM). NVM lets you select and manage different Node.js versions easily. By using official Node.js packages, you'll get a reliable and straightforward setup.
11+
12+
1313
First, use this command to download and install NVM into your VM instance:
1414

1515
```console

0 commit comments

Comments
 (0)