Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OrchardCMS Admin panel loads really slow on Azure App Service (Linux) when using WebOptimizer #11761

Closed
antonis-sna opened this issue May 24, 2022 · 16 comments

Comments

@antonis-sna
Copy link

antonis-sna commented May 24, 2022

I am using OrchardCMS (1.2.2) with SQL Server and everything works fine and smooth on my local machine.

However, when I publish my solution to Azure App Service (net5.0, self-contained deployment mode, linux-x64), the admin panel loads forever. For example, the admin of my landing page content type takes almost 5-6 minutes to load. My App Service is hosted on Azure by using Basic Tier, 1 B1 (1 Core(s) with 1.75 GB RAM, 10 GB Storage) on Linux OS and all my resources (app service, sql server, database, etc.) are hosted on West Europe datacenters.

Below I attach a screenshot from the network tab of chrome developer tools, showing how long each request takes to complete:

image

Below I attach a screenshot of one random request:

image

Meanwhile, when I monitor the Log Stream from my Azure App Service I get multiple requests of this type:

File '/TheAdmin/js/TheAdmin.min.js' not found. Passing on to next middleware.
OrchardCore.Modules.ModularTenantRouterMiddleware[0]

File '/OrchardCore.Resources/Scripts/bootstrap-select.min.js' not found. Passing on to next middleware.
OrchardCore.Modules.ModularTenantRouterMiddleware[0]

File '/OrchardCore.Resources/Scripts/js.cookie.min.js' not found. Passing on to next middleware.
OrchardCore.Modules.ModularTenantRouterMiddleware[0]

...

On the other side, when I run my solution from my local machine with VS2022 on debug mode and I connect to the remote Azure SQL Server DB, everything loads fine, so it seems not a database connection problem. I should mention that my landing page loads fine and I haven't faced any issue with my front page, loading issues occur only when accessing the Orchard Admin panel.

Do I have to configure any special setting while publishing to Azure ? Has anyone faced any similar issue before?

Thanks

@Skrypt
Copy link
Contributor

Skrypt commented May 24, 2022

Looks like a TheAdmin theme issue since it doesn't find the assets. Though for the network speed I never experienced this under Azure.

@antonis-sna
Copy link
Author

Looks like a TheAdmin theme issue since it doesn't find the assets. Though for the network speed I never experienced this under Azure.

Thank for the reply. I'll focus on TheAdmin theme assets loading but it's weird that admin panel finally loads properly after several minutes

@MikeAlhayek
Copy link
Member

Note sure this is going to help you much, but I would suggest you turn on the mini profiler feature on admin and see if that’ll give you additional data.

https://docs.orchardcore.net/en/latest/docs/reference/modules/MiniProfiler/

I would also enable SSH on your container and run tracert from the container to the database server “or other services you are using” to make sure the connection between the services is solid. You can also look at the networking logs in Azure to see if there is more clues

I am using OC on azure service app using docker container and have no issues.

@antonis-sna
Copy link
Author

antonis-sna commented May 25, 2022

turn on the mini profiler feature on admin

Thanks for the suggestion. I turned on the mini profiler but I couldn't target to a specific issue.

image

image

image

Unfortunately I don't use a docker container but Azure App Service on Linux and I don't have much access to the host machine. When trying to execute any tracert/traceroute/tracepath/tracetcp/etc command from the Kudu (.scm) SSH environment, I get command not found.

@ns8482e
Copy link
Contributor

ns8482e commented May 25, 2022

Are you using orchard source code or are you using nuge packages?

Also verify that your asp net core environment is not Development

@antonis-sna
Copy link
Author

The following line from the Azure Log Stream got me suspicious:

2022-05-24T16:23:40.786293209Z WebOptimizer.AssetBuilder[1005]

So I removed the LigerShark.WebOptimizer.Core nuget package from my project and everything loads normally now. However, I really don't know why there was a conflict between the admin panel and WebOptimizer.

In Startup.cs I had the following in ConfigureServices():
services.AddWebOptimizer(pipeline => { pipeline.MinifyJsFiles(); pipeline.MinifyCssFiles(); });

And in Configure():
app.UseWebOptimizer();

Also in _ViewImports:
@addTagHelper *, WebOptimizer.Core

Removing only the code parts did not fixed the issue. Removing the entire nuget library did.

Does anyone know why?

@antonis-sna antonis-sna changed the title OrchardCMS Admin panel loads really slow on Azure App Service (Linux) OrchardCMS Admin panel loads really slow on Azure App Service (Linux) when using WebOptimizer May 25, 2022
@antonis-sna
Copy link
Author

Are you using orchard source code or are you using nuge packages?

Also verify that your asp net core environment is not Development

I 'm on Production using nuget packages

@Skrypt
Copy link
Contributor

Skrypt commented May 25, 2022

https://github.com/ligershark/WebOptimizer

I think you may find an answer going on the WebOptimiser repository. Though, I'm not sure if that's a necessary library since in Orchard Core we build assets with a Gulp pipeline. We don't bundle assets on production server. This is maybe what is the issue there, it is trying to bundle/minify every assets that the requests has and some of them just don't get enough time to end processing and returns a 400 error.

@antonis-sna
Copy link
Author

antonis-sna commented May 25, 2022

I think you may find an answer going on the WebOptimiser repository

I have been also searching WebOptimizer repository without any luck. I 'm using WebOptimiser package to take advantage of the bundling, minification and cache busting options for my landing page because "Use resources cache busting" option in OrchardCMS does not seem to apply to my homepage. Neither does minification option (when in production mode).

@Skrypt
Copy link
Contributor

Skrypt commented May 25, 2022

The "Use resources cache-busting" option will only change the URI if the assets have changed. If you are using the "response cache" then it might take some time before the page gets refreshed.

The minification option in the admin is only there to say: use the minified version of the assets if any is provided to the ResourceManager. It won't minify the assets for you; it needs to be minified manually with the gulp pipeline.

Here, when you are using the WebOptimizer you may need to use its own cache busting feature since you would then need to assert that our cache busting middleware is executed after the WebOptimizer one.

There is clearly an issue here but we would need to start a PR to support WebOptimizer which is not something that is planned right now. You may want to take that task and start a PR if you want.

@antonis-sna
Copy link
Author

start a PR if you want

It's weird that this "delay" seems to happen only when I deploy to Azure and not on my local machine where it works perfectly fine while bundling, minifiing and cache busting all script and style files in both my landing page and admin panel.

I wish I find the strength to deal with this issue with a PR. Also, I don't know if this issue should be closed or stay open for anyone else who's struggling with similar problems.

@Skrypt
Copy link
Contributor

Skrypt commented May 25, 2022

Keep it open, it will get triaged tomorrow.

@Skrypt
Copy link
Contributor

Skrypt commented May 25, 2022

I personally think you should use the gulp pipeline simply. It will save you time. Also, using the native SASS and LESS and TypeScript compilators will keep you out of trouble most of the time by experience. This is why we are using a gulp pipeline because we had issues with these server-side solutions which don't follow the latest specs.

@antonis-sna
Copy link
Author

I tried to use WebOptimizer as it runs simply as an out-of-the-box solution and I 've been already using it in older ASP.Net MVC projects. However, I 'll try to use gulp pipeline as you suggested. Thank you

@Skrypt
Copy link
Contributor

Skrypt commented May 25, 2022

https://docs.orchardproject.net/en/latest/Documentation/Processing-client-side-assets/

We need to move this documentation to Orchard Core documentation.

@sebastienros
Copy link
Member

Please reopen if you think there is still a bug in OC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants