Link to home
Start Free TrialLog in
Avatar of fleshlight
fleshlight

asked on

CF 5 - Slow Page - Session errors?

I'm having too many slow page entries in the server log.  I've tuned the db's, using stored procedures and cached queries.  Pages process under 50ms.  I've done all the performance monitoring, and can not find a reason that I'm getting so many slow page entries.  I suspect that there has to be a problem with our session managment.  Could there be a problem with my application file?


<cfapplication name="appname" clientmanagement="yes" sessionmanagement="Yes" setclientcookies="yes" sessiontimeout="#CreateTimeSpan(0, 2, 0, 1)#" applicationtimeout="#CreateTimeSpan(2, 0, 0, 1)#">

<cflock name="#Session.CFID#" timeout="5">
      <cfparam name="Session.Cart" default="">
      <cfparam name="Session.LastPg" default="index.cfm">
      <cfparam name="Session.CustID" default="0">
      <cfparam name="Session.OrderNo" default="0">
      <cfparam name="Session.SaveToCookie" default="0">
</cflock>
<cfif not isDefined('Session.CustInfo')>
      <cflock name="Session.CFID" timeout="5">
            <cfset Session.CustInfo=querynew("FName,LName,Company,Address1,Address2,City,State,Zip,Country,Phone,Email,Comments,ShipTo,inCookie,Maillist")>
      </cflock>
</cfif>

<cfif not isDefined('Session.ShipTo')>
      <cflock name="Session.CFID" timeout="5">
            <cfset Session.ShipTo=querynew("FName,LName,Address1,Address2,City,State,Zip,Country")>
      </cflock>
</cfif>

<cfif not isDefined('Session.CardData')>
      <cflock name="Session.CFID" timeout="5">
            <cfset Session.CardData=querynew("CardType,NameonCard,CardNumber,CVV2,Expiry")>
      </cflock>
</cfif>

<cfset curPath = ReplaceNocase(CGI.SCRIPT_NAME,"#GetFileFromPath(CGI.SCRIPT_NAME)#","")>
<cfif #LCase(GetFileFromPath(CGI.SCRIPT_NAME))# eq 'order.cfm' or #LCase(GetFileFromPath(CGI.SCRIPT_NAME))# eq 'cart.cfm'>
      <cfset regLnk="http://#CGI.SERVER_NAME##curPath#">
<cfelse>
      <cfset regLnk="">
</cfif>
<cfset cfQTrailer="CFID=#CFID#&CFTOKEN=#CFTOKEN#">
<cfparam name="ContQuery" default="0">
ASKER CERTIFIED SOLUTION
Avatar of jyokum
jyokum
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fleshlight
fleshlight

ASKER

site does 150k visitors per day..   <cflock scope="session" timeout="5"> versus <cflock name="#Session.CFID#" timeout="5"> ?
i've always gone with the scope attribute but whatever works for you.
is there another way to do this? so that it won't put too much load on the cpu.
<cfif isDefined('id')>
      <cfset newID=''>
      <cfloop from="1" to="#len(id)#" index="x">
            <cfif isNumeric(Mid(id,x,1))>
                  <cfset newID='#newID##Mid(id,x,1)#'>
            </cfif>
      </cfloop>
      <cfset id=#newID#>
</cfif>
You say pages process under 50 ms, that is excellent isn't it?

Where exactly do you think things are slow?
yes, the tracker says that the total execution time is 32 ms per page. but the server.log reports that there are some connections that runs for more than 10 secs. on the same page.

i'm not sure where this is coming from, and we've tried to reproduce the said report by running at different types of connections, but we're still weren't able to reproduce it.

Can you show me some of those entries, I assume you are talking about the CF server.log? I haven't seen any entries in there recording execution time, but it could just be something that I just don't experience ???
this is faster but we're talking in the range of < 0.1 ms, nothing to get excited over

<cfscript>
if(isDefined('id')) id=REReplace(id,'[^[:digit:]]','','ALL');
</cfscript>
i often have this report from server.log

