Tuesday, March 19, 2019

ASP.Net State Service for Service Fabric

https://github.com/wasabii/AspNetStateService

So, many of you that deal with older ASP.Net (non-Core) sites are aware of Session State. And many of those of you are aware of the notion of offloading Session State to an external provider. And, a subset of those of you are aware that MS has a built in ASP.Net Session State server to do just this.

And many of you have tried to use that and found that it sucked. Not distributed. Still subject to a single host failure.

So lots of people use Redis, or SQL or various other Session state backends.

I however host a lot of ASP.Net applications in Service Fabric. And thus, I figured, a native Service Fabric ASP.Net state service would be nice. Wouldn't it be nifty if all my Service Fabric nodes just listened on `localhost:42424`, and found a ASP.Net state server that was compatible with the built in ASP.Net State service protocol? No other driver required. So no matter what node my app roams to, it finds a state server! Only have to set `mode="StateServer"` in `Web.config`, and the app automatically tries to find the state server on `localhost:42424`.

And wouldn't it be even more nifty if that all that session state was shared between all the nodes?

So I did that.

The ASP.Net State Server is a ASP.Net Core application that implements the MS State Server Protocol. It supports dynamic backends as well. One of those being an in-memory Entity Framework Core backend for testing. And another being Service Fabric Actors.

The state server hosts a Web application on every node at :42424, implements the MS state server protocol, but stores the actual state in an Actor which might live elsewhere in the cluster. Which is configured for volatile storage. So it's copied to N other nodes, but not persisted to disk.

Was a fun project to implement. And super useful.

Hope somebody else thinks so, as well.

Tastes best if used in conjunction with my IIS Hosted Web Core project: https://github.com/wasabii/Cogito.HostedWebCore

ASP.Net State Service for Service Fabric Click here
  • Blogger Comment
  • Facebook Comment

0 comments:

Post a Comment

The webdev Team