CL1 webserver: <Anantsystems<Ad info>

    AspnetEmail.com   AspNetPro.com

related sites: <FREE Help> <ASP> <Asp.net> <worldwide>  
feedback: <lovethat> <hatethat> <thanks> <credits> <contact us>

Server Coding: Round-robin Scripts Table of Contents PrintView CL1
<Previous> Why Response.Buffer=TRUE is best

Databases & Sessions... Just Say No! <Next>


       

Round-Robin Code Execution by Charles Carroll

A common expression you will hear when shifting paradigms (Flat Earth to Round Earth, Cold-Blooded to Warm Blooded Dinosaurs, Traditional Applications to Web Apps) is that everything you know is wrong. Great.... My next question is "What is the right answer in this environment?". Often they have only learned to get rid of the wrong tactics, but are not so fluent in the new tactics. Here we will explain one of the correct things to do when coding an ASP page.

Scripts on a webserver run round-robin. If a script say x.asp is run by 100 people and 50 people are running y.asp then the server may be running:

Person1 x.asp lines 1-3
Person2 x.asp lines 1-3
Person1 x.asp lines 4-20
Person3 x.asp lines 1-3
Person4 x.asp lines 1-3
Person2 x.asp lines 4-10
Person1 y.asp lines 1-5
Person3 x.asp lines 4-6
etc.

If your code does something for example 3 lines later you may think it is inconsequential... 
Only 3 lines after all...
But the webserver may execute thousands of lines in other scripts before returning to your code. 
Hence if the task could be done on line 1 INSTEAD of line 3 that may conserve a resource for thousands of lines of code.

What most people do without thinking:

So if your process opens recordsets a couple of lines before manipulating them this could lead to more open recordsets for the total webserver than you think.

<%
rs1.open
rs2.open
rs3.open
rs4.open
...
process rs1
...
process rs2
...
process rs3
...
process rs4
rs1.close
rs2.close
rs3.close
rs4.close
%>

What they should do:

It is certainly more wasteful than

...
rs1.open
process rs1
rs1.close
...
rs2.open
...
process rs2
rs2.close

rs3.open
...
process rs3
rs4.close

rs4.open
..
process rs4
rs4.close

mostly because of the round-robin effect.

GetString, GetRows conserve resources

This is one of the many reason Getrows and GetString, can be so durn fast ala:
http://www.learnasp.com/learn/dbtablegetrows.asp
http://www.learnasp.com/learn/dbtablegetstring.asp
that code closes recordsets and connections as early as possible.

This is also why disconnected recordets can help an application perform better see:
http://www.learnasp.com/learn/dbtabledisconnected.asp

Server Coding: Round-robin Scripts Table of Contents PrintView
<Previous> Why Response.Buffer=TRUE is best

Databases & Sessions... Just Say No! <Next>

CL1 webserver: <Anantsystems<Ad info>

    AspnetEmail.com   AspNetPro.com

related sites: <FREE Help> <ASP> <Asp.net> <worldwide>  
feedback: <lovethat> <hatethat> <thanks> <credits> <contact us>