Set a timeout every time a ping is received. Cancel previous timeouts. Note... you might want to add a fudge factor to your timeout to reduce noise)
var timerId;
function ping(deviceId) {
clearTimeout(timerId);
timerId = setTimeout(function() {
updateDb(deviceId);
}, 15000 + 500);
}
I'm doing something similar to you but will have 10,000 devices pinging every 15 minutes. I'll be using a different solution. I have a cron job (technically a Cloudwatch Event) that runs every 5 minutes to check which devices haven't pinged within the last 15 minutes.