instead of using setInterval, calculate the request time (usually using a unix timestamp in seconds), how much for 10 seconds, in the server side, use setTimeout
the remaining time, so it will vary from user to user, on their ping time (or the business of the site)
function heartbeat(){
$.ajax({
'url': '/where/',
'success': function(data){
setTimeout(heartbeat, parseInt(data) * 1000);
}
});
}
heartbeat(); // initialize it
in the server side, (like in PHP), you would do
<?php
// do your stuff
echo (time() - (int)$time_requested) + 10; // it will vary per user, so if it takes 2 second, it will be 12, if it returns imediately, returns 10