Website crash when traffic is little high

I’m hosting my Umbraco 15 website on Azure. My plan is Standard S1.

When I’m sending a newsletter, or just traffic increase (because of social media posts, etc.), Instance count jump to 8, and yet, the website is crashing! Is it make sense?? It cost $73 / month and can’t handle some traffic???
(In a shared host I’d get a better performance …)

So now when I’m sending newsletter I change the plan to Premium v3 P0V3, then it stable. Problem is that the Premium v3 P0V3 cost $127 / month …

And here are my questions:
Is it Umbraco / my website or that Azure is just a bad service?
Like, is there something I can do to make the website more efficient ?

Like, it’s a simple magazine website, the code is not that complicated and I don’t have plugins / packages, etc. A standard code

Any ideas?

Thanks

It’s probably your site, sorry :slight_smile:

Read through Common Pitfalls & Anti-Patterns | Umbraco CMS it covers a lot of things you can do wrong.

1 Like

It doesn’t make sense. Where I’d start would be the Umbraco logs. I would search for any exceptions or out of memory errors that could be an indication.

What Soren also suggested makes sense. Maybe, unwillingly, you’re doing one of the things mentioned there that contribute to your website being overloaded. It could be something as simple as getting a huge collection in memory every time you load a list without using caching, or making a content query that just returns too much. These things tend to create issues only on higher traffic scenarios.

1 Like

Hi, thanks.
Which logs? At Umbraco back office or Azure kudu ?

Also, what should I look for in the logs?

How can I know what causes the issue ?

My code is pretty simple - at home page I take the latest news items from each category, then click on each of them takes to the article, which I get the document’s information, etc. Pretty simple. I looked at the link which Soren put and didn’t find something from there in my code

This for example a typical section at the home page (in the link it’s still the V11 code because haven’t pushed yet to my github the V15, but very similar - my current code just with the changes to 15):

Is anything wrong in this code?

And this for example the code to display posts for each category:

Thanks

I’ve had a very quick look at your repo. Nothing immediately jumps out but the following things will help:

  1. Review your use of the ‘@’ - this is just to put Razor variables into markup - within c# blocks it’s possibly causing some weirdness.
    Lines like this below
var photonics_pagesToList = @photonics_node.Children.Where("Visible");

