Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 371103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:04:56+00:00 2026-05-12T14:04:56+00:00

I recently did some performance testing and analysis of an ASP.NET application using out-of-process

  • 0

I recently did some performance testing and analysis of an ASP.NET application using out-of-process session state – this is necessary when using session state on a web farm so that state can be retrieved on any of the web servers, e.g. if subsequent HTTP requests arrive at a different server because the sessions aren’t ‘sticky’ or the original server is down, etc.

What surprised me was that when I ran the web servers at full load and profiled the CPU usage something like 99% of CPU time was spent serializing and deserializing session state. Subsequently we implemented a customised ‘caching’ state server; this always serializes state but also keeps state in-memory so that if you use sticky sessions the state doesn’t have to be deserialized most of the time. This improved server throughput by a factor of 2; However, serialization still makes up 98% or more of CPU time.

We obtained some further improvements in speed by ‘trimming’ unnecessary object references between objects in the session state prior to serialization – fixing up the references manually upon desrialization. This improved speed by another 10-20% or so. The reasoning here is that some of the performance loss is due to the built in serialization having to walk the graph of object pointers, which becomes a more complex task with more pointers.

Continuining the investigation we wrote customized serialization routines for some of our classes rather than relying on .Net’s built-in serialization. What we found was that performance was greatly improved, by a factor of about 50x. It seems the bulk of the CPU load is caused by built in .Net serialization, which in turn is slow due to reliance on using Reflection to walk the object pointers/graph and extract field data.

It’s very tempting to boost our performance by 50x, thus reducing the web server hardware requirements by a large factor (and power requirements by a lesser but still significant factor). The options currently are:

1) Write customized serialization. This is an issue due to the complexity of the task and the maintenance overhead it generates, that is, any change to class state requires a change to the serialization/deserialization routines.

2) Some third party solution. Perhaps some product that automatically generates state save/load code at build time, thus eliminating the need to use Reflection.

I’d be very interested to know if anyone knows of a third party solution, or has encountered this issue as I haven’t found any mention of it from internet searches.

UPDATE:
Some have suggested a sort of halfway solution between the default built-in serialization and pure customized serialization routines. The idea is that you implement customized serialization for the classes that affect performance the most by, e.g. overiding ISerializable. This is an interesting and promising approach; However I still think there’s scope for a complete replacement for built-in serialization without having to write and maintain any custom code – this can’t be done at runtime because Reflection is needed to query objects and access private data. But it is theoretically possible to post-process already built assemblies and inject new methods as an additional build step. Some profilers use this approach to inject profiling code into assemblies after they have been built by the C# compiler. Also I /think/ I read somewhere that the .Net framework supports injecting methods into classes – thus all the messing around with IL is potentially taken care of.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:04:57+00:00Added an answer on May 12, 2026 at 2:04 pm

    Unfortunately I am only aware of option one and tbh that can start to get very painful to work on.

    But it does only what you want so it’s as quick as it gets.

    Good luck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently I have been investigating the possibilities of caching in ASP.NET. I rolled my
I wrote some code recently (ISO/ANSI C), and was surprised at the poor performance
I recently did the Chris Coyier tutorial from the css-tricks.com weblog #38: Basics &
I recently wrote a piece of code which did SomeClass someObject; mysqlpp::StoreQueryResult result =
Recently our Subversion (SVN) server was changed and we did a svn switch .
Recently, I started changing some of our applications to support MS SQL Server as
Recently, I've been dealing with an error with accessing MAPI via the .NET framework
Recently we got a new server at the office purely for testing purposes. It
I recently needed to append some data to dynamically created LI elements . In
Recently Jeff has posted regarding his trouble with database deadlocks related to reading. Multiversion

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.