Why is Node.js on Balena OS so much faster than on Rapsbian?

I have been playing around with Node.js on BalenaOS vs Raspbian, and I was impressed with the difference in performance. In fact, I am controlling a hardware system using Node.js + Express. I am using two different environments, one for testing and one for production:

  1. Test environment: Raspbian Stretch
  2. Production environment: Balena OS

I have been running a few tests on the same function when run on two different environments on the same hardware (I am swapping SD cards in and out of a RPI 3b+). These are the results:

  1. Test environment ==> avg time: 34.479 ms
  2. Production environment ==> avg time: 0.662 ms

The code being used is exactly the same. Both tests run through the same docker-compose file. Why is there such a big difference?

Wow, that’s quite the difference. So my first assumption would be a difference in the speed of SD cards. What does your function do when executed?

The reason I think it’s the SD card is that once the script and executable are loaded into memory, the runtime should be almost identical.

There is other potential things, such as a lower memory footprint from balena-engine compared to docker, and lower memory footprint in general of balenaOS to raspbian (at least when last I checked).

@CameronDiver I confirm that it was not about Node, but just about the SD cards being of different models. Once I used the exact same SD card, performance was roughly the same.

Thanks!