Skip to content

Nodejs samples: http and http2: Server, Client, and stress test

franke-hub edited this page May 28, 2021 · 1 revision

nodejs: http and https samples

As usual, the source programs are in ~/src/js/http and the associated pseudo-object environment is ~/obj/js/http. As described elsewhere, the object directory is kept in ~/src/obj and created by the bash script ~/src/obj/.README restore. Read the script for usage information.

Highlights:

  • All clients, servers, and stress testers use javascript async methods.
  • The http2 server also handles https requests.
  • Although the clients differ, the http2 server uses the compatibility API and is nearly identical to the http server.
  • The client and stress tester verify that the received data is correct.

The code is written in a style similar to that used by python http samples. The node_datetime module is the only external dependency and it's currently included in the distribution. I plan on removing it and including a simpler substitute at some point.

Even running the server and stress tester on the same machine, logging each operation and checking data correctness, thousands of requests/second are handled. The servers do not cache data. Each request results in a file read. The 16G test machine has over 12G available to be used for file caching so it's not really necessary. The stress tester requests one file over and over, only reading it once to get the verification data.

Current timing: (All requests are logged and all response file data verified.)

  • http: About 4,000 requests and responses per second.
  • http2: About 6,000 requests and responses per second.

The http2 stress test currently outperforms the http stress test because it uses same client (and socket) for the entire test. The session is only negotiated once. I don't expect http2 to outperform http once the tester is modified to be more realistic.