Optimizing long polling on a dedicated server

扶醉桌前 提交于 2019-12-14 04:20:02

问题


Right now, I am hosting a site on a dedicated server, 8 GB ram, Intel Xeon E3 1230 V3. I am using long polling techniques in order to display information which gets added into a database consistently.

The problem is: so far, after around let's say 20 users come onto the site, it starts lagging and slowing down dramatically. I'm pretty sure the server is strong enough to handle way more people than that. Thus, I am not sure what exactly is the problem. Can long polling using Apache handle that many users? If not, how should I implement real-time information being displayed. And if it can, how should I configure Apache or anything in order to handle around 500-1000 concurrent users.

Any help is appreciated.

The js/Ajax script I'm using for long-polling is the following:

function waitForMsg() {
$.ajax({
    type: "GET",
    url: "updatelog.php?items=" + items,
    async: !0,
    cache: !1,
    timeout: 1e3,
    success: function(data) {
        var json = eval("(" + data + ")");
        getStatus(), "null" == json.initial ? $("div.betBox").load("displaylog.php") : (diff = json.items - json.initial, getdisplay()), setTimeout(waitForMsg, 1e3), items = json.items
    },
    error: function() {
        setTimeout("waitForMsg()", 1e3)
    }
})

}

来源:https://stackoverflow.com/questions/30205007/optimizing-long-polling-on-a-dedicated-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!