"Warning","2532","02/09/04","19:41:46",,"Template: D:\Inetpub\wwwroot\main\products.cfm, Ran: 10 seconds."
"Warning","2516","02/09/04","19:41:48",,"Template: D:\Inetpub\wwwroot\main\products.cfm, Ran: 10 seconds."
"Warning","2584","02/09/04","19:41:49",,"Template: D:\Inetpub\wwwroot\main\products.cfm, Ran: 11 seconds."
"Warning","2524","02/09/04","19:41:53",,"Template: D:\Inetpub\wwwroot\main\products.cfm, Ran: 11 seconds."

although i've already cutdown several codes to make it run faster, but still it didn't work.
what the code on products.cfm look like?
<cfsilent>
      <cfinclude template="includes/dbase.cfm">
      <cfif isDefined('id')>
            <cfquery name="qryChkCat" datasource="#DSN#" CachedWithin="#CreateTimeSpan(0,1,0,0)#">
                  SELECT * FROM tbl_categories WHERE catz_id=#id#
            </cfquery>
            <cfif #qryChkCat.recordcount# is 0><cflocation url="index.cfm"></cfif>
      <cfelse>
            <cflocation url="index.cfm">
      </cfif>
      <cfquery name="qryProducts" datasource="#DSN#" CachedWithin="#CreateTimeSpan(0,1,0,0)#">
            EXEC sp_qryProducts @CatzID = #id#
      </cfquery>
      <cfset tdCount=0>
      <cfparam name="prodCounter" default="0">
