Tips and Tricks

Improving Startup Time by Sharing Packages

You can speed up how fast your "less frequently used" sites load by sharing assembles among your sites. You'll also reduce memory consumption on your server.

IIS does some wonderful things to improve your Web site's performance … not all of which improve everything about your site's performance. For example, IIS will keep the components of sites that are seeing lots of requests in memory while swapping out those sites that haven't seen requests for a while. Swapping out the components of those little-used sites also frees up memory on your server for the sites that are left running.

Unfortunately, when a request does come in for one of those less frequently used sites, that request will have to wait while IIS loads all of the site's components. This is especially annoying because those components include packages that have already been loaded by some other site (many NuGet packages, for example; Entity Framework leaps to mind). And, of course, you're now using up memory to hold multiple copies of the same component.

If you're using .NET Framework 4.5 or later, then you can use the aspnet_intern utility to help with this problem. All you have to do on your Web server is to run the command, pointing to the folder where IIS keeps its temporary files. The utility will analyze the folder and -- where it finds three or more copies of the same file -- copy the component to a new location of your choice and direct all the affected applications to use that single copy. Now, when a request comes in for an infrequently used site, IIS will use an already loaded copy of its components rather than loading them again.

Before running the utility, make sure you exercise all the sites involved to ensure the temporary folder is populated with the sites' components. Then run the aspnet_intern command, providing three parameters: mode (set to exec); sourcedir (set to the path to the Framework's temporary folder); and interndir (set to the folder where you want to keep the shared components). A typical example looks like this:

aspnet_intern -mode exec -sourcedir "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files" -interndir C:\Prod\ShareAssemblies

If you want to see if this is worth doing, run the command, but pass "analyze" to the mode parameter. The command will print out a report showing how many shared components there are.

About the Author

Peter Vogel is a system architect and principal in PH&V Information Services. PH&V provides full-stack consulting from UX design through object modeling to database design. Peter tweets about his VSM columns with the hashtag #vogelarticles. His blog posts on user experience design can be found at http://blog.learningtree.com/tag/ui/.

comments powered by Disqus

Featured

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube