.Net 6/8 WebApi take long time to start

Jiayu Qiu 0 Reputation points
2024-06-27T08:15:07.1766667+00:00

I compile this simple project and run it in Linux bash is normal.

But when I create service file to run this program, it take almost 2 minute to start. The same as in Podman.

var builder = WebApplication.CreateBuilder(args);

var app = builder.Build();

app.MapGet("/", () => "HelloWorld");

app.Run();

Update 2024/07/01

HELP! HELP! HELP!

I found the reason. But nothing can do~

I have mounted a SMB folder from Windows, this folder has a large number of folders and files.

[/etc/fstab: //ip/depot /mnt/depot cifs username=xxx,password=xxx,_netdev 0 0 ]

Run this WebApi program in bash is normal. But I start the service[systemctl start webapi], got the PID number and strace the PID. I found that this program is traversing all the directories in the folder。It took nearly 2 minutes until the scan was completed。

I have test Linux kernel > 5.x, e.g RokcyLinux 9.x, openEuler24.03, Anolis 8.9(ANCK) .

User's image

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,337 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 60,201 Reputation points
    2024-06-29T15:52:26.47+00:00

    Your performance issue appears to be podman startup cost. Performance tuning podman is outside the scope of this forum.