</cfsilent>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<cfinclude template="scripts/css01.cfm">
<title>Products Page :: Fleshlight.Com</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body text="#999999" link="#999999" vlink="#999999" alink="#999999" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="100%" height="100%"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td bgcolor="dbdbdb"><table width="100%" border="0" cellspacing="1" cellpadding="0">
              <tr>
                <td width="180" height="30" align="left" valign="middle" background="images/sub_up_bg.jpg" bgcolor="#FFFFFF"><cfinclude template="includes/supportLnk.cfm"></td>
                <td colspan="2" align="left" valign="middle" background="images/sub_up_bg.jpg" bgcolor="#FFFFFF"> <cfinclude template="includes/phne.cfm"></td>
              </tr>
              <tr>
                <td colspan="3" background="images/blue_fl10.gif"><a href="<cfoutput>#regLnk#index.cfm?#cfQTrailer#</cfoutput>"><img src="images/blue_fl10.jpg" alt="Welcome to Fleshlight.Com" width="177" height="60" border="0"></a></td>
              </tr>
              <tr align="right">
                <td height="25" colspan="3" bgcolor="fafafa"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
                    <tr align="center">
                      <td align="center" background="images/sub_bg.jpg"><cfinclude template="includes/infoLnks.cfm"></td>
                    </tr>
                  </table></td>
              </tr>
              <tr>
                <td align="center" valign="top" bgcolor="fefefe"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td background="images/flTbl_shadow02.gif"><img src="images/flTbl_shadow02.gif" width="1" height="24"></td>
                    </tr>
                  </table>
                  <cfinclude template="includes/prodLnks.cfm"></td>
                <td align="center" valign="top" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td align="right" background="images/flTbl_shadow02.gif"><img src="images/flTbl_shadow02.gif" width="1" height="24"><img src="images/flTbl_shadow02.gif" width="150" height="24"></td>
                    </tr>
                  </table>
                  <table width="93%" border="0" cellspacing="3" cellpadding="0">
                    <tr>
                      <td height="25" align="left" valign="middle"><div align="justify"><strong><font color="183958" size="3"><cfoutput>#qryChkCat.catz_name#</cfoutput></font></strong><br>
                        </div></td>
                    </tr>
                    <tr>
                      <td align="left" valign="top"><div align="justify"><font color="404040" size="2"><cfoutput>#qryChkCat.catz_longdesc#</cfoutput></font><br>
                        </div></td>
                    </tr>
                  </table>
                  <BR> <BR>
                          <table width="93%" border="0" cellspacing="3" cellpadding="2">
                    <tr align="center" valign="middle">
                              <cfoutput query="qryProducts">
                              <cfsilent>
                                    <cfset refMoreInfo = "prodinfo.cfm?id=#prod_id#">
                                    <cfif #LTrim(prod_moreinfo)# gt "">
                                          <cfset refMoreInfo = "#prod_moreinfo#">
                                    <cfelse>
                                          <cfset refMoreInfo = "prodinfo.cfm?id=#prod_id#">
                                    </cfif>
                              </cfsilent>
                              <FORM action="cartpro.cfm?#cfQTrailer#" method=post name="frmItem#prodCounter#" id="frmItem#prodCounter#" onSubmit="javascript:return chkSelect#prodCounter#();">
                      <td width="50%"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
                          <tr>
                            <td align="left" valign="top" bgcolor="f5f5f5"><table width="100%" height="100%" border="0" cellspacing="1" cellpadding="6">
                                <tr bgcolor="##FFFFFF">
                                  <td colspan="2"><font color="BB0009"><strong><font color="183958">#qryProducts.prod_name#</font></strong><font color="183958">
                                    <font color="BB0009"><!---(best seller)---></font></font></font></td>
                                </tr>
                                <tr>
                                  <td width="30%" align="center" valign="top" bgcolor="##FFFFFF"><table width="80" border="0" cellspacing="5" cellpadding="0">
                                      <tr>
                                        <td align="center" valign="middle"><a href="#refMoreInfo#"><img src="images/products/#qryProducts.image_sm#" alt="#qryProducts.prod_name#" border="0"></a></td>
                                      </tr>
                                      <tr>
                                        <td align="right" valign="middle"> <a href="#refMoreInfo#"><font size="1">view
                                          larger</font> <img src="images/zoom.jpg" width="13" height="12" border="0"></a></td>
                                      </tr>
                                    </table></td>
                                  <td align="center" valign="top" bgcolor="##FFFFFF"><table width="98%" border="0" cellspacing="2" cellpadding="0">
                                      <tr>
                                        <td><strong>
                                          <INPUT type=hidden value="#qryProducts.prod_id#" name="Product_ID">
                                                              <input name=hTrigs type=hidden id="hTrigs" value=1>
                                        </strong></td>
                                      </tr>
                                      <tr>
                                        <td>#qryProducts.prod_desc#</td>
                                      </tr>
                                      <tr>
                                        <td><table width="101%" border="0" cellspacing="0" cellpadding="0">
                                            <tr>
                                              <td><img src="images/post.gif" width="15" height="16">
                                                <a href="#refMoreInfo#"><font color="BB0009" size="1">More
                                                Info</font></a> <strong><font color="##CCCCCC"><img src="images/spacer.gif" width="8" height="8"></font></strong><strong></strong><strong></strong></td>
                                            </tr>
                                            <tr>
                                              <td><img src="images/jack.gif" width="13" height="20">
                                                <a href="##"  onClick='javascript:window.open("HowToUse/howto.html", "HowToUse", "toolbar=no,status=no,menubar=no,scrollbars=no,width=700,height=500");'><font color="##BB0009" size="1">How
                                                to use</font></a></td>
                                            </tr>
                                          </table></td>
                                      </tr>
                                                        <tr>
                                        <td> <strong>Price: <font color="183958">$#Decimalformat(prod_retailprice)#</font></strong></td>
                                      </tr>
                                      <tr>
                                        <td><FONT face="microsoft sans serif, ms sans serif, arial, tahoma" size=-2>
                                          <INPUT maxLength="5" size="3"  value="1" name=Quantity>
                                        </FONT>                                          <font color="##003366" size="1">Quantity</font>
                                        </td>
                                      </tr>
                                                        <cfif (#LTrim(qryProducts.prod_opts)# eq '' or #qryProducts.prod_opts# eq 0) OR (#qryProducts.prod_id# eq "53")>
                                                              <input name="sOption" type="hidden" id="sOption" value="0">
                                                        <cfelse>
                                                        <tr>
                                        <td>
                                                                  <select name="sOption">
                                                                    <option value="-">Choose selection:</option>
                                                                    <cfloop list="#qryProducts.prod_opts#" index="opts">
                                                                    <cfsilent>
                                                                              <cfquery name="qrySelections" datasource="#DSN#" CachedWithin="#CreateTimeSpan(0,1,0,0)#">
                                                                                    EXEC sp_qryProdOpts @Opt_id = #opts#
                                                                              </cfquery>
                                                                    </cfsilent>
                                                                    <option value="#qrySelections.opt_id#">#qrySelections.opt_name#<cfif #qrySelections.opt_price# gt 0> : +$#decimalformat(qrySelections.opt_price)#</cfif></option>
                                                                    </cfloop>
                                                                  </select>
                                                            </td>
                                      </tr>
                                                        </cfif>
                                                        <cfif #qryProducts.prod_id# eq "53">
                                                        <tr>
                                                              <td colspan="3" valign="top"><strong><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Wonder
                                                                  Wave Insert:<br>
                                                                  <select name="sOption1">
                                                                    <option value="-">Choose selection:</option>
                                                                    <cfloop list="#qryProducts.prod_opts#" index="opts">
                                                                        <cfsilent>
                                                                        <cfquery name="qrySelections" datasource="#DSN#" CachedWithin="#CreateTimeSpan(0,1,0,0)#">
                                                                              EXEC sp_qryProdOpts @Opt_id = #opts#
                                                                        </cfquery>
                                                                        </cfsilent>
                                                                        <option value="#qrySelections.opt_id#">#qrySelections.opt_name#
                                                                        <cfif #qrySelections.opt_price# gt 0>
                                                                          : +$#decimalformat(qrySelections.opt_price)#
                                                                        </cfif>
                                                                        </option>
                                                                    </cfloop>
                                                                  </select>
                                                                  </font></strong><br>
                                                                  <strong><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Super
                                                                  Tight Insert:<br>
                                                                  <select name="sOption2">
                                                                    <option value="-">Choose selection:</option>
                                                                    <cfloop list="#qryProducts.prod_opts#" index="opts">
                                                                        <cfsilent>
                                                                        <cfquery name="qrySelections" datasource="#DSN#" CachedWithin="#CreateTimeSpan(0,1,0,0)#">
                                                                              EXEC sp_qryProdOpts @Opt_id = #opts#
                                                                        </cfquery>
                                                                        </cfsilent>
                                                                        <option value="#qrySelections.opt_id#">#qrySelections.opt_name#
                                                                        <cfif #qrySelections.opt_price# gt 0>
                                                                          : +$#decimalformat(qrySelections.opt_price)#
                                                                        </cfif>
                                                                        </option>
                                                                    </cfloop>
                                                                  </select>
                                                                  <br>
                                                                  Super Ribbed Insert:<br>
                                                                  <select name="sOption3">
                                                                    <option value="-">Choose selection:</option>
                                                                    <cfloop list="#qryProducts.prod_opts#" index="opts">
                                                                        <cfsilent>
                                                                        <cfquery name="qrySelections" datasource="#DSN#" CachedWithin="#CreateTimeSpan(0,1,0,0)#">
                                                                              EXEC sp_qryProdOpts @Opt_id = #opts#  
                                                                        </cfquery>
                                                                        </cfsilent>
                                                                        <option value="#qrySelections.opt_id#">#qrySelections.opt_name#
                                                                        <cfif #qrySelections.opt_price# gt 0>
                                                                          : +$#decimalformat(qrySelections.opt_price)#
                                                                        </cfif>
                                                                        </option>
                                                                    </cfloop>
                                                                  </select>
                                                                  <br>
                                                                  <br>
                                                                  </font></strong> </td>
                                                        </tr>
                                                        </cfif>
                                      <tr>
                                        <td align="center" valign="middle">
                                                                  <script language="JavaScript" type="text/JavaScript">
                                                                        function chkSelect#prodCounter#() {
                                                                              <cfif not (#LTrim(qryProducts.prod_opts)# eq '' or #qryProducts.prod_opts# eq 0)>
                                                                              <cfif #qryProducts.prod_id# eq "53">
                                                                              if(document.frmItem#prodCounter#.sOption1.value=="-") {
                                                                                    alert('An option selection/entry is required!');
                                                                                    document.frmItem#prodCounter#.sOption1.focus();
                                                                                    return false;
                                                                              }
                                                                              if(document.frmItem#prodCounter#.sOption2.value=="-") {
                                                                                    alert('An option selection/entry is required!');
                                                                                    document.frmItem#prodCounter#.sOption2.focus();
                                                                                    return false;
                                                                              }
                                                                              if(document.frmItem#prodCounter#.sOption3.value=="-") {
                                                                                    alert('An option selection/entry is required!');
                                                                                    document.frmItem#prodCounter#.sOption3.focus();
                                                                                    return false;
                                                                              }
                                                                              
                                                                              document.frmItem#prodCounter#.sOption.value = "";
                                                                              document.frmItem#prodCounter#.sOption.value = document.frmItem#prodCounter#.sOption1.value + "," + document.frmItem#prodCounter#.sOption2.value + "," + document.frmItem#prodCounter#.sOption3.value;
                                                                              
                                                                              <cfelse>
                                                                              if(document.frmItem#prodCounter#.sOption.value=="-") {
                                                                                    alert('An option selection/entry is required!');
                                                                                    document.frmItem#prodCounter#.sOption.focus();
                                                                                    return false;
                                                                              }
                                                                              </cfif>
                                                                              </cfif>
                                                                              if(document.frmItem#prodCounter#.Quantity.value.match(/^[0-9]{1,32}$/)) {
                                                                                return true;
                                                                              } else {
                                                                                    alert('Please enter a Numeric Value');
                                                                                    document.frmItem#prodCounter#.Quantity.value = document.frmItem#prodCounter#.Quantity.value.replace(/[^0-9]/g, '');
                                                                                    return false;
                                                                              }
                                                                        }
                                                              </script>
                                                                  <cfif #qryProducts.letBuy#>
                                                                  <input name="bn_grab" type="image" id="bn_grab" src="images/grabit.jpg" border="0">
                                                                  </cfif>
                                                            </td>
                                      </tr>
                                    </table></td>
                                </tr>
                              </table></td>
                          </tr>
                        </table></td>
                                  </FORM>
                                    <cfset tdCount=#tdCount#+1><cfset prodCounter=prodCounter+1>
                              </cfoutput>
                    </tr>
                  </table>
                <BR> </td>
                <td width="119" align="center" valign="top" bgcolor="fefefe"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td background="images/flTbl_shadow02.gif"><img src="images/flTbl_shadow02.gif" width="1" height="24"></td>
                    </tr>
                  </table>
                          <cfif #id# eq 1002>
                                <cfinclude template="includes/cCatzLnk02.cfm">
                          <cfelse>
                        <cfinclude template="includes/cCatzLnk.cfm">
                          </cfif>
                        </td>
              </tr>
              <tr valign="middle" > 
                <td height="43" colspan="3" align="center" background="images/header_bg.gif"><cfinclude template="includes/footer.cfm"></td>
              </tr>
            </table>
          </td>
        </tr>
      </table></td>
  </tr>
</table>
</body>
</html>
could you change this procedure to accept a list as the parameter instead of an individual ID? I don't imagine your getting a lot of benefit from the caching. CF only caches a specific # of queries (set in CF Admin)... each time you pass in a new #opt#, your caching a new query.

<cfquery name="qrySelections" datasource="#DSN#" CachedWithin="#CreateTimeSpan(0,1,0,0)#">
EXEC sp_qryProdOpts @Opt_id = #opts#
</cfquery>
9999 queries..  we've been tuning it for weeks.  our average req time is has been reduced greatly.  
Are you running the CF server on the same machine as the SQL Server? If so this is gonna cuase everything to run slower under heavy load. Watch your SQL performace my guess is it is performing slower under heavy load and this is holding up the product page. Additionally make sure your Stored Proceudres are compiled and stay compiled certain tasks in stored procedure force the SP to get destroyed and recompiled each time. I would look specifially at the one that is getting called each iteration of the loop.

jyokum:
>> I haven't seen any entries in there recording execution time, but it could just be something that I just don't experience ???

In the CF admin under Logging Settings there is a checkbox to check that reads "Log slow pages taking longer than <inputbox> seconds." thats how he is getting this info in the server log :)
The perfmon stats on the db look excellent.  the only cf requests that take 60+ ms are from our admin section (searching orders, etc..) and our forum.  neither the admin or forum queries are causing the problem, because we've still get entries at night (when nobody is using the admin section) and we've disabled the forum at the same time.  Average DB time is 7 ms.
Our slow page errors continue, but the application.cfm has improved.