Monday 10 June 2013

Node.js and real-time applications

Hey there guys , posting after a long long time . Was a bit busy and stuff .
          So let's talk about node.js . What is node.js ? It is a server-side software system that can be used to write scalable web applications . As the name suggests , all the code is basically written in javascript .

So what makes node stand out from conventional server side solutions such as php/jsp or other such stuff ? The main advantage of using node.js is it's advanced push capability . That is server can push information to the client in real time , whenever there is a change in the web page or new content is added which means it enables persistent connection between your page and the web server . Node.js uses a non-blocking event driven I/O . In node each persistent connection won't block other requests .Other languages like php sets up a new server process for each connection and we might end up with using a lot of cpu resources . Thus nodejs is suitable for handling many persistent connections at once without using up a huge amount of resources .

To get the best out of node , use Socket.IO and redis . So what is socket.io ? Socket.IO enables you to broadcast data to clients based on a certain event . It uses websockets protocol primarily if present , but it can use other methods too like Adobe flash sockets , JSONP polling , ajax , long polling . It allows us to have almost "instant" feedback from the server . Redis is a in-memory , key:value store . Redis supports abstract data types like hashes , sets and lists . Also the pub-sub system allows you to subscribe to messages from a certain channel and so on which can be used for notification systems , chat rooms and so on.