Recently, I've had a few performance issues with my Umbraco website. Like most website issues the issues turned out to be my application, instead of a specific issue within Umbraco. As you can see from the screenshot below, my Azure hosting was fine (that's the green line), the blue line that's jumping all over the place means my website keeps crashing for some reason, so my challenge was to figure out what was going wrong. This is usually harder than it sounds. If you're doing this at work then there's usually a lot of pressure for you to get a site up and running and working correctly, if you need help in this area, read on.
In today's guide, I'm going to cover the steps I followed in order to resolve the issue.
My website started running slowly in sporadic periods, it ran quickly then after a while it started getting slower and slower, so my first thought was the issue could be a DDOS attack. If you don't know what a DDOS attack is, think someone spamming your website a lot. I use Cloudflare as a CDN which also has DDOS protection, so to rule out any malicious activities, the first thing I did was log into CloudFlare and manually enable my DDOS protection. This did nothing, so the next step was to FTP into my Azure account and go through the log files to check what errors were being reported and to see if I could figure out what was going wrong. BTW... if you're not using a CDN, or, DDOS protection then I recommend you go and check it out, as it's free.
Azure has a number of useful tools to help you try and diagnose your issues. One of the first ones I always check is the 'diagnose and solve problems' page in your Azure portal.
As I'll mention below, you need to make sure Application Insights is installed, otherwise, the amount of information you can get from here is limited. Useful screens here is the one that tells you which controllers are taking the longest to load. This might tell you if you have one specific issue in particular.
'Application Insight' logs are one of the most useful logs you can use. If you're new to 'Application Insights', then it's the kind of out-of-the-box monitoring software supplied with Azure, kind of like New Relic... ish. To get application insights to work, you need to install it via NuGet. Simply search for 'Application Insights' and install it. One thing to note, you need to enable it in Visual Studio before it will work.
When I enabled App Insights with Umbraco I got a Log4Net error. As Umbraco has a separate log4net.config in the 'config' folder. My install tried to add things to the tag on my website, which caused the site to crash. If you find this, simply move the config from the web.config to the one in the config folder.
To make sure application insights is installed, simply right click on your website project and enable it:
Now if you FTP into your Azure website and look in your 'Log File' directory and you'll see a file called 'event log.xml'. This should show you a number of emails
The other place to look for errors is in the Umbraco logs. You can find these within your websites webroot -> 'App_Data' -> 'Logs'.
Following this process above, I managed to find a number of errors with the site trying to connect to Redis. I was using the Stackoverflow version for the cache at one stage, which I thought I had turned off, however, on each page request, a constructor was still being called that tried to establish a connection with a Redis server. This constant stream of failing connection requests meant a number of threads weren't being closed correctly, which after a while, caused a performance bottleneck.
Republish/Redeploy Your Code. Sometimes things can go astray while deploying, try publishing again.
Clear Temp Files. Another potential quick win is to clear your Umbraco cache. I know this sounds a little counterintuitive, clear the cache when you have performance issues, but I've to see Umbraco max out the CPU at 99% because of invalid cache. FTP into your App_data folder and clear the files within 'Temp' and Examine indexes.
Umbraco Azure Performance Bottleneck Takeaway
It is very unlikely that anyone reading this will experience the same bug as I did, however, the aim of this tutorial was not to give you an answer of what's wrong with your site. The aim of this post was to walk you through my troubleshooting process so, hopefully, you can follow the same pattern and figure it out yourself.
Software Architect, Programmer and Technologist Jon Jones is founder and CEO of London-based tech firm Digital Prompt. He has been working in the field for nearly a decade, specializing in new technologies and technical solution research in the web business. A passionate blogger by heart , speaker & consultant from England.. always on the hunt for the next challenge