Link to home
Start Free TrialLog in
Avatar of Whing Dela Cruz
Whing Dela CruzFlag for Anguilla

asked on

Traffic: Asp server side

Hi experts, I wanted to know how server pc handle the multiple clients while accessing the data at the same time. I am beginner developing web programming, and have a little background of vb6 language. Here what I exactly wanted to know, I have a server side Asp named, GetProduct.asp When in terms of response to the client upon the request, does it matter the response of it base on the number of clients having a request? Since I've only one GetProduct.asp How could the server handle it? Let's say, for example 1,000 clients who have requested to inquire the product at exactly the same time, does the response of the server will cause a delay because of the multiple request? if it could cause the traffic because of the numbers of request, should I need to assign GetProduct.asp per client? I hope you (experts) can give some insight about this. Thank you!
Avatar of Chinmay Patel
Chinmay Patel
Flag of India image

Hi Whing,

When a web server receives first request, it checks if this request has a session id. If the session id is not present in the request, it sends back a cookie to the requester (browser). This session id is unique, now when browser sends next request to the server it embeds the session id in HTTP headers. If a session id is found then the current requester is identified uniquely. So it does not matter if you have 1000 clients as long as they send a request without session id they will be identified uniquely.

above description is bit crude, I would suggest to have a look at this link https://www.w3schools.com/asp/asp_sessions.asp for details.

Feel free to ask more queries if you have more questions/doubts.

Regards,
Chinmay.
Avatar of Whing Dela Cruz

ASKER

Hi Chinmay.  you said;
When a web server receives first request, it checks if this request has a session id

How do I set session id? I used the code below as a browser or client side to request to the server. Can you tell me if this code has a session id? another thing I found in the code on server side is
response.expires=-1
Can you tell me also what does it mean -1.  Thank you!

Browser or client side

<script>
function GetAllProduct(x)
{
	if (window.XMLHttpRequest)
	  {
	  xmlhttp = new XMLHttpRequest();
	  }
	else
	  {
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (this.readyState==4 && this.status==200)
	    {
	        	document.getElementById("deptor-7").innerHTML = this.responseText;
	    }
	  }                                             
		xmlhttp.open("GET","GetProduct.asp?a="+ "2123", true);
		xmlhttp.send();
}
</script>

Open in new window


Server side, Asp

<%
On Error Resume Next

dim bcode, db, k, l
Code = request.querystring("a")

response.expires=-1

set cn=Server.CreateObject("ADODB.Connection")
cn.ConnectionString = "driver={SQL Server};Server=SkyBlue;uid=sa;pwd=100;database=" & "Mydb" & ""
cn.Open

If Err.Number <> 0 Then
      Response.Write(  Err.Number & "|" & Err.Description )
      response.end()
End if

Set rs = cn.Execute ("Select some codes here..")       
   With rs
       If rs.BOF = True Then 'Not exist
            response.write("Res-n50")
            response.end()
      else
            response.write("Res-n100")
            Response.end()
      End If
   end with
On Error GoTo 0
%>

Open in new window

Hi Whing,

Please do have a look at the article I shared earlier. It has explained Session in greater details.

Answering your first query, you don't have to worry about it ASP does it for you. If you want to check session id you can check the cookie that is in your browser cache OR you could write this code somewhere in your page:

<%
Response.Write(Session.SessionID)
%>

Open in new window


and from,https://www.w3schools.com/asp/prop_expires.asp

The Expires property sets how long (in minutes) a page will be cached on a browser before it expires. If a user returns to the same page before it expires, the cached version is displayed.

When you set it to -1, it means the page will be never cached, so when user hits the back button, browser will still request page from the server and display it rather than the content from the browser cache.

Regards,
Chinmay.
Thank you ChinMay, for your time. Lastly, base on the code I have posted from the client side to server side are capable of handling multi users who would access the server  side at the same time? Or do I need to modify it or add something to help avoid traffic. As far as I understood from reference site you have provided  to me sir, the code is capable of handling the issue already. So, I am right to conclude that the Asp server side base on the code above does not matter on number of request from the clients side when in terms of traffic? Or the delay of response from the server is not because of the number of clients accessing the server.  Hoping you sir more further explanation about this. Thank you so much!
ASKER CERTIFIED SOLUTION
Avatar of Chinmay Patel
Chinmay Patel
Flag of India 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
Thank you so much sir...