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

  • Hands On: New VS Code Insiders Build Creates Web Page from Image in Seconds

    New Vision support with GitHub Copilot in the latest Visual Studio Code Insiders build takes a user-supplied mockup image and creates a web page from it in seconds, handling all the HTML and CSS.

  • Naive Bayes Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the naive Bayes regression technique, where the goal is to predict a single numeric value. Compared to other machine learning regression techniques, naive Bayes regression is usually less accurate, but is simple, easy to implement and customize, works on both large and small datasets, is highly interpretable, and doesn't require tuning any hyperparameters.

  • VS Code Copilot Previews New GPT-4o AI Code Completion Model

    The 4o upgrade includes additional training on more than 275,000 high-quality public repositories in over 30 popular programming languages, said Microsoft-owned GitHub, which created the original "AI pair programmer" years ago.

  • Microsoft's Rust Embrace Continues with Azure SDK Beta

    "Rust's strong type system and ownership model help prevent common programming errors such as null pointer dereferencing and buffer overflows, leading to more secure and stable code."

  • Xcode IDE from Microsoft Archrival Apple Gets Copilot AI

    Just after expanding the reach of its Copilot AI coding assistant to the open-source Eclipse IDE, Microsoft showcased how it's going even further, providing details about a preview version for the Xcode IDE from archrival Apple.

Subscribe on YouTube

Upcoming Training Events