大量Json Data传输导致网站挂起/冻结

Bug

问题代码:不能传输约32万组Json数据:
这里写图片描述

var request = $.ajax({
type: 'GET',
url:'support/search/searchHelper.php',
data:{action:"Connect",        x x x xxxx1:$('#lastName').val(),
xxxx2:$('#otherName').val(),
xxxx3:yearArray,
xxxx4:$('#month').val(),
xxxx5:$('#day').val(),       
xxxx6:$('#xxx6').val(),
xxxx7:$('#age').val(),	        xxxx8:$('#xxx').val(),
xxxx9:$('#xxxx').val()
},
success: function(reply){
    if(reply == "report_Connect_Error"){
        report_Connect_Error("Failed in connect to Database");}
    else{
    $('.load_image').css('display','none');
    table = $('#resultTable').DataTable( {
            data: JSON.parse(reply),
            columns: [
                     { data: 'xxx1'},
                     { data: 'xxx2'},
                     { data: 'xxx3'},
                     { data: 'xxx4'},
                     { data: 'xxx5'},
                     { data: 'xxx6'},
                     { data: 'xxx7'},
                     { data: 'xxx8'},
                     { data: 'xxx9'},
                     { data: 'xxx10'},
                     ],
         rowCallback: 
         function(row, data ){                                                    if($.inArray(data.DT_RowId,selected_id) > -1 ){$(row).addClass('selected');}
        },
        columnDefs: [
                    { "visible": false,         
                      "targets": 0}
                    ]
});

Solutions

对Ajax进行操作:
- 添加异步代码 async:true :对我的这个没用
- 增加fastCGI:RequestTimeoutActivityTimeout

RequestTimeout :对我的这个没用

javascript
timeout: 3000000000

  • 增加Data type, 便于解析?但对我的这个没用
datatype : "json",
contentType: "application/json; charset=utf-8",

More info

FastCGI

It is a binary protocol for interfacing interactive programs with a web server. FastCGI is a variation on the earlier Common Gateway Interface (CGI); FastCGI’s main aim is to reduce the overhead associated with interfacing the web server and CGI programs, allowing a server to handle more web page requests at once.
From: Wiki


然后我继续往后面debug,发现问题出现在数据库上,貌似不能传送太大的数据量:
可以用 以下代码检测 LIMIT 5000

$query = "SELECT * FROM merged_datasets WHERE ".$conditions."LIMIT 5000";

以上都不是最佳解决方案,因为数据需要全部显示,不能设定Limitation.

考虑到周围使用同样服务器的情况,可能服务器处理不了那么多数据导致的。

未完待续》。。。。。。。。。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值