I just began to study web developing and heard that node.js can be easily used to deal with incoming HTTP requests. But I'm wondering why they don't simply use Apache or IIS? Under what circumstance would people prefer handling HTTP requests with their own code written in node.js? Thanks.
Asked
Active
Viewed 75 times
-2
-
http://stackoverflow.com/questions/1884724/what-is-node-js?rq=1 – Sergio Tulentsev Jan 10 '14 at 06:52
-
@SergioTulentsev Hi. I don't think this is a duplicate because that thread does explain the advantages of node.js but does not tell me "why we use it, instead of a real server, to deal with http requests"... – babel92 Jan 10 '14 at 06:56
-
@SergioTulentsev Well. By that I mean Apache, nginx, IIS and etc.. – babel92 Jan 10 '14 at 07:31
-
And how node.js server isn't a real server? – Sergio Tulentsev Jan 10 '14 at 07:47
-
@SergioTulentsev Because I believe those 'traditional' server would automatically serve media files when getting some requests. And if I do this with node.js, it might become harder. – babel92 Jan 10 '14 at 07:49
-
Ah, I see what you mean. – Sergio Tulentsev Jan 10 '14 at 07:50
-
1Apache and IIS are slow and eat memory like crazy, why would anyone use them? If you're worrying about serving media, put nginx in front of your application, like a lot of people do. – alex Jan 11 '14 at 04:06
1 Answers
1
Go and have a look into the Raspberry PI community. I know that there this is discussed every once in a while to have a very lightweight server to do stuff. So I believe this is one occasion.
In reality it's though very common to have nginx or apache as a proxy before the node server. The proxy then handles all the heavy lifting like handling static files, while node handles the dynamic stuff.
Node.js compared to PHP is a completely different concept. While a PHP application is stateless, a Node application is stateful, meaning you start the application and it's just running, even when there's no requests, which would not be the case with PHP.

rapsli
- 749
- 1
- 8
- 23