我實現心跳爲以下龍拉PHP和AJAX - 服務器性能
$.ajax({
cache:false,
timeout:8000,
type:"POST",
url:"someurl.php",
data:allFormValues,
error:function(){ alert("some error occurred") },
success:function(response){ //call some functions }
});
,並在服務器端
$time = time();
while(!proccessServer() && (time() - $time) < 60)
{
sleep(5);
}
,只是它調用的函數返回false循環會睡更多5秒,然後檢查 但問題是這個東西是吃我的資源CPU ,這是隻有當5個用戶測試它
我在這之前
window.setInterval(function(){
//I call a function here
}, 5000);
使用,但也有人在同一時間 吃,因爲很多要求
,也許我的應用程序的資源100K網上也我不考慮使用,因爲瀏覽器的WebSockets兼容性 你有什麼建議來解決這個問題? 任何幫助表示讚賞