Reputation: 85715
Here the problem.
I have my site hosted on a shared hosting for asp.net mvc. I login and say and fill in one of my forms in and want to submit it. The submit is done using jquery ajax request.
Now all of a sudden it will hang and won't do something for like 20 seconds then all of a sudden it will finish my request of saving the form.
Now here is the thing. I could do the same request 10 times and the other 9 times might take like 200-500 milliseconds to finish. So why is there such a time difference?
It also seems if I do a request then do some other request both request will be go fast but if I stop and come back a couple mins the first request might take a while to complete(seems to range from 5 to 20 seconds).
But really it just seems to happen whenever it feels like. Some times I can almost go an entire session without seeing it. Some times I get multiple ones in a row and have to refresh the page and then it will go fast again.
So what causes this?
Like I have no clue what causes this or how to test this so I can't even begin to fix it.
Upvotes: 2
Views: 2362
Reputation: 22485
i've also noticed on shared hosting that the app can drop out of global memory and require a recompile on the 1st revisit to the site. this process (recompilation) obviously is related to the size of your codebase, but 15-20 seconds doesn't sound unreasonable for a small-medium sized site to be recompiled.
to get around this, make sure that all your views are compiled and not just your core DLL code.
Upvotes: 1
Reputation: 22760
Have you added logging into your application so that you can identify lags in your server code?
As well as Fiddler and Firebug, I'd be implementing stacks of logging. It may be that a particular request, on the server, is being held up.
Logging will narrow down the possibilities of where it is.
Upvotes: 0
Reputation: 37648
I'd be curious if you have tested this at different times throughout the day, or if you just deployed and noticed the lag. It could be that there are backups running on the server or other administration jobs that cause the behavior. The problem is that on a shared host you have very few options for identifying the cause of performance issues. If the lag happens all the time, it is likely one of the following things:
You could do a reverse DNS lookup for your IP and see what else is running. You could ping the server while you are waiting for a response and see if the network latency goes up, or if the response comes uniformely fast. And finally, you could ask a support person to take a look.
Upvotes: 0
Reputation: 116977
The first place to start is with a network analyzer like Fiddler or Firebug. You should be able to tell pretty easily if the problem is from network lag or if it's actually just waiting on a response from the server. Likely it's the server.
The next step is to be able to see what is going on with the CPU and memory when you encounter a slow request, and if it's accessing a database, you need to be able to see what's going on there. Perhaps there is a transaction that is being blocked.
Ideally you should be looking at several of the built-in system performance counters that relate to the hardware and to .Net itself, such as the request queue and the GC stats.
Upvotes: 3
Reputation: 351466
You need to use a profiler (like ANTS Profiler) to determine the cause of the slowness. There are so many possible causes for the loss of performance that it will be impossible to tell without some data about how your application is running.
Upvotes: 4