How to track and limit a large number of similar queries on a site

It is very easy to accidentally put the markup of another component in the table, and this will cause the nested components to be called repeatedly. 

For example, if you have 50 rows in a table, and you put 2 form snippets in each row, this will result in 2 * 50 additional requests, which will create an unnecessary load on the server. And this is only from one user. And if he opened 5-10 similar pages at once? What if several users do the same thing at the same time? As a result, it turns out that with a small attendance, a significant load is created on requests to the server and database.

How to avoid this is very simple, use the as-form-modal, as-form-link, sub_ and modal_ fields of the table row. Thus, the loading of a specific form will only go on the user's click. That is, there are tools for how to do it correctly, but no one is immune from errors, and you need a tool for identifying and correctly handling such situations. 

In this article, we will look at how to protect yourself from such "adversities".

To do this, the system has special settings in as. SystemOptions: 

{ "disableDebugMode": false, // ability to disable the display of debug messages in the browser console
    "doubleRequests.disableCheck": false, // disable control of the number of identical requests per page
    "doubleRequests.count": 3, // the threshold for the number of requests, after which the notification will go to trace with the dblreq code
    "doubleRequests.countLimit": 4, // after exceeding this threshold, the request will be discarded and a message will be displayed to the user
    "doubleRequests.duration": 2000, // time duration during which the number of requests is taken into account (in milliseconds)
}

In case of occurrence of 1 threshold (count), we simply fix it in trace. If the 2 threshold is reached, we block the requests and display a message on the page.This will prevent excessive server load.. 

You can add such a query to the project prevention to identify these situations: 

-- show too many dublicate requests per page
select top 200 itemID reqCount,
    dbo.as_stripHTML(replace(text, '
', char(10))) text,
	convert(nvarchar(20), created, 120) + iif(len(username)>0,  ' - ' +  username, '') details
	from as_trace where code='dblreq' order by id desc

Thus periodically looking at prevention you can find similar situations.

Falcon Space is a functional web development platform on a narrow stack MS SQL/Bootstrap. Falcon Space Gettting started
{sp-shortDemostandLinks}

Falcon Space Platform

This is a reduction in the cost of ownership

at the expense of fewer people to support

This is a quick change

while using the program

This is a modern interface

full adaptation for mobile devices

Note