Skip to content
Frug edited this page Oct 18, 2012 · 1 revision

Server load and traffic

To make things clear: HTTP is not the ideal protocol for a Chat.
If you want to have a real chat server you should go for IRC or Jabber.

While not overcoming the limitations of a stateless protocol, the AJAX technology at least made it possible to implement a web chat that does not bring down the server.

This AJAX Chat is implemented to be as resource efficient as possible:

  • The operations the server has to do are not complex, the queries to the database held simple
  • Most of the work is done on client side: The language handling, the BBCode, Hyperlinks, Emoticons and Commands replacement is all done by JavaScript.
  • Only updated data is sent to the clients to keep the traffic low.

Reducing server load and improving performance and responsiveness using the socket server

Since version 0.7 of AJAX Chat it's possible to further increase performance by using a Flash (client-side) and Ruby (server-side) based socket connection to push updates from the server. => see Socket Server

Reducing server load without a socket server

To reduce server load and traffic without using a socket server you have some configuration options:

The time between update calls can be configured in js/config.js - the default is 2 seconds (2000 milliseconds):

   // The time in ms between update calls to retrieve new chat messages:
   timerRate: 2000,

The chat upate can be delayed by setting the following option in js/config.js to false - this is set by default for the shoutbox:

   // If set to false the chat update is delayed until the event defined in ajaxChat.setStartChatHandler():
   startChatOnLoad: true,

The maximum users online can be configured in lib/config.php - the default is 100:

// Max users in chat (does not affect moderators or admins):
$config['maxUsersLoggedIn'] = 100;

If you're writing a custom user authentication integration for AJAX Chat you should make sure you're following the lazy initialization rule.