|
| 1 | +--- |
| 2 | +layout: blog |
| 3 | +title: What's next with Node-RED? |
| 4 | +author: nick |
| 5 | +description: Having covered the release schedule in a previous post, we now look at the technical content in the roadmap for Node-RED. |
| 6 | +--- |
| 7 | + |
| 8 | +Last week I presented at [Node-RED Con Tokyo](https://nodered.jp/noderedcon2020/index-en.html) |
| 9 | +to talk about the future of the project. I spoke about the high-level goals for |
| 10 | +project and what they translate to in terms of technical features in the roadmap. |
| 11 | + |
| 12 | +This blog post is the written form of that talk - it provides the context that |
| 13 | +is otherwise lacking from just looking through the slides. |
| 14 | + |
| 15 | +<script async class="speakerdeck-embed" data-id="df4c972d06664bbe97b2e66897eba5c4" data-ratio="1.77777777777778" src="//speakerdeck.com/assets/embed.js"></script> |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | + |
| 20 | +In my [last post](/blog/2020/07/01/release-plans), I wrote about how we plan to |
| 21 | +schedule our releases - with a new major versions being published to coincide |
| 22 | +with the Node.js release schedule. |
| 23 | + |
| 24 | +What I didn't touch on in that post is the technical side of the roadmap. Aside |
| 25 | +from keeping up to date with Node.js, the question is what have we got planned |
| 26 | +for the future of the project. |
| 27 | + |
| 28 | +The roadmap for the 1.0 release gave us something to focus on - it set a reasonably |
| 29 | +well-defined target for the project to get to. Looking beyond 1.0 is a much more |
| 30 | +open-ended question - there isn't an equivalent end-point in mind. |
| 31 | + |
| 32 | +We do have a set of goals of the project - things we know we want to achieve. |
| 33 | +We can use those goals to identify and prioritise the technical features we're |
| 34 | +going to work on in the coming releases. |
| 35 | + |
| 36 | +In this post, I'm going share some of the technical features we have |
| 37 | +planned for the project and how they fit in with our goals for the project's future. |
| 38 | + |
| 39 | +But first I wanted to share what we see our goals as being. |
| 40 | + |
| 41 | +### Who are our users? |
| 42 | + |
| 43 | +To begin thinking about what the technical roadmap is for the project, we have |
| 44 | +to take a step back and think about who our users are - who are we developing |
| 45 | +Node-RED for? |
| 46 | + |
| 47 | +The [community survey](https://nodered.org/about/community/survey/2019/) we did |
| 48 | +last year gave us a good view of the community. Our users come from a very wide |
| 49 | +range of backgrounds and experience. We have students who are just starting to |
| 50 | +learn about programming. We have retired engineers who are getting back to |
| 51 | +building things. We have experienced developers who appreciate the convenience |
| 52 | +Node-RED provides over writing code. And we have everyone else in between. |
| 53 | + |
| 54 | +A large proportion of our users are individuals who run Node-RED on personal devices - |
| 55 | +a laptop, a Raspberry Pi or a virtual machine in the cloud. They are building |
| 56 | +solutions for themselves - whether it's home automation, adding skills to their |
| 57 | +Alexa or Google Home, or doing the types of online services like IFTTT can provide. |
| 58 | + |
| 59 | +It's predominately these users who spend their time in the forum, discussing what |
| 60 | +they’ve built, or helping answer questions from newcomers. |
| 61 | + |
| 62 | +Another group of users come from the companies who have integrated Node-RED into |
| 63 | +their own products and services. Hitachi, Siemens, Samsung, Particle and many others. |
| 64 | +They have a different set of needs. They want to integrate Node-RED into their |
| 65 | +existing platforms. They want to be able to offer a seamless experience to their |
| 66 | +end users - hiding away the details of how Node-RED is being run or where the |
| 67 | +flows are executed. |
| 68 | + |
| 69 | +Understanding the different needs of these groups of users is vital to getting |
| 70 | +the priorities right in the roadmap. |
| 71 | + |
| 72 | +### Sustainability |
| 73 | + |
| 74 | +There is another reason why we need to understand these different groups of |
| 75 | +users. We have a responsibility to ensure Node-RED is a sustainable project - that |
| 76 | +it has the resources it needs to continue delivering to our users. Sustainability |
| 77 | +in open source is a hard problem. |
| 78 | + |
| 79 | +Contributors typically come from two places; individuals who chose to invest their |
| 80 | +spare time to the project and individuals who have a commercial interest in the |
| 81 | +project and contribute as part of their day job. |
| 82 | + |
| 83 | +As a Growth project of the OpenJS Foundation, we want to grow our contributor |
| 84 | +base - getting more people involved with the central parts of the project. |
| 85 | + |
| 86 | +Whilst some of that will come from individuals, we want to increase the commercial |
| 87 | +adoption of Node-RED. This will help increase the commercial investment back into |
| 88 | +the project itself. |
| 89 | + |
| 90 | +### Project goals |
| 91 | + |
| 92 | +As we think about the technical roadmap for the project, we have three goals: |
| 93 | + |
| 94 | + * Improve the experience for the individual developer |
| 95 | + * Increase commercial adoption of Node-RED |
| 96 | + * Improve the path to production for anyone wanting to use Node-RED |
| 97 | + |
| 98 | + |
| 99 | +It's these goals that we should use to help us prioritise and focus our efforts |
| 100 | +moving forward. |
| 101 | + |
| 102 | +A lot of this will be familiar if you've followed the various discussions in the |
| 103 | +forum or slack - but it's useful to bring it together into one place. |
| 104 | + |
| 105 | +## Improving the Developer Experience |
| 106 | + |
| 107 | +### Testing Framework |
| 108 | + |
| 109 | +One of the most fundamental requirements for any software development is being |
| 110 | +able to easily test the code. Whether that is unit-testing individual components, |
| 111 | +or system-testing a larger piece. |
| 112 | + |
| 113 | +This is an entire area that Node-RED does not provide much help to the user with. |
| 114 | +Some testing can be done in the editor, using Inject nodes to create test messages, |
| 115 | +and the Debug sidebar to check the results. But that’s quite a limited set of tools. |
| 116 | +It's entirely manual testing and not suitable when you want to test against external |
| 117 | +systems like databases or web apis, nor is it suitable when you want to automate |
| 118 | +the testing as part of a automated Continual Integration workflow. |
| 119 | + |
| 120 | +One approach would be to create traditional test cases in code; tests that can |
| 121 | +run against the externals exposed by the flows. This has two major drawbacks; |
| 122 | +it would be hard to do unit testing of internal components of the flows, and it |
| 123 | +does not fit the ‘low-code’ idea of Node-RED very well. |
| 124 | + |
| 125 | +We want our users who are not traditional software developers to be able to |
| 126 | +create tests for their flows just as easily as anyone else can. |
| 127 | + |
| 128 | +There is some initial design work on this item in our designs repository. The |
| 129 | +high-level concept is to be able to define suites of test cases in the editor. |
| 130 | +Then, for each node in a flow, you will be able to define the desired behaviour |
| 131 | +of that node for each test case. The behaviour will be split into three phases: |
| 132 | + |
| 133 | +* `beforeNode` - this phase is triggered when a node receives a message, but |
| 134 | + before the node is given the message. This can be used to validate the message |
| 135 | + arriving at the node has the expected properties. |
| 136 | +* `testNode` - this phase can be used to define the behaviour of the node in |
| 137 | + place of the actual runtime node. This would allow the node to be ’stubbed’ |
| 138 | + out, for example a node that writes to a database or interacts with an external |
| 139 | + system. |
| 140 | +* `afterNode` - this phase is triggered whenever the node sends a message, but |
| 141 | + before the next nodes receive it. This can be used to validate the output of |
| 142 | + the node. |
| 143 | + |
| 144 | +Any of these phases will be able to mark the test case as having passed or failed. |
| 145 | +That means it would be possible to create test cases that span entire flows, or |
| 146 | +that just focus on one or two nodes. |
| 147 | + |
| 148 | +The editor will have a new sidebar that lists out the test cases, where they can |
| 149 | +be run and have their results reported. We'll also provide a way of running the |
| 150 | +test cases using just the command-line so they can be used as part of an automated |
| 151 | +pipeline. |
| 152 | + |
| 153 | + |
| 154 | +### Flow Linter |
| 155 | + |
| 156 | +Alongside testing, there’s another type of tool that developers have come to |
| 157 | +expect and rely on in modern development tools - linters. |
| 158 | + |
| 159 | +Linters are tools that can analyse the code and generate recommendations, warnings |
| 160 | +and errors based on what they find. From checking for basic syntax errors, to |
| 161 | +ensuring a consistent format is used in a code base, linters play an important |
| 162 | +role. |
| 163 | + |
| 164 | +There has been some initial work on a Flow Linter from our friends at Hitachi, |
| 165 | +and we’ll be looking to accelerate that work in the coming months. |
| 166 | + |
| 167 | +The Flow Linter will be both command-line and editor based. The command-line |
| 168 | +version will allow it to be used as part of deployment pipelines to ensure a |
| 169 | +flow meets the required linting rules before it is integrated. |
| 170 | + |
| 171 | +Within the editor, it’ll give feedback to the user over issues in their flow, |
| 172 | +before they have even clicked the Deploy button. |
| 173 | + |
| 174 | +It will be a pluggable tool, allowing custom linting rules to be written and |
| 175 | +shared with the community - so if your organisation has a particular set of |
| 176 | +requirements, or maybe you use some custom nodes that must be wired up in very |
| 177 | +particular ways, the linter will help catch mistakes before they are deployed. |
| 178 | + |
| 179 | +### Flow Debugger |
| 180 | + |
| 181 | +One of the features that I am personally most excited to start working on is a |
| 182 | +proper flow debugger. |
| 183 | + |
| 184 | +Node-RED provides the Debug node to help the developer understand what is happening |
| 185 | +in their flow. They are helpful tools, but they have their limits. You can only |
| 186 | +debug at the points you have added a node into the flow. Where you have a flow |
| 187 | +that involves multiple branches and timing events, it can be hard to see how |
| 188 | +messages are flowing in each branch at the same time. |
| 189 | + |
| 190 | +The Flow Debugger will allow the developer to set breakpoints throughout their |
| 191 | +flow. When a message arrives at a breakpoint, the runtime will pause, messages |
| 192 | +will stop flowing. The developer can then inspect the flow at different points - |
| 193 | +to inspect the messages waiting to be delivered. |
| 194 | + |
| 195 | +When running with the Debugger enabled, the user will be able to visualise the |
| 196 | +performance of their flows - to see where time is being spent, or if there are |
| 197 | +any bottlenecks that could be optimised. |
| 198 | + |
| 199 | + |
| 200 | +### Exportable Subflows |
| 201 | + |
| 202 | +We want to make it easier for users to create their own nodes and share them with |
| 203 | +the community. The goal is to allow subflows to be published as proper node |
| 204 | +modules that can then be installed just like any other node in the library. |
| 205 | + |
| 206 | +Work is already well underway on this - there's a draft PR that adds basic |
| 207 | +support for loading subflows into the runtime from a module. |
| 208 | + |
| 209 | + |
| 210 | +### Projects |
| 211 | + |
| 212 | +We have had the projects feature in Node-RED for a long time now - bringing the |
| 213 | +ability to version control flows directly into the editor. But there’s more to be |
| 214 | +done in this area. |
| 215 | + |
| 216 | +The 1.2 release has introduced a new simplified git workflow - where changes are |
| 217 | +automatically committed whenever the deploy button is clicked. That’s important |
| 218 | +for users who are less experienced with Git version control - they will benefit |
| 219 | +without having to know about committing changes themselves. |
| 220 | + |
| 221 | +And there are other areas we need to improve: |
| 222 | + |
| 223 | + - *Managing project dependencies*. At the moment the editor lets you edit the |
| 224 | + dependencies yourself, and it tries to give some hints on what needs doing, |
| 225 | + but that whole user experience needs to be improved. |
| 226 | + - *Accessing earlier versions of a project*. Having a full history of changes |
| 227 | + is not much use if you can’t easily go back to an earlier version. It is |
| 228 | + possible to do on the command-line - but that isn’t the right answer if we |
| 229 | + want this to be accessible to all users within the editor. |
| 230 | + - *Adding `settings.js` to a project*. For a project to be a complete deployable |
| 231 | + artefact, it needs a settings file. At the moment, that has to be created and |
| 232 | + added to the project manually. There's more the editor could do to help with |
| 233 | + this - the hard part is managing the project's settings file versus the runtime |
| 234 | + settings file - but that's a discussion for another time. |
| 235 | + - *Adding a `Dockerfile` to a project*. A common pattern for deploying projects |
| 236 | + into a production environment is via some form of containerisation. Making |
| 237 | + this quick and easy to setup in the editor would be a big step forward - although |
| 238 | + very much an optional feature. |
| 239 | + |
| 240 | +I’m sure there are other things we could be doing with the Projects feature to |
| 241 | +make it much more powerful. As with everything on this roadmap, we’ll be looking |
| 242 | +to the community for feedback to help expand on the details. |
| 243 | + |
| 244 | +### Standalone Installer |
| 245 | + |
| 246 | +Another area we want to improve is making it easier for users to get started with |
| 247 | +Node-RED. At the moment, to install Node-RED a user has to install node.js and npm, |
| 248 | +then run some commands they may not be familiar with, and they see a screenful |
| 249 | +of output from npm - most of which will mean very little to them. |
| 250 | + |
| 251 | +There are also the cases where a user doesn’t have a good internet connection - |
| 252 | +or any connection at all where they want to install Node-RED. |
| 253 | + |
| 254 | +To help address these problems, we’re going to create a standalone installer for |
| 255 | +Node-RED. Built with Electron to generate native installers for all the common |
| 256 | +platforms, this will be a way to install and use Node-RED as a native desktop |
| 257 | +application. |
| 258 | + |
| 259 | +There are existing projects that do this - including Saito-san's [Node-RED Desktop](https://sakazuki.github.io/node-red-desktop/). |
| 260 | +We'll look to those projects for collaboration and inspiration as we move forward. |
| 261 | + |
| 262 | +## Increasing commercial adoption |
| 263 | + |
| 264 | +An important goal for the project is to increase its commercial adoption. It's |
| 265 | +through this we can help increase the investment back into the project and help |
| 266 | +increase its long-term sustainability. |
| 267 | + |
| 268 | +All of the developer experience items feed into this as Node-RED will only get |
| 269 | +adopted if there is a demand for it - so ensuring it is a delight to use and |
| 270 | +provides the tools users want to use is vital. |
| 271 | + |
| 272 | +But there are also a set of features that are of less immediate relevance to individual |
| 273 | +users - but will play an important role when looking at running Node-RED at scale. |
| 274 | + |
| 275 | +### Deploying Node-RED at scale |
| 276 | + |
| 277 | +One very common question we get is around multi-tenancy - having multiple users |
| 278 | +share a single Node-RED instance without getting in each other’s way. |
| 279 | + |
| 280 | +Our long-stated recommendation has been that the node-red runtime is not suited |
| 281 | +for multi-tenancy. This is down to a number of reasons. Node.js is a single-threaded |
| 282 | +runtime - there is only one event loop that must be shared between all of the |
| 283 | +flows in the runtime. If one user creates a flow that uses a lot of resources, |
| 284 | +it could have a negative impact on the performance of the other flows. Any bugs |
| 285 | +in that flow that lock up the event loop would stop everything else from running. |
| 286 | +Similarly, we have no mechanism to isolate the global context of each flow. |
| 287 | + |
| 288 | +This is why we have always said each user’s flows should be put in its own runtime |
| 289 | +instance - and we have no immediate plans to change that recommendation. |
| 290 | + |
| 291 | +But we recognise that hands the responsibility for figuring out how to manage |
| 292 | +multiple instances over to those who want to integrate Node-RED into their |
| 293 | +environment. That can be quite a barrier to adoption and we don’t currently provide |
| 294 | +any guidance on how to do it. |
| 295 | + |
| 296 | +To begin with, we want to understand how the existing users of Node-RED have |
| 297 | +approached deploying it at scale. We know there are lots of different possible |
| 298 | +models and approaches taken today. We want to get a better view on questions like |
| 299 | +what stacks are being used - is it Kubernetes, OpenShift, Docker Compose or some |
| 300 | +other orchestration technology. We want to understand what approaches companies |
| 301 | +have taken to manage their user's flows. Do users edit their flows in a ‘live’ |
| 302 | +environment or are there separate development and production runtimes. |
| 303 | + |
| 304 | +This will then feed into a set of architectural patterns we'll create for deploying |
| 305 | +Node-RED at scale. In the first instance, those patterns may be more about |
| 306 | +documentation than running code. Over time, there may prove to be some useful |
| 307 | +components we can develop that would fill in some of the gaps. |
| 308 | + |
| 309 | + |
| 310 | +### Scalability of flows |
| 311 | + |
| 312 | +As workloads increase, we need to ensure the Node-RED runtime can be scaled to |
| 313 | +meet the demand. |
| 314 | + |
| 315 | +As with the multi-tenancy question, we've traditionally deferred this question to |
| 316 | +say you can horizontally scale your flows by running multiple instances of the runtime, |
| 317 | +with some kind of load balancing in front. |
| 318 | + |
| 319 | +That answer remains largely the same, but there are certainly things we can do |
| 320 | +to help with the overall scalability. |
| 321 | + |
| 322 | +We've talked about the idea of a distributed Node-RED architecture many times in |
| 323 | +the past. This is where a flow drawn in the editor can be deployed across multiple |
| 324 | +runtimes and devices. It is something we've been slowing working towards and we'll |
| 325 | +continue to do so. |
| 326 | + |
| 327 | +It's a model that can also be used in the context of scalability. For example, |
| 328 | +being able to deploy multiple copies of a flow across multiple runtimes. |
| 329 | + |
| 330 | +In 1.2 we’ve added the hooks API to support pluggable message routing. This will |
| 331 | +allow custom code to be added to the message routing between nodes. So if a flow |
| 332 | +spans two different runtimes, or different parts can be scaled independently, |
| 333 | +that custom code could be used to route the messages between the runtimes. |
| 334 | + |
| 335 | +In 1.0 we added the Groups feature in the editor. The plan is, in a future release, |
| 336 | +to allow a group to have custom meta data associated with it. A user could then |
| 337 | +create a flow, and then group the nodes according to *where* they should be deployed, |
| 338 | +or *how* they can be scaled. That group meta data could then be used by the |
| 339 | +messaging routing to handle getting the messages to where they need to be. Aside |
| 340 | +from the group meta-data, the only other missing piece is a way to deploy the |
| 341 | +flow across the multiple runtimes. |
| 342 | + |
| 343 | +The new hooks api we introduced in 1.2 for the message routing will get extended |
| 344 | +in a future release to support hooks at other points of the runtime lifecycle - |
| 345 | +such as when the deploy button is pressed. |
| 346 | + |
| 347 | +The key part here is we're adding the components and APIs needed to build a |
| 348 | +distributed Node-RED. We don't plan at this stage to produce an out-of-the-box |
| 349 | +Distributed Node-RED version - but all the parts will be there to do so. |
| 350 | + |
| 351 | +### Customising the Node-RED flow appearance |
| 352 | + |
| 353 | +Another aspect is looking at how easy it is to customise the appearance of Node-RED. |
| 354 | +We already provide ways to add custom CSS and modify some aspects of the editor, |
| 355 | +but that can only go so far. |
| 356 | + |
| 357 | +We have had occasional requests to be able to customise the appearance of the |
| 358 | +flow itself - the shape and design of the nodes. |
| 359 | + |
| 360 | +We plan to make the drawing of flows a pluggable component of the editor. It is |
| 361 | +only a concept at this stage - I couldn’t say exactly how it would work, but the |
| 362 | +idea would be that when the editor needs to draw a node on the screen at a given |
| 363 | +position, it calls out to the custom code that does the work needed. |
| 364 | + |
| 365 | +To be clear, this isn't about allowing individual nodes to change their own |
| 366 | +appearance - its about customising the appearance of the entire flow in a consistent |
| 367 | +way. |
| 368 | + |
| 369 | + |
| 370 | + |
| 371 | +## Feedback |
| 372 | + |
| 373 | +With all of these features, there is a significant amount of development work |
| 374 | +needed. As an Open Source project without a large team of full-time developers, |
| 375 | +it isn't possible to put a time-scale on this work as a whole. These items are |
| 376 | +only the headlines for future releases - there will be countless smaller |
| 377 | +enhancements and features throughout the editor and runtime. |
| 378 | + |
| 379 | +If there’s anything here you're excited by, that you'd like to get mored involved |
| 380 | +with, then please do come talk to us - either on the [forum](https://discourse.nodered.org) |
| 381 | +or on [slack](https://nodered.org/slack). |
| 382 | + |
0 commit comments