11-04-2012, 04:37 PM
Large Scale Web Chat Application
chat-report.pdf (Size: 631.64 KB / Downloads: 115)
Introduction
This report presents an overview of my semester project which happened
during the spring semester in the Distributed Information Systems Laboratory
at EPFL. The project was consisting in a research in push technologies
and in a practical application with the implementation of a chat.
Push Technologies for Web applications
Concepts
Web applications works onto the HTTP which is client-server, this means
the client initiate the connection, the server only responds to its request.
With the evolution of the web, people have wanted applications to be more
interactive and to be able to give live information to their users. We are
going to look at the dierent mechanisms to achieve this technique which is
called server push.
Comet
Comet is a term invented by Alex Russell of the Dojo project who was actually
joking about AJAX cleanser. The technology is known by several other
names like Ajax Push or Reverse Ajax but only refers to the possibility of
a server to "initiate" the communication in a web application using AJAX.
Thus, in this part we will only consider push using AJAX.
Long polling
An evolution of simple polling can be thought by remembering the beginning
of the Internet, when pages were loading slowly. Thus, we can build a special
server which does not respond until it has the information. From the point
of view of the client, it seems that the server is lagging but in fact this is the
key idea of Comet and it works pretty well!
Harder to implement:
On the server: we need software modications. A very problematic
one is certainly the C10K problem" which is a due to
the OS constraint and software limitations. When a server
which implements long polling receives more than ten thousands
requests, if it uses default blocking IOs, it will have to
keep in memory ten thousands threads. This consumes lot
of ressources in RAM memory can over ow. Thus classical
servers are now implementing powerful tools such as Asynchronous
Request Processing (ARP) for Java Servers which
permits non-blocking IO.
Architecture
After this research, Nicolas convinced me to try node.js for this project. It is
really interesting to work on new technologies and I thought I will be able to
learn a lot about webservers, scalable architectures and NoSQL databases.
Moreover I was not really good in Javascript so it was an opportunity for me
to learn this language which is becoming more and more popular.
The application
The application is a simple chat. The main program is contained in two les
(app.js and room.js). app.js denes the instructions to be executed for each
type of request. It create room objects which denition is in the room.js
le. Each rooms use three EventedBuer objects to handle messages, users
and les. EventedBuder is in fact a buer for which we have associated
four events: added, removed, changed and all. Each corresponding event is
triggered when an element is added, removed or changed in the buer. For
this, it denes a addListener(event, callback) method which save the callback
and calls it when the event happens.