Node.js: Now Available on Shared Hosting!

Written by Jo Stonehouse 0 Comments
We're thrilled to announce that Node.js is now available on our shared hosting platform, continuing our mission to make more programming languages available to our customers. With the introduction of Node.js, it's now possible to use JavaScript to code your backend application, as well as on the frontend.

So what is Node.js?

Unlike our PHP, Ruby and Python, which are all programming languages supported by our shared hosting platform, Node.js is not a programming language.

Node.js is a JavaScript runtime environment. In simple terms, Node.js makes it possible for Javascript to run server-side, as opposed to the front end in the web browser, where it usually runs.

This means that you no longer need to use another language like PHP on the backend, you can now code in Javascript in both the front and backend.

What is Node.js good for?

Having "JavasScript Everywhere" certainly simplifies your software stack and the requirements of your development team. However, the advantages go beyond simplification. Being able to use JavaScript on both the front and backend of your application is what lies at the core of the advantagsed of using Node.js.

One of the key benefits of Node.js, and JavaScript everywhere, is that for the first time it opens the door to real time two-way communications. In a traditional backend built on PHP, for example, requests are one way. Typically, the client side (i.e. the user/web browser) makes a request to the backend (i.e. the server/PHP file)  and data is returned. To make apps appear real time, the client side would need to 'poll' the backend server periodically and then react based on the response. There is no mechanism for the server to actually communicate with the client side proactively.

With Node.js, websockets are used, which is a protocal that allows two-way communications between the server and the user in real time. The websocket is bidirectional, meaning that communications between user and server are interactive and two way, the client side does not need to continuously poll the server to see if it has an update - the server simply sends it whenever it is appropriate.

It is this two way communications which makes Node.js so useful for many of the modern applications we use today which are all about instant, realtime sharing of data. Online chat tools or messaging apps, social media, SaaS products, gaming, APIs, dara streaming, file uploads, interactive dashboards - anything that might need to proactively update the user with realtime changes in what is presented to them.

Node.js is hugely scalable

One of the major benefits of Node.js is scalability. If you're a startup developing an app that you believe will scale, Node is a great choice as scalability is baked into it at the core. In a traditional PHP backend, each time a user communicates with the backend, a new connection is opened which will spawn a new thread on the server, eating up the servers resources, such as RAM. Node operates on a single thread, using non-blocking I/O calls, and on average you may be able to support around 250 times the number of concurrent users compared to a PHP based backend with the same physical resources. If you don't need to support that many users, this also means that you could scale down, and lower your hosting costs.

npm: The Node.js Package Manager

No article on Node would be complete without mentioning npm, the package manager that comes with every Node.js installation. Similar to Ruby Gems or the Python Package Index (PyPI), npm allows you to speed up your development time by leveraging thousands of publically available components.

There are hundreds of thousands of packages that do all kinds of things, allowing you to connect to 3rd party ecosystems, automate common tasks and much more, without having to develop that functionality from the ground up yourself.

This makes using Node a no brainer if you want to take your product to market quickly, as it will allow you to significantly speed up your development time, and reduce the cost.

How do I get started with Node.js?

To get started, check our our knowledgebase for details on how to Enable NodeJS in cPanel and How to Deploy a NodeJS Application - in this example we run through installing Ghost, a popular CMS written in JavaScript.

As ever, our team will be available to provide every assistance should you get stuck!

You might also like...

About the Author

Jo Stonehouse is the Founder and Managing Director at Kualo. He loves helping businesses succeed online, and is based in London were he lives with his wife, Sali, daughter Seren, son Griff and dog, Milo.