On the back end, you have pure speed, no none sense. Like any respectable environment, Nodejs offers the full power of a scripting language right from start. I was very tempted to convert my entire blog to node, but every time I face the same hurdle.
- single threaded application
- Web server
Every few months I get excited by Node and forget why I failed to convert my framework again. There are very few useful tutorials when it comes to node, because a lot of people limit themselves to HelloWorld.
This blog runs on PHP and Apache. You get quite a few advantage by default with those two being tied together. One of my favorite is you don't have to worry about serving files. Also, Apache runs many parallel instances of PHP so it can handle multiple requests.
With Node, you run a single process, that runs your code and serves your files. That seems cool in the beginning because you don't have to worry about writing complex config files like with your traditional web server. But it becomes a short coming as soon as you get any decent amount of traffic on your website.
I was lured into nodejs because of its real time communication feature. I made a chatting app like everyone else. It worked fine on my local machine at work, at first. As soon as I gave the link to more than 10 people, I noticed it started to lag. Though I have to admit my machine was running multiple other services and applications at the same time.
Node runs your code in a single process, this means if you have a CPU intensive task, it will affect all your users. This is not necessarily a bad thing because it forces you to reorganize your application. The CPU intensive or slow IO stuff shouldn't block the rest of your application. Actually, the power of nodejs lies in its Asynchronous IO capability.
With a server like Apache or Nginx it is easy to forget all about serving files. You almost never have to do anything to serve your file. With nodejs since you create your web server in node, you have to handle your files by yourself.
Frameworks like expressjs can take care of it for you, but still it can be intensive to have your server run both the code and serve the files. So my suggestion is to have an instance of Nginx serve all your static file. You will thank me when your server suddenly gets a million visitors.
- Your code runs in a single thread. It makes sense to separate all your CPU intensive tasks into a different process.
- Since node is the web server, it makes more sense to use another server for your files. This helps you separate static files from code.