What is a Comet?
“Comet is a programming model that allows web servers to push data to the client browser without having any need for explicit requests.”
Comet is also called as server push technology (or Ajax Push technology). Alex Russell (key member of Dojo Toolkit project) calls this server-push technology a Comet, which is based on long live Http connection and has no need to install plugins in the browser.
Due to the slow development of browser technology, there is no good support for the implementation of Comet, and it is difficult to provide a perfect solution to implement server-push in the application of browser. In past many years, because of the consistent demand for Comet and the extensive use of AJAX technology in various applications, Comet starts getting more attention.
Architecture of Comet:-
The architecture divided into two phase request and response phase.
- Push the data to the clients only when the data at the server side changes without having any need for the client to explicitly request. Here the connection is always initiated by server only.
Application of the Comet:-
- Gmail uses this technology whenever new mails are received
- Meebo chat system
- Financial trading systems
- Web-based real-time monitoring system
- No redundant calls (request/response) are made to the server from the client, when there are no updates at the server side. The result is increase in server performance, network performance, and preserves the server maintenance time.
- Comet allows more number of clients at a time to connect to server compared to AJAX. Because in AJAX with increased no. of clients, the web server may get overloaded due to multiple requests arriving simultaneously.
- Firewalls might terminate connections after some time. So re-establishment of connection may be required.
- The HTTP/1.1 specification suggests only two simultaneously connections between the client and server. Comet needs a new connection established to fetch each URL.
- This technique can have some scalability issues.
- Every request is serviced by a single thread from the thread pool. A thread pool which launches a thread for every new request in server applications may run out of threads if they are used to keep alive the connection to the client. Such implementations rule out the support for comet. Connections on the web server need to be preserved and serviced by different threads when the data needs to be sent.