# Function node efficiency

**URL:** <https://discourse.nodered.org/t/function-node-efficiency/47728>\
**Category:** General\
**Created:** [28 June 2021 04:00 UTC](https://discourse.nodered.org/t/function-node-efficiency/47728 "2021-06-28T04:00:42Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [28 June 2021 05:14 UTC](https://discourse.nodered.org/t/function-node-efficiency/47728/2 "2021-06-28T05:14:30Z")

</div>

As with most things... it depends; mainly on your expected message throughput, the complexity of your function and your hardware limitations.

Yes, the function node executes its code in a [VM](https://nodejs.org/dist/latest-v14.x/docs/api/vm.html) which can have an impact on performance, but for most "normal" use cases, that should be negligible.

All in all, those a things you should simply try out and measure the limitations for your use case, and not fall victim to premature optimization.

_If_ function nodes become a bottleneck, there are solutions of course.

- There is the [https://flows.nodered.org/node/node-red-contrib-unsafe-function](https://flows.nodered.org/node/node-red-contrib-unsafe-function), which doesn't use a VM.
- use native code for your operations
- don't perform CPU-intensive workload inside Node-RED (i.e. NodeJS), but use separate processes
- ...

Also keep in mind, that CPU-intensive workload can block your NodeJS' event loop, which affects everything running in your Node-RED instance.

I think the topic has also been covered here to some extent a while back: [Function Node, which code is more efficient?](https://discourse.nodered.org/t/function-node-which-code-is-more-efficient/22036)

---

_[View the full topic](https://discourse.nodered.org/t/function-node-efficiency/47728)._
