Cron job vs NodeJS setInterval for optimal performance

Advantages of cron solution

  • less memory consumption for 90% of the time
  • memory leaks are effectively eliminted
  • the code is reloading all libraries every time so updates take effect on the next run without additional complexity

Advantages of daemon solution

  • load time only happens once so disk I/O and CPU are lower for subsequent runs since you won't be parsing your source code or pulling in all of the libraries
  • the lower CPU and disk I/O for subsequent runs also means that there is more of those resources available for whatever your main application for the Raspberry may be.
  • Linux should swap out the memory you're not using. This could be really slow depending on your storage though.

Conclusion

I agree with Alexander T that cron seems likely to be better, but if your main app is sensitive to background processes it might be better to go with the daemon.