On the other hand, the other advantage is that the container images will be much smaller compared to normal. In this case, the deployment will increase its speed. Smaller disk footprint: This means that one executable contains the program and used code from external dependencies.Here are the benefits you can expect when using Native AOT: This new feature offers some impressive advantages that will make developers’ lives easier and more efficient. These advantages are particularly noticeable in situations where multiple instances are running, such as cloud infrastructure and large-scale services. There's possibly JIT times coming in to play too.Įven with the startup task, there's still a big difference between the first request duration, and the second and third requests which are only 4ms and 1ms respectively.The combination of native AOT with ASP.NET Core leads to impressive results: smaller footprint, blazing-fast startup, and reduced memory usage. No need for the t-test to prove significance here! I can only assume that instantiating some of the scoped/transient services triggers some lazy initialization which then doesn't have to be performed when a real request is received. That's a mean reduction in first request duration of 117ms, or 37%. The table below shows the first request time without using the startup task (top), when using the startup task to only create singletons (middle), and using the startup task to create all the services (bottom) I ran the test again, and got some slightly surprising results. ExecuteAsync() creates a new IServiceScope before requesting the services, so that the scoped services are properly disposed at the end of the task.GetSingletons() is renamed to GetServices(), and no long filters the services to singletons only.NET Core 2.2 SDK: dotnet new webapp -auth Individual -name testįor simplicity, I tweaked the logging in appsettings.json to write request durations to the console in the Production environment: I created the default ASP.NET Core web template with individual authentication using the. I decided to do a quick test of a very simple app, to see the difference between that first request and subsequent requests. However this work often only has to be done once subsequent requests have much less work to do, so they complete faster. There's lots of work that has to be done before a response can be sent. The first request after an app starts up is particularly susceptible to slowing down. As the app gets bigger, more and more services are registered with the DI container, you pull in data from multiple locations, and you add extra features where they're needed. Inevitably, developers have to put some actual functionality in their apps, and if performance isn't a primary focus, things can start to slow down. However, you can't just have framework code in your applications. NET types like Span and System.IO.Pipelines. Throughout its development there's been a huge focus on performance, even driving the development of new high-performance. The ASP.NET Core framework is really fast, there's no doubt about that. It describes an interesting way to try to reduce the latencies seen by apps when they've just started, by pre-building all the singletons registered with the DI container. Rather than discuss a general approach to running startup tasks, this post discusses an example of a startup task that was suggested by Ruben Bartelink. This post follows on somewhat from my recent posts on running async startup tasks in ASP.NET Core.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |