0

I'm searching for the best pratices to threat massive requests using jQuery ajax. Basically I have this situation:

var req = 0;
var p; // global scope
function getServerLoad() {
    p = $.ajax({
        url: 'system/sysload/get-server-load/'+req,
        method: 'get',
        dataType: 'json',
        timeout: 1000,
        success:  function(r) {
            if (r.success) {
                // print server loads
            } else {
                // abnormal situation
            }
        },
        error: function() {
            // http error or timeout action
            p.abort();
        }    
    });
    req++;
}

Looking at Browserscope in my Firefox 15 I can do at max 17 connections and only 6 connections per Hostname.

In this case I tried one solution: make a wildcard CNAME at DNS and point r[1...999999].mydomain.com to www.mydomain.com, but Firefox doesn't allows connection to subdomain. I think will be threathed like an XSS.

I have another idea analyzing Google Suggest and this post (In Portuguese).

http://danilow.wordpress.com/2009/05/28/google-suggest-nao-e-ajax/

In resume, in firsts versions of Google Suggest it doesn't uses Ajax. It make get requests by creating and replacing dynamic <script> elements - it's a smart solution because some older browsers doesn't suports XmlHttpRequest component, and by replacing old requests under user typing an search term will have only 1 (one) concurrent search request - it's because every new onkeyup event will overwrite the last request.

By the way... I see similar questions in stackoverflow, but specifically in a enviroment with Linux / PHP / Apache<<--reverse-proxy-->>nginx, somebody have a nice solution?

PS: sorry for the bad english.

Thanks in advance!

4

1 回答 1

0

最后,我找到了一种创建 DNS 通配符的解决方案,例如 *.myappdomain.com

并且在跨域中使用 JOSNP 进行 ajax,就像一个魅力。

于 2012-12-07T05:06:49.157 回答