: the @photonics is unneeded - just photonics_node.Children

  1. You’re mixing the use of partials and macros (in how you call these partials from your page layout master template and on the pages. I think you can just use partial views based on what I can see. Then you can cache too… (see next point)
    Partial Views | Umbraco CMS

  2. Cache - for every page load your making this site traverse all these nodes - things like navs and side bars with links are not changing so use caching. You can control if the cache is the same site wide or different for each page (e.g. the main nav might be the same site wide if you don’t have any current page context) and the side bar related links is likely per page.

e.g. replace

@await Umbraco.RenderMacroAsync("ArticleImgHandler")

with

@await Html.CachedPartialAsync("ArticleImgHandler", Model, new TimeSpan(0, 1, 0, 0), true, false)

// the first true is cache by page - for a site wide you can have false.

But definitely look at the logs - check in the Settings section in Umbraco and look at what happens at the time of the crashes. My guess is in the use of macros when you don’t need them and your accessing of Umbraco media.

1 Like

Thanks.
I refactored some of the code but still happening.

For example, this what the Azure logs look like when instance count jumps to 8 and website either very slow or not coming up

Is it make sense?

What do the logs say?

When you say instance count are you scaling the instance? If so have you followed the documentation on how to scale and load balance Umbraco on Azure?

What’s your traffic levels? A single instance on Azure that’s correctly sized won’t need multiple instances unless you’re handling big load.

Hi @Menachem35 and welcome :slightly_smiling_face:

I think there’s a lot of potential issues with the provided examples.
If you code follow the same pattern as the one you’ve linked to, then you’re most certainly falling into two anti-patterns:

  1. Querying with Descendants
  2. Over querying

There are far too many, too expensive queries that doesn’t really scale well with the amount of content.

Furthermore checking the website on the GitHub page with Google Page speed yields a pretty bad score:
https://pagespeed.web.dev/analysis/https-www-opli-net-lasers/xnwfk44nin?form_factor=mobile
Now, this doesn’t necessarily impact the server, but it does impact your visitors.

As Steve Morgan said, when you write:

What does that mean? If you’re scaling the Umbraco instance, then you have to be super careful and strictly follow the loadbalancing guidelines.
Umbraco cannot work correctly if more then 1 publishing instance is serving content.
So, IF, you’re scaling your Umbraco instance, are you then making sure, only to scale the frontend render servers?

While looking through the thread I saw you reference that database tier you’re on is S1.
Please consider scaling to at least S2 for your SQL server as Umbraco has defined:
https://docs.umbraco.com/umbraco-cms/fundamentals/setup/server-setup/azure-web-apps

The minimum recommended Azure SQL Tier is “S2”, however noticeable performance improvements are seen in higher Tiers

This is a key part to optimal website performance, especially if you’re doing expensive querying.


To answer this question.

No. Azure is just fine, but managing infrastructure is a complicated task.
There are certain requirements and configuration that MUST be done correctly or it will severely impact a sites performance and reliability.
Your website might have a few potential performance issues in code, but I think it’s largely a SQL DB issue.
What is your average DTU usage when the site crashes, my guess is close to 100%.
Scaling Umbraco incorrectly will also cause you many problem, I guarantee, so consider not scaling unless you fully understand the requirements and scenarios where this might be applicable.

Hope it helps :slightly_smiling_face:

1 Like

Hi, thanks.

I already refactored the code, still issues. I didn’t pushed yet the refactored code to my github, so put it here:

@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
@using Umbraco.Cms.Core
@using Umbraco.Cms.Core.Models.PublishedContent
@using Umbraco.Cms.Core.Routing
@using Umbraco.Extensions

@{
    var get_feature_story = Umbraco.Content(1561); //Get properties of the Features articles page
	var feature_story_id = get_feature_story?.Value<IPublishedContent>("mainNewsItem")?.Id;  //Get the content picker with the main story at home page
}

@{

	var photonics_node = Umbraco.Content(1061);
	var photonics_pagesToList = photonics_node?.DescendantsOrSelf().Where(n => n.ContentType.Alias == "NewsPage").OrderBy(x => x.CreateDate);

	var feature_story_HP = feature_story_id.HasValue ? Umbraco.Content(feature_story_id.ToString())
	                       : null; //Get the content picker with the main story at home page

	/* *** Get first items of Imaging & Solar *** */
	var Imaging_node = Umbraco.Content(1064);
	var Imaging_pagesToList = Imaging_node?.DescendantsOrSelf().Where(n => n.ContentType.Alias == "NewsPage" && n.IsVisible())
	                                       .OrderBy(x => x.CreateDate);

	var Solar_node = Umbraco.Content(1306);
	var solarNewsItem = Solar_node?.DescendantsOrSelf().Where(n => n.ContentType.Alias == "NewsPage" && n.IsVisible())
	                                                       .OrderByDescending(x => x.CreateDate)
														   .FirstOrDefault();

	<!-- ****************************************** -->
		
	<!-- *** Headlines *** -->
	<div class="row">
		<div class="col-xl-6 col-lg-6 col-md-12 MainNewsBox" id="MainNewsItem">
					
			<figure>
			   @if (feature_story_HP.HasValue("articleImg"))
				{
					var image = feature_story_HP.Value<IPublishedContent>("articleImg");
				    <img src="@image.Url()" alt="@image.Value("photoAlt")" class="img-fluid news-img" />
				}
				<figcaption>
					<a href="@feature_story_HP.Url()">
						<h3 class="MainNewsTitle">@feature_story_HP.Value("title")</h3>
					</a>
				</figcaption>
			</figure>
							
			<!-- Old version -->
			@*<p>
            	@feature_story_HP.Value("metaDescription")
                <br />
				<a href="@feature_story_HP.Url()" class="news_link">Continue >></a>
			</p>*@
		</div>
				
		<div class="col-xl-6 col-lg-6">
			<div class="row">
				<div class="col-xl-12 col-lg-12 col-md-4 MainNewsBox">
					<figure>
						@if (Imaging_pagesToList.Last().HasValue("articleImg")) 	
						{
							var image = Imaging_pagesToList.Last().Value<IPublishedContent>("articleImg");
							<img src="@image.Url()" class="img-fluid wide-news-img" alt="@Imaging_pagesToList.Last().Value("photoAlt")" />
							@* <img src="@Umbraco.Media(Imaging_pagesToList.Last().Value<IPublishedContent>("articleImg").ToString()).Url()" class="img-fluid wide-news-img" alt="@Imaging_pagesToList.Last().Value("photoAlt")" />*@
						}		
						<figcaption>							
							<a href="@Imaging_pagesToList.Last().Url()">
								<h3 class="MainNewsTitle-1">
									 @Imaging_pagesToList.Last().Value("title")  
								</h3>
							</a>
						</figcaption>
					</figure>
				</div>					
															
				<div class="col-xl-6 col-lg-6 col-md-4 MainNewsBox">
					<figure>
						@if (photonics_pagesToList.Last().HasValue("articleImg")) 	
						{
							var image = photonics_pagesToList.Last().Value<IPublishedContent>("articleImg");  
							<img src="@image.Url()" class="img-fluid news-img" alt="@photonics_pagesToList.Last().Value("photoAlt")" />
							@*<img src="@Umbraco.Media(photonics_pagesToList.Last().Value<IPublishedContent>("articleImg").ToString()).Url()" class="img-fluid news-img" alt="@photonics_pagesToList.Last().Value("photoAlt")" />*@
						}
						<figcaption>															
							<a href="@photonics_pagesToList.Last().Url()">
								<h3>@photonics_pagesToList.Last().Value("title")</h3>
							</a>
						</figcaption>	
					</figure>							
				</div>
						
				<div class="col-xl-6 col-lg-6 col-md-4 MainNewsBox">
					<figure>
						@if (solarNewsItem.HasValue("articleImg"))
						{
							var image = solarNewsItem.Value<IPublishedContent>("articleImg");
							<img src="@image.Url()" class="img-fluid news-img" alt="solarNewsItem.Value("photoAlt")" />
							@*<img src="@Umbraco.Media(Solar_pagesToList.Last().Value<IPublishedContent>("articleImg").ToString()).Url()" class="img-fluid news-img" alt="@Solar_pagesToList.Last().Value("photoAlt")" />*@
						}
						<figcaption>															
							<a href="@solarNewsItem.Url()">
								<h3>@solarNewsItem.Value("title")</h3>
							</a>
					</figcaption>	
					</figure>
				</div>
			</div>
					
		</div>
	</div>
	<!-- *** End Headlines *** -->
							
	<!-- Advertising -->
	<div class="row">
		<div class="col-xl-12 col-lg-12 col-md-12 col-sm-12">
		 	
			
			
			
						
		</div>
	</div>
	<!-- *********** -->
			
	<!-- *** More news at photonics and physics *** -->						
	<div class="row">
		<!-- *** Photonics and physics - left box *** -->
		<div class="col-xl-6 col-lg-6 col-md-6 col-sm-12 col-xs-12">
				
			<div class="category-title-container">				
				<h2 class="category-title-item">
					<a href="/photonics">Photonics and Physics</a>
				</h2>			
				<div class="stripe-line"></div>
					 
			</div>
			
			@foreach (var photonics_newsItem in photonics_pagesToList.OrderByDescending(x => x.CreateDate).Skip(1).Take(5))
			{
				<div class="img-text-container">
					<div class="news-img-left">
						@if (photonics_newsItem.HasValue("articleImg")) 	
						{
							var image = photonics_newsItem.Value<IPublishedContent>("articleImg");
							<a href="@photonics_newsItem.Url()">
								<img src="@image.Url()" alt="@photonics_newsItem.Value("photoAlt")" />
								@*<img src="@Umbraco.Media(photonics_newsItem.Value<IPublishedContent>("articleImg").ToString()).Url()" alt="@photonics_newsItem.Value("photoAlt")" />*@
							</a>
						}
					</div>
					<div class="news-text-right">
						<h3><a href="@photonics_newsItem.Url()">@photonics_newsItem.Value("title")</a></h3>
						<p>						
							@Html.Truncate(@photonics_newsItem.Value("metaDescription").ToString(), 120, true)
						</p>
					</div>	
				</div>
			} 
																				
		</div>
				
		<!-- *** More in Photonics and physics - right box *** -->
		<div class="col-xl-3 col-lg-6 col-md-6 col-sm-12 col-xs-12">
					
			<div class="category-title-container">
				<h2 class="category-title-item">More in Photonics</h2>	
				<div class="stripe-line"></div>						
			</div>
			
			 @foreach (var photonics_newsItem in photonics_pagesToList.OrderByDescending(x => x.CreateDate).Skip(6).Take(14))
			{
				<h4 class="physics-news">
					<a href="@photonics_newsItem.Url()">
						@photonics_newsItem.Value("title")
					</a>
				</h4>				
			}	
		</div>
		<!-- *** End More in Photonics and physics - right box *** -->
				
		<!-- Up coming events -->
		<div class="col-xl-3 hidden-lg-down Events-box">
					
			<div class="category-title-container">
				<h2 class="category-title-item">UPCOMING EVENTS</h2>
											 
			</div>
			<aside>		
				@await Html.PartialAsync("Show Events Sidebar")
			</aside>
		</div>
		<!-- End Upcoming events -->
				
	</div>
	<!-- *** End More news at photonics and physics *** -->
			
	<!-- Upcoming Events - lg-down -->
	<div class="row">
		<div class="hidden-xl-up col-lg-12 col-md-12 col-sm-12" style="background-color: #F7F8FF; min-height: 200px;">
			<h2 class="category-title-item">UPCOMING EVENTS</h2>

			@await Html.PartialAsync("Show Events Sidebar")
		</div>
	</div>
	<!-- End Upcoming Events - lg-down -->
		
}

Now here is the thing, in the link you put it says: Querying with Descendants using DescendantsOrSelf

but here is my problem, here’s my tree:

so I think I must use DescendantsOrSelf() ?

can I do it in more efficient way?

The code above renders part of the home page

Thanks

Hey!

Based on what I read you are unintentionally trying to load balance Umbraco. (Single App Service Plan multiple instances)

Try reducing the instances to one and see if the issue goes away.

If you want to have more than one instance you need to configure the site for Load balancing as described here .

This needs two separate app service plans one that scales out (Public front end) and one that is single instance (Umbraco back office). The Umbraco back office cannot be scaled out currently but the front end can. Also insure your database is at least S2 Tier as mentioned by others.

Double check you also have the correct configuration setup for Azure web apps here: Running Umbraco On Azure Web Apps | Umbraco CMS

1 Like