ASP.NET pages lag intermittently - sql

I'm using IIS 10, SQL Server 14, and .NET 4.5. I have made a website with just 4 pages of significance. Any one of them loads perfectly, every time. And quickly, even though they do a lot of work with datatables and database edits.
But if I open two browser windows (same session if it matters) and play around for a while loading pages in one window while the other is refreshing another of the pages every 3 seconds, it is only a matter of time until they freeze up for a bit. Sometimes only for 5 or 10 seconds. Often for over a minute, and sometimes for as long as 20 minutes.
What I've tried:
My first thought was SQL deadlock and I spent a long time down that rabbit hole. All my select statements now use WITH (NOLOCK). I've run SQL profiler, and there is no discernible rhyme or reason to which queries have long durations during these periods, and none are that long. The longest "StartTime - EndTime" on the trace is never more than 0.25 seconds. I added my own StopWatch control to my functions that do my cmd.ExecuteNonQuery() statements and another on the one that gets my datatables, and see the same thing: max elapsed times during the hangs of 250ms or thereabouts. Under "normal" lag/hang-free operation, the elapsed times typically record 0ms, and at most maybe 3ms. The jump of 100x during the hang is confusing and concerning, but don't at all account for the long periods of lag/hang. And each time this happens, it will only be 1 or 2 statements with that extended duration.
I turned my attention to debugging the page that refreshes every 3 seconds. I use a StopWatch there also, and the page always loads in under 3ms as measured from the first line of the form_load event to the last line of the form_unload event. What is interesting here, is that while it is hung, it sure LOOKS LIKE Chrome (my browser) is trying to load the page. The little circle is spinning, and it is just waiting. It never times out, even if it takes 20 minutes. But during that time it will never record the first debug entry of form_load. Once it finally resolves, it will run the page as well as ever. So in my log I'll see something like this (oldest entry at the bottom):
2021-02-07 11:52:21.703 unload
2021-02-07 11:52:21.700 load
2021-02-07 11:52:18.642 unload
2021-02-07 11:52:18.640 load
2021-02-07 11:50:37.820 unload
2021-02-07 11:50:37.817 load
2021-02-07 11:50:34.777 unload
2021-02-07 11:50:34.773 load
Note how the page loads quickly every time, and while there is normally a 3 second gap between loads, in one case there was almost a 2 minute gap.
Looking at my W3SVC1 logs, and lining it up to that same time, I see that there are entries (both POST and GET) for the pages with time-taken of around 90000 (not sure what units on that) where the entries before and after the problem are mostly in the 10-50 range.
I'm at a loss of what to look at next.

Related

How to setup Jmeter test to have a certain throughput?

I am trying to perform a load test, and according to our stats (that I can't disclose) we expect peaks of 300 users per minute, uploading files of different sizes to our system.
Now, I created a jmeter test, which works fine, but what I don't know how to fine tune is - aim for certain throughput.
I create a test with 150 users 100 loops, expecting it to simulate 150 users coming and going, and in total upload 15000 files, but that never happened because at certain point tests started failing.
Looking at our new relic monitoring, it seems that somehow I reached 1600 requests in a single minute. I am testing a microservice, running 12 instances, so that might play the role here for a higher number of requests, but even with it I expected tests to pass. My uploaded file was 600kb. In the end, I had 98% failure.
I reduced the file size to 13kb, at that point, I got 17% failiure.
So, there's obviously something with the time needed to upload the bigger file, but I don't understand what causes 150 thread/users in X loops to become 1600 at the same time. I'd expect Jmeter to never start a new loop with the same thread, unless the original user is finished. That being said - I'd expect tops 150 users in a given minute.
Any clarification on how to get exact number of users/threads running at the same time is well appreciated.
I tried to play with KeepAlive checkbox, I tried adding lifetime of request to 10 seconds (all them uploads get response earlier) - but then JMeter finished the Thread, and I had only 150 runs, no loops.
Thanks!
By default JMeter executes Samplers as fast as it can so there are 2 main factors which define the actual throughput (number of requests per unit of time):
JMeter configuration
Application under test response time
So if you're following JMeter Best Practices and JMeter has enough headroom to operate in terms of CPU, RAM, etc. - you are only limited by your application response time as JMeter waits for previous request to finish before starting a new one.
If you need to "slow down" your test execution consider adding i.e. Constant Throughput Timer to your Test Plan where you will be able to define the desired number of requests per minute

Why Action In console was Paused till the process is done

When I use the python or etc,
In using for'for' command,
I print the row count
Beacause it can help to expect how long does it takes time,
But In VBA, Printing line numbers in console is paused when it reach some levels
However, the process is still operating normally.
when it process is done,
suddenly all output messages are displayed on the console at once.
The performance of the PC is very good. ( i7 CPU / ram = 16gb)
Why happen like this?
I used below code,
Please refer to this code and capture.
for RowVarialbe = 2 to 100000
debug.print (RowVariable)
next RowVarialbe
I don't know why, but I have observed the same. Add a
DoEvents
inside the loop and you'll be fine. It'll slow down the process slightly, so you might want to do it every nth row instead (but if performance is an issue, you shouldn't use the console that much - it is a performance killer). Another bonus is that the DoEvents allows you to pause or halt the execution.

SQL Query perform slow with increasing users

I have an asp.net web application with SQL server 2014 express database. My application runs well until data entry records are less, but as the data entry records saving increases, not every time but sometime page takes too long to load back again. On save button, after insert/update query is executed, I have reloaded the page to get fresh data. The page takes 2-3 min to load and then it again starts running normally and there is no load. This happens at any time but not everytime. I kept a watch on Activity Monitor, the Processes peaks are high. It show recent expensive query, but that query hardly takes 1 second to run because every time it will have max 120 rows output. I have added all missing indexes, but no success since my query is already optimized. What could be the cause?

ASP.NET MVC page slow Time To First Byte

I have two views that I am refreshing every few seconds asp.net mvc. Every few views are refreshed since there is another program that is updating the database. It is taking a lot of time and it is random, what I mean by that is sometimes the first view reload time is slow and sometimes the second view reload time is slow. It is in 500ms or 50ms each for view1 and view2 or vice versa 500ms for view2 and 60ms for view1. I needs to reduce both the load time to 10ms. I have set the timer interval to 30 seconds and loading the views. I did sql profiler to see if the queries are taking a long time and it does not look like it. In dev tools TTFB time is showing as taking long and this is on my local machine with local webserver and sql. Please advise!
Thanks

timing a method's duration

I have a splash that displays at my app's startup while it loads data from a Web query. I'd like to make sure the splash displays for at least 3 seconds, but sometimes the load query takes less than this. However, I don't want this 3 seconds added to the time it takes to load the web data; I just want to make sure the minimum is 3 seconds.
In other words, can I time how long it takes to load the data, then maybe set a delay for the difference between that load time and 3 seconds, and make the splash hang on (using a selctor or something) for that extra amount of time?
I'd suggest that instead of doing it that way, you start a 3 second long timer when you start the load query. When each finishes, set a boolean to say that one finished and call a method that checks if both are done yet; if so, it's time to close the splash window. (sorry, no code examples - I'm not familiar with Objective C)