In my previous post, I proposed a way of trying to figger out where performance problems are.
Now I discovered a possible problem in our existing classic ASP website. On several places, the server tag:
<%Response.Buffer = false%>
Now what exactly happens when this is set on top of the page?
When the Response.Buffer is set to false, every Response.Write is sent immediately to the client. If response buffering is enabled, then these writes are grouped and sent to the client in one larger, more efficient transaction. From IIS 5 this is by default enabled on the server (they did that for a reason).
In our case there are loops and sometimes these loops go over 100 rows. In the loop there are more then 50 Response.Write tags. So image when the Response.Buffer is set to false. It will result in 100 * 50 connections from server to client. that's 5000 connections. Now when the load on the server gets higher and 100 users are opening the same page on the same time, it's 500000 connections. This will blow up the server and breaks performance.
|5000 Response.Write||Response.Buffer = false||Response.Buffer = true|
|1 user||5.000 connections||1 connection|
|100 users||500.000 connections||100 connections|
If your page is very large, and the processing very long you may want to periodically flush the response buffer to the client. This will ensure that the client steadily receives data and does not time out. If you are building large tables in a loop you may want to add Response.Flush every 100 rows or more.
It can also happen that the Buffer Limit is reached and the response is cancelled. By default the Response Limit is set to 4Mb. You could increase the to max 20Mb. But even better, you could improve the page itself by using Response.Flush every n rows or simply check if the page could be rewritten. You do not want to sent page over 10Mb to clients.
Responsiveness can be achieved by other ways, like showing a loading message, Response.Flush it and hide it in the end of the response. Or flush loops over n number of rows.
I have several techniques to analyse an old asp application.
Off course reading the code, but some large pages can be totally unreadable.
In my case all calls to the DB where performed through the same functions. So there I put a file logger. Now all SQL calls to the DB are logged in a file. Later I could analyse them and have some more idea what's going on.
stringToLog = FormatDateTime(Now()) & ": " & stringToLog
I have many friends in Brazil. Meeting them and drinking chimarrão together aways been great times. So now I even have my own stack of herbs here in the freezer (Directly from Brazil, the imported herbs in the shops in Belgium are really bad!)
The only hard part sometimes is to make the pot of chimarrão.
I found a very easy and good way, where the herbs keep fixed and you can enjoy all day! They call it the ant heap.
Here are the steps to follow:
1) Fill the pot with water to the top.
2) Insert the BOM (pipe) and lower the water level until a few cm above the head of the pipe.
3) Fill it with herbs until you get a small hill on top:
Do not push the herbs, just let it fall on int the pot.
4) Make a small hole with your finger in the other side as where the pipe goes in:
(Do not try to push on the herbs, just swipe the herbs on the sides to get a small hole there.)
5) Pour a little bit of water in the hole:
Really not too much, just a bit, to get the herbs sticky where we will make the hole go down to the bottom later.
6) Leave it for 2 minutes, then gently make the hole deeper with a spoon or fork end: