Adquio and Node JS

When we started designing our Adquio programmable controller we had to make a lot of decisions, and many of them were going to decide what the future of our devices would be.

When you have to design both hardware and software yourself, this is quite normal. On the hardware side, we decided to use ARM processors, and not microcontrollers as other manufacturers do, but today we are not going to talk about this, but about the most important decision we have made on the software side.

What programming language will we use to develop it?

The decision was a quick one, considering the features we wanted for our device. Node.JS. But why?

The answer is the way Node.JS works with its event loop, which makes it very fast in processing huge amounts of events, processes and inputs and outputs. This is most desirable for a device that must be responsible for processing dozens of connections with other devices, and for handling the events that come from them.

How does the NodeJS event loop work?

All the processes of your program are sent to the event loop, if what you are asking it can be solved immediately, it does it and returns the control, but if it is a heavier job, it separates it in a different thread and continues processing your program. This is what is called in Node.JS, asynchrony, since, your program may eventually be running many of its processes in parallel. This is ideal for a system that must handle lots of input/output events, as is the case with Adquio.

Additionally, these threads can be distributed among different processor cores, if the device on which they are running has them. In our case, Adquio has 4 cores, that’s why it is so efficient, because it takes full advantage of the hardware it has available, and it does it in a natural and native way, since the base language we have used already behaves like this.

Advantages of Node.JS and the event loop in Adquio

  1. One of the main advantages is its ability to handle multiple requests efficiently. Instead of having to create a new thread for each request, the event loop allows Adquio to process multiple requests sequentially using a single thread. This reduces system overhead and allows Adquio to handle a greater number of requests without suffering reduced performance. This allows Adquio controllers to handle a large number of inputs and outputs simultaneously.
  2. Its ability to execute tasks asynchronously. When an event occurs, such as a network request or an input/output (I/O) operation, the event loop places it in an event queue and processes the event when its turn comes. In the meantime, your program within Adquio continues to run and can process other events. This allows Adquio to execute tasks more efficiently and without having to wait for all tasks to be completed before continuing. Especially important when waiting for responses from slow buses such as Modbus RTU or BACnet MSTP.
  3. The event loop is compatible with multi-core systems. When running a Node.js application on a multi-core system, such as Adquio, each core can run its own instance of the event loop. This allows Adquio to take full advantage of the system’s processing power and handle multiple requests more efficiently.
  4. Facilitates writing asynchronous code: the event loop provides a framework for writing asynchronous code in a simple and consistent manner. This can significantly simplify the development process and improve code readability.
  5. Improve Adquio’s scalability: by allowing Adquio to handle multiple requests efficiently, the event loop can significantly improve the scalability of your projects. This is especially important in high concurrency environments, where large amounts of traffic can be expected.
  6. Facilitates integration with other libraries and frameworks: due to its event-driven design, the Node.js event loop integrates naturally with other libraries and frameworks that use a similar model. This can facilitate the integration of your application with other tools and technologies. This is perfect for our roadmap with Adquio.
  7. Its ability to improve the efficiency of your Scripts within Adquio. By processing the events in the queue sequentially and allowing them to Adquio continues to run while waiting for other events to occur, the event loop allows Adquio to execute tasks more efficiently and without having to wait for all tasks to complete before continuing. This can significantly improve Adquio’ s performance and make it more agile.
  8. Its ability to improve the stability of your application. By processing events sequentially and not having to wait for all tasks to complete before continuing, the event loop allows Adquio to recover more quickly from potential errors or problems. This can significantly improve stability for your projects and reduce downtime.
  9. It is highly extensible and allows developers to create custom applications within Adquio that fit their specific needs. By using the event loop as a framework, developers can create more advanced and adaptable applications that can grow and evolve as customer needs change.
  10. It is compatible with a wide variety of operating systems and platforms. Node.js can be installed on virtually any operating system, including Windows, macOS, Linux and Unix. This means that you can develop applications with Node.js on the operating system of your choice and then deploy them to any other supported operating system. This has been key to port our software and create products such as Adquio Server or Adquio Link.
  11. It supports a wide variety of cloud platforms and hosting services, which means you can easily deploy your applications in cloud environments. Adquio has used this key advantage to create our Adquio Link product.
  12. It is compatible with a wide variety of external modules and libraries. The Node.js community has created a large number of modules and libraries that can be easily integrated into your application by using Node Package Manager (NPM). This means that you can take advantage of the wide variety of tools and functionalities that have been created by other developers and use them to improve your application. This has allowed us, for example, to connect Adquio with weather forecasts or energy prices.
  13. The Node.js event loop is compatible with a wide variety of databases and data storage systems. You can use the event loop to connect to relational databases such as MySQL and PostgreSQL, or to non-relational databases such as MongoDB and Redis. This means that you can store and retrieve data efficiently and use the event loop to process and handle that data efficiently. All this from a programmable controller, isn’t it amazing?

As you can see, our decisions always go hand in hand with efficiency; it would be no good to have a very powerful processor but not be able to take full advantage of it. In this case, and as you have just seen, using Node.JS is the best decision we could have made, because, there is no better way to leverage hardware resources and do it to give the end customer the best performance and efficiency experience.

This is just another example of why Adquio interests you, because you know that you have the best hardware on the market in your programmable controller, but not only that, as you have just seen, you also have the best software, which takes advantage of all the features of modern processors in the most optimal way for you.

Related Posts

Leave a Reply