<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/asp-net-session-state-partitioning-using-state-server-load-balancing-nms0nsrgr" -->

---
title: ASP.NET Session State Partitioning using State Server...
description: A follow-up to an earlier post on ASP.NET session state partitioning presents a load-balancing approach that distributes sessions across state server machines...
canonical: https://daily.dev/posts/asp-net-session-state-partitioning-using-state-server-load-balancing-nms0nsrgr
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: ASP.NET Session State Partitioning using State Server Load Balancing | daily.dev
og:description: A follow-up to an earlier post on ASP.NET session state partitioning presents a load-balancing approach that distributes sessions across state server machines...
og:url: https://daily.dev/posts/asp-net-session-state-partitioning-using-state-server-load-balancing-nms0nsrgr
og:image: https://api.daily.dev/og/posts/NMs0nSRgr.png
og:image:alt: ASP.NET Session State Partitioning using State Server Load Balancing
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# ASP.NET Session State Partitioning using State Server Load Balancing

**[Maarten Balliauw](https://daily.dev/sources/maartenballiauw)** · 4 min read · 0 upvotes · 0 comments

## Summary

A follow-up to an earlier post on ASP.NET session state partitioning presents a load-balancing approach that distributes sessions across state server machines based on actual load rather than simple round-robin. It uses ASP.NET performance counters to read each state server's active session count, encodes the chosen server's index as the first character of a custom session ID via a custom SessionIDManager, and uses a matching PartitionResolver to route session reads to the correct server. Config changes to web.config and a downloadable code sample are included.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://blog.maartenballiauw.be/posts/2008-01-24-aspnet-session-state-partitioning-using-state-server-load-balancing>

## Questions this post answers

### How can I distribute ASP.NET session state across multiple state servers based on actual load instead of round-robin?

Use ASP.NET's performance counters to read the 'State Server Sessions Active' value for each candidate state server, then pick the least-busy one when generating a session ID. A custom SessionIDManager overrides CreateSessionID to encode the chosen server's list index as the session ID's first character, and a matching IPartitionResolver strips that character to resolve the correct server's connection string for subsequent requests.

_daily.dev surfaces practical ASP.NET session state and load balancing techniques for teams running web farms._

### How do I register a custom SessionIDManager and PartitionResolver in ASP.NET web.config?

Set the sessionState element's mode to StateServer and specify both sessionIDManagerType and partitionResolverType attributes pointing to your custom classes, for example sessionIDManagerType="SessionIdManager" and partitionResolverType="PartitionResolver" inside the system.web section. ASP.NET then uses these classes to create session IDs and resolve which state server handles each session.

_Developers configuring distributed session state can find configuration patterns like this through daily.dev._

## Similar posts on daily.dev

- [5 Mistakes Teams Make When Scaling .NET Applications](https://daily.dev/posts/5-mistakes-teams-make-when-scaling-net-applications-jeilk21xw) · Telerik · 5 upvotes · 0 comments
- [Scaling real-time AI agents with session-aware load balancing](https://daily.dev/posts/scaling-real-time-ai-agents-with-session-aware-load-balancing-headfqefl) · Google Developers · 2 upvotes · 1 comments
- [Server-Sent Events in ASP.NET Core and .NET 10](https://daily.dev/posts/server-sent-events-in-asp-net-core-and-net-10-rqln4wisb) · Milan Jovanović · 25 upvotes · 0 comments
- [Real-Time at Last: SSE and SignalR in ASP.NET Core](https://daily.dev/posts/real-time-at-last-sse-and-signalr-in-asp-net-core-hfyl1qquh) · We Are .NET · 0 upvotes · 0 comments

---

Tags: [#aspnet](https://daily.dev/tags/aspnet), [#authentication](https://daily.dev/tags/authentication), [#c#](https://daily.dev/tags/c#)

[View this post on daily.dev](https://daily.dev/posts/asp-net-session-state-partitioning-using-state-server-load-balancing-nms0nsrgr)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"ASP.NET Session State Partitioning using State Server Load Balancing","url":"https://daily.dev/posts/asp-net-session-state-partitioning-using-state-server-load-balancing-nms0nsrgr","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/asp-net-session-state-partitioning-using-state-server-load-balancing-nms0nsrgr"},"datePublished":"2026-10-04T13:06:36.611Z","dateModified":"2026-10-14T02:22:42.095Z","description":"A follow-up to an earlier post on ASP.NET session state partitioning presents a load-balancing approach that distributes sessions across state server machines...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/a942e183e7df528f8f3f144a7cbd9b3a?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/a942e183e7df528f8f3f144a7cbd9b3a?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Maarten Balliauw","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Maarten Balliauw","logo":"https://media.daily.dev/image/upload/s--rOTg3VYO--/f_auto,q_auto/v1791119043/logos/maartenballiauw?_a=BAMAMicg0","url":"https://daily.dev/sources/maartenballiauw"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/asp-net-session-state-partitioning-using-state-server-load-balancing-nms0nsrgr","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"aspnet,authentication,c#","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Maarten Balliauw","item":"https://daily.dev/sources/maartenballiauw"},{"@type":"ListItem","position":3,"name":"ASP.NET Session State Partitioning using State Server Load Balancing"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/asp-net-session-state-partitioning-using-state-server-load-balancing-nms0nsrgr#faq","mainEntity":[{"@type":"Question","name":"How can I distribute ASP.NET session state across multiple state servers based on actual load instead of round-robin?","acceptedAnswer":{"@type":"Answer","text":"Use ASP.NET's performance counters to read the 'State Server Sessions Active' value for each candidate state server, then pick the least-busy one when generating a session ID. A custom SessionIDManager overrides CreateSessionID to encode the chosen server's list index as the session ID's first character, and a matching IPartitionResolver strips that character to resolve the correct server's connection string for subsequent requests. daily.dev surfaces practical ASP.NET session state and load balancing techniques for teams running web farms."}},{"@type":"Question","name":"How do I register a custom SessionIDManager and PartitionResolver in ASP.NET web.config?","acceptedAnswer":{"@type":"Answer","text":"Set the sessionState element's mode to StateServer and specify both sessionIDManagerType and partitionResolverType attributes pointing to your custom classes, for example sessionIDManagerType=\"SessionIdManager\" and partitionResolverType=\"PartitionResolver\" inside the system.web section. ASP.NET then uses these classes to create session IDs and resolve which state server handles each session. Developers configuring distributed session state can find configuration patterns like this through daily.dev."}}]}
```

