网页上的资源使用

Resource use on a webpage

我有一个网页使用 javascript 和 ajax 来调用处理一个数据库记录的另一个页面。在向页面发出另一个 ajax 请求之前,javascript 使用计时器 "rest"。

我的网络团队坚持认为这会给系统带来巨大的负载,即使如果直接加载调用的页面加载时间不到一秒。我看不到我是如何加载服务器的。我不确定是网络服务器还是数据库服务器性能受到影响。

这可能吗?还是他们吸的是好东西?网络团队认为,由于它经常调用,因此它一定是性能下降的罪魁祸首。

作为解决方法,我考虑过将处理记录的页面调整为每 30 秒到一分钟刷新一次,理论上这与我对 ajax 请求所做的相同.我这样设置的唯一原因是能够有一个 on/off 开关。

问题:它们是否正确?如何确保我的页面不占用资源。

谢谢

这里是javascript

        $(document).ready(function(){
    $("#btn-go").click(Start);
    $("#test").click(Stop);
});

var timer;
var counter = 0;
var timeOut = 30000;
var pause = 10000;
var bit = 0;
var data = null;
//stops the process
function Stop(){
    bit = 1;
    $("#response").append('<br/>***Stopped at - '+ getTime() + ' ***');
    $("#response").append('<br/>***Records Processed - '+ counter + ' ***');
}
//Starts the process
function Start(){
    bit = 0;
    $("#response").append('<br/>***Started at - '+ getTime()+ ' ***');
    Step1();
}

function Step1(){
    counter++;
    $.post('Step1.cfm', setTimeout(finalStep, timeOut));//,  setTimeout(Step2, timeOut));
    return false;
}

//Final Step
function finalStep(){
    //alert(getTime());
    $("#response").append('<br/>record updated at - '+ getTime());

    if(bit != 1)
        {
            Step1();

        }

}

function getTime()
{
    var now = new Date();
    var hours = now.getHours();
    var minutes = now.getMinutes();
    var seconds = now.getSeconds();
    var time = hours+":"+minutes+":"+seconds;
    return time;
}

处理记录的网页

<!--- the page checks the archive database table contact to see if any records match--->
<cfparam name="pblead" default="cfleadsource_prod">
<cfparam name="MARS" default="cfleadsource">

<cfquery name="GetRecord" datasource="#pblead#">
    select top 1 * from tmp_WirelessRepairListDec2014 where IsMatch = 1
    <!--- select * from contact where contactid = 2323924 --->
</cfquery>


<!-- check for phone matches-->
<cfquery name= "CheckPhone" datasource="cfLeadSourceArchive">
    select * from contact where phone='#GetRecord.phone#' or phone2 = '#GetRecord.phone#' or phone3 = '#GetRecord.phone#'
</cfquery>


<cfif CheckPhone.RecordCount eq 0><!--- no record found--->

    <!-- check for address matches-->
    <cfquery name="CheckAddress" datasource="cfLeadSourceArchive">
        select * from contact where mailingAddress = '#GetRecord.address#' or shippingAddress = '#GetRecord.locationAddress#'
    </cfquery>

        <cfif CheckAddress.RecordCount eq 0><!--- no record found set IsMatch to one for Archive Testing--->
            <cfquery name="SetForArchiveTest" datasource="#pblead#">
                update tmp_WirelessRepairListDec2014 set IsMatch = 2 where id = '#GetRecord.id#'
            </cfquery>

        <cfelse><!---address record found update database--->
            <!--update database 8 indicates that an address number matched-->
            <cfquery name="RecordFound" datasource = "#pblead#">
                update tmp_WirelessRepairListDec2014 set IsMatch = 8, cid = '#CheckAddress.contactid#', locationFound ='archive' where id = '#GetRecord.id#'
            </cfquery>
        </cfif>

<cfelse><!---phone record found update database--->
    <!--update database 9 indicates that a phone number matched-->
    <cfquery name="RecordFound" datasource = "#pblead#">
            update tmp_WirelessRepairListDec2014 set IsMatch = 9, cid = '#CheckPhone.contactid#', locationFound ='archive' where id = '#GetRecord.id#'
    </cfquery>
</cfif>

主页

<html>
<head>
<!--include link to jquery files-->
<script src="jquery-2.1.3.min.js"></script>
<!--<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>-->
<script src="CheckArchive.js"></script>

</head>
<body>
<h3>Check list against archive for Wireless list</h3>
<button id="btn-go">Start</button><button id="test">Stop</button>
<hr/>
<div id="response"></div>

</body>
</html>

经过数月的研究,我们得出结论,虽然这是一个非常简单的计划,但由于要比较的记录数量太多,所以效率很低。

我最终将整个过程移动到数据库,现在只是 运行 一个存储过程来执行此任务。

感谢大家的参与。

刚刚发现处理此问题的服务器只有 4GB 内存,并且正在 运行 连接 CF 服务器、DB 服务器、Web 服务器,处理 DNS 和 Active Directory