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

  • AI for GitHub Collaboration? Maybe Not So Much

    No doubt GitHub Copilot has been a boon for developers, but AI might not be the best tool for collaboration, according to developers weighing in on a recent social media post from the GitHub team.

  • Visual Studio 2022 Getting VS Code 'Command Palette' Equivalent

    As any Visual Studio Code user knows, the editor's command palette is a powerful tool for getting things done quickly, without having to navigate through menus and dialogs. Now, we learn how an equivalent is coming for Microsoft's flagship Visual Studio IDE, invoked by the same familiar Ctrl+Shift+P keyboard shortcut.

  • .NET 9 Preview 3: 'I've Been Waiting 9 Years for This API!'

    Microsoft's third preview of .NET 9 sees a lot of minor tweaks and fixes with no earth-shaking new functionality, but little things can be important to individual developers.

  • Data Anomaly Detection Using a Neural Autoencoder with C#

    Dr. James McCaffrey of Microsoft Research tackles the process of examining a set of source data to find data items that are different in some way from the majority of the source items.

  • What's New for Python, Java in Visual Studio Code

    Microsoft announced March 2024 updates to its Python and Java extensions for Visual Studio Code, the open source-based, cross-platform code editor that has repeatedly been named the No. 1 tool in major development surveys.

Subscribe on YouTube