Along with the community, StrongLoop is excited for Node v0.12 to become generally available.
There’s no time like the present to get familiar with the new features that are coming to v0.12. We’ve compiled the list below to help you get prepared:
- Cluster round-robin load balancing
- Performance optimizations
- Running multiple instances in a single process
- execSync: a synchronous API for child processes
- Debugging clustered apps with Node Inspector
One of the goals of clustering in Node was to make it easy to create ‘fire and forget’ multi-process servers. In a perfect world, you should be able to take an existing single-process application and spawn as many worker processes as you see fit without having to change a single line of code in your application. The cluster module in Node.js v0.11.2 introduces a round-robin approach: new connections are accepted by the master process, which then selects a worker process to hand off the connection to.
The long development cycle for v0.12 has given the core team and contributors ample opportunity to introduce a number of performance optimizations. This blog post aims to cover the most notable ones. Here’s six performance enhancements to be aware of.
- Cork support for writable streams
- TLS performance improvements
- Crypto performance improvements
- Reduced garbage collector strain
- Better cluster performance
- Faster timers
An oft-requested feature is the ability to embed Node.js in other applications, particularly in ways that let it integrate with other event loops and (“while you’re at it”) with support for multiple Node execution contexts: that is, the ability to have multiple instances of Node co-exist peacefully within the same process. Imagine a node-webkit application where each window runs its own Node instance that is isolated from all other windows. Or Node embedded in a phone or network switch where it is performing routing logic for multiple connections, but in a single process and you’re not far off.
GitHub came to us needed this kind of functionality for Atom.io. It’s a pretty tall order because Node started out as – and still is – a single-threaded application, built around the concept of a single event loop, with hundreds of global variables that store various bits of state.
A notable library that supports this use case is Grunt, which itself is built on top of ShellJS. However, ShellJS has a tough nut to crack: Node forces it to use asynchronous I/O. While that is great for web servers that must remain responsive at all times, it doesn’t necessarily make a lot of sense for shell scripts that require all steps to be taken in sequence. The inefficiency and ugliness of the hack to make this work motivated the Node core team to implement a real solution – Node v0.12 should finally get support for synchronously running child processes.
By now, most of you have figured out how to use the new and improved node-inspector (built with Google Blink development tools) to debug Node.js applications. But how about clustered apps? In this blog post we’ll take a look at what it takes to accomplish this feat.
The StrongLoop team has received a lot of feedback from the community in the past year and we have been giving it a lot of thought lately. We’ve been asking ourselves, “How can we as a company, individual developers, and members of a community best contribute to Node so that it benefits everyone? From individual developers to customers to the ecosystem of vendors offering services and products around Node?”
The result is this post where we’ve collaborated with colleagues both inside and outside of StrongLoop to try and articulate where we think StrongLoop can be of most use in helping the community take Node to the next level. Here’s our thoughts for APIs, module management, instrumentation, tooling and connectivity.
When will v0.12 be released?
Good question. The first build of what will become Node v0.12 was released about a year ago back in April of 2013. StrongLoop has been busy helping make v0.12 a reality by making significant contributions to core and being the primary authors of a bunch of cool new features like performance optimizations, cluster round-robin and the ability to run child processes synchronously. Although we have contributed lots of code, we don’t actually control when Node v0.12 will get released. This task is up to the community steward. Developers have been suggesting for a few months now that v0.12 is “weeks away”. With about about 830 open bugs and about 187 pull requests waiting to be reviewed, it seems unlikely. Time will tell!
Ready to start monitoring event loops, manage Node clusters and chase down memory leaks? We’ve made it easy to get started with StrongOps either locally or on your favorite cloud, with a simple npm install.
- Ready to develop APIs in Node.js and get them connected to your data? Check out the Node.js LoopBack framework. We’ve made it easy to get started either locally or on your favorite cloud, with a simple npm install.
- Need training and certification for Node? Learn more about both the private and open options StrongLoop offers.