I'm building a basic messaging system, and am currently checking for a user's message updates by querying the database every few seconds (running a php 'check' page initiated every 3 seconds using AJAX.
It works fine, but I'm curious as to how Facebook do it?
I notice two things...
1. If you load Facebook into your browser, typically there's no traffic unless something happens ie they aren't using AJAX to repetitively ping the database
2. When someone sends you a message, it instantly appears, and the speech bubble up top updates with the number of new messages - both without a page refresh.
Any ideas as to how are they doing this?