I bet most of you already do this, but, I’ll mention it anyway. I was having a lot of issues with one of the sites I was building. Turns out it was an endless loop in my code. In a project with thousands of lines of code, I was able to find the issue and resolve it quickly. So, how did I find the issue, you may ask.
- Moved the site to another server and changed the URL
- This was done so no one would be hitting the site while I was trying to find the problematic page.
- I then started clicking through the site and watching the Task Manager on the server.
- One page finally caused the CPU to spike.
- I killed the process a few times and tried that same page again. Every time it spiked the CPU.
- I then went to the Sitecore Item for this page and looked at the Presentation Details.
- I started removing Sublayouts, one at a time, and testing the page again.
- Eventually one of the Sublayouts I removed allowed me to go to the page and the CPU no longer spiked.
- I added the Sublayout back in, tried the page, and the CPU spiked again. So I knew the problem was in this Sublayout.
- I went into the code for this Sublayout and found an endless loop. That was the culprit!
These were the steps I took to debug my issue. A few things were key here:
- Moving the site to a different server.
- This was really helpful because it allowed me to stop the site and start it again and see exactly what was spiking the CPU.
- When the site was on the URL that the client had access to, I could never stop the process because there was always someone with a browser open requesting a page on the site.
- Removing Sublayouts one at a time allowed me to identify where the problem was coming from.
I hope this is helpful for you!