您的位置:首页 > 运维架构 > 网站架构

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

2016-07-18 08:02 871 查看

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:
RequestTimeout
ActivityTimeout


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.

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

未完待续》。。。。。。。。。。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  bug json 500-error