Node.js with Dr Takhir Mamirov
Takhir, I know, your team uses Node.Js for more than 3 years. It is effective and perspective server-side JavaScript platform, and hundreds of startups use Node.JS today. Do you know why? How big is NodeJS community?
Well, there are several benefits of Node.js. Just think:
a) you don’t need to compile the NodeJS code. In general, all that you need are the simple text editor to write the code, system console to run it and… web browser to see how it works 🙂
b) NodeJS is insanely fast, free and open source!
c) you get your development environment ready to work in any machine in 10 minutes!
Also, here is the simple example: we have approximately 200 files, each containing somewhere between 10 to 30 thousand random decimals. Each request to the server would contain a number in the URL such as/1 or /120, the service would then open the corresponding file, read the contents, and sort them in memory and output the median value. That’s it. Our goal is to reach a maximum of 200 simultaneous requests, so the idea is that each request would have a corresponding file without ever overlapping.
On an average NodeJS wins hands down. Even though there are few spikes that could be attributed to various disk related anomalies, as some of the readers have eluded to.
Your previous big Node.Js project was – Californian Start-Up for Online Training Platform. A Client replaced ASP.NET server-side code with Node.Js. What was the main business requirements for that change? Was it expensive?
Firstly, they didn’t replace the existing huge .NET codebase with NodeJS – otherwise, it would require too much efforts and they wouldn’t get lots of benefits of such change. Instead, we kept supporting and slight updating the .NET code, but started using NodeJS and AngularJS for almost any new functionality for the website. The usage of NodeJS for server-side coding met almost all requirements that were set for existing .NET code – simplicity, scalability and speed of development. And eventually that was not expensive – it requires not so much efforts to start up the NodeJS server.
Have you compared the performance of NODE.JS with other platforms? Is it connected to the main Architecture principle of NODE.js?
We didn’t do any huge performance tests comparing the .NET and NodeJS code similar in business flows, but we’ve tested a lot the NodeJS performance in serving or processing tens of thousands of data objects. As a result, all such tests passed successfully and met all requirements. I believe, someday I will have an opportunity to feel how NodeJS handles the really huge server load.
TDD (Test Driven Development) and Node.JS. Why when we talk about Node.Js – everybody knows that we mean TDD principles of development?
Well, the usage of NodeJS doesn’t actually imply a test-driven work. Unfortunately, as practice shows, there might be a NodeJS architecture built and functioning without any test. It is a responsibility of the project architect and developers to follow the right coding patterns and standards, making sure the automated tests are written before the code. The other amazing thing is that writing tests in correctly built NodeJS server architecture is pretty easy and fast, which is practically proven!
Cloud. I know you used Amazon Cloud services. is it expensive from a development point of view to use Node.Js in Amazon AWS? Do you know? Is it possible to use Node.js in Microsoft Azure?
Definitely! I’ve used Amazon Web Services (AWS) to start up a new EC2 instance there, running with MS Windows 2008 R2, and deployed the recent website application there. The deployment included set up of IIS, Node.js, and Apache servers. The MySQL database was rolled out inside an instance of Amazon RDS. Apparently, they have lots of different paid tiers/subscriptions based on your needs and required software performance. They also have a small free tier for start up and get familiar with AWS, but to stay with more-or-less fast production release I’d the advice to use at least the lower paid tier. Eventually, the software deployment into AWS is pretty straightforward and usually goes without any lags. There’re only a few of small things that you need to take care of: firewall inbound rules in Windows OS and security groups in AWS, that you need to apply both to EC2 and RDS instances.
I am working on a proposal for the Latvian National Health system. it will be Online system where thousands of simultaneous users will work with their Patient cards, will be able to complete registration for doctors, send and receive receipts etc. I was going to use ASP.NET based proposal, but would you advise me to choose NODE.js platform? What are the main benefits for it?
Some of the benefits are coming from #3 answers. Also, the place that NodeJS is really compelling is for handling LOAD. This is where technologies really differ. ASP.NET dedicates a thread per request from its thread pool, and once ASP.NET has exhausted available threads requests begin to queue. These blocking requests mean that your valuable thread from the thread pool is doing nothing. The more blocking you have, the less LOAD your ASP.NET app is going to be able to serve. The designers of node on the other hand, made an opinionated choice that ALL I/O should be async. Because of this decision, node designers were also able to make the decision that each instance of node would be single threaded to minimize thread switching and that one thread would just execute code that had been queued. That might be a new request, it might be the callback from a DB request, it might be the callback from a http rest request you made. Node tries to maximize CPU efficiency by eliminating thread context switches. Because node made this opinionated choice that ALL I/O is asynchronous, that also means that all its frameworks/add-ons support this choice. It’s easier to write apps that are 100% async in node (because node forces you to write apps that are async).
What do you think about Node.Js community? Do we already have enough information and resources on the internet to help developers to work with it? What is the most helpful? What is situation with development on Javascript?
The official NodeJS website (http://nodejs.org) has a lot of guide and API stuff to start up the development; it also has a list of references to a bunch of NodeJS communities (http://nodejs.org/community). There are also a lot of internet articles devoted to different patterns and approaches for using the NodeJS in custom server-side development.
Your current Node.Js project is also start up from Australia. Why did the customer decide to replace PHP with node.js?
No, initially they had the PHP server code, responsible for client-side rendering, and NodeJS server side for backend operations. Our work on that project mainly implied refactoring of javascript in NodeJS code to make it testable, readable, stable and supportable. At the same time, we have analyzed the existing PHP code and suggested to replace it with AngularJS / NodeJS combination, which should eventually split the client and server sides and make them easier and faster to upgrade in the future.
Takhir, your experience in Microsoft.NET is more than 10 years. Do you feel nostalgia?
believe that I can get back to .NET anytime, and use its benefits, and moreover, I don’t picture myself using NodeJS for every single web application. If you know what you are doing, you can create decent and efficient applications on top of the .NET stack (for example, MVC).