1

There's an ASP.NET MVC 5 application (it uses Entity Framework 6.0, .NET 4.6.1 dependencies, it utilizes both MVC controllers and API controllers and most importantly) which relies on IIS's ability to provide session stickyness through ARR. Sometimes this is also referred as client affinity and IIS ARR implements it with a cookie if I'm not mistaken. ARR feature is essential for that app, it'd be unusable without it.

I haven't found any concrete evidence if such a project got upgraded to ASP.NET Core 3.1+ (or even .NET 5) then would the ARR still work as before? .NET Core architecturally is very different than .NET MVC 5 and want to prepare in advance for any surprises. Is there any cloud platform besides Azure which could provide equivalent feature what Azure WebApps can provide with IIS + ARR?


BTW I highly disadvise anyone from developing any solution which would rely on sticky session or client affinity. Ideally a webapp request/response code should be stateless in the sense that the requests should be able to be routed randomly to any server in case of a horizontal scale-out.

Sticky session routing can be also costly (I mean money) depending on the provider (fortunately IIS ARR is free) and it can also hurt even load distribution.

Csaba Toth
  • 10,021
  • 5
  • 75
  • 121

1 Answers1

2

Client Affinity in IIS is for load balancing / traffic routing so this is how your farm will redirect routes to nodes. Which means it does not matter what you have on backend since as soon as you enable then requests with those cookies will always hit same node.

For instance Kubernetes has similar concept

If you want to make sure that connections from a particular client are passed to the same Pod each time, you can select the session affinity based on the client's IP addresses by setting service.spec.sessionAffinity to "ClientIP" (the default is "None"). You can also set the maximum session sticky time by setting service.spec.sessionAffinityConfig.clientIP.timeoutSeconds appropriately. (the default value is 10800, which works out to be 3 hours).

You can also do the same with AWS

{     
    "Attributes": [
       ...
        {
             "Key": "stickiness.enabled",
             "Value": "true"
          },           
          {
              "Key": "stickiness.lb_cookie.duration_seconds",
              "Value": "86500"
          
          },
       ...
      ]
  } 

So once Again session Affinity is for routing request to your nodes and has nothing to do with backend technology, but honestly I would avoid it since you could have some scalability problem or at least configure those sessions to be short.

Vova Bilyachat
  • 18,765
  • 4
  • 55
  • 80
  • Oh yes I was a little vague because how ARR is part of IIS configuration. Client affinity in general is a request routing feature. I added some disclaimer to my question influenced by you. Thanks for the pointer about AWS client affinity. IP based vs cookie based affinity is a little different (https://stackoverflow.com/a/1040063/292502). Do you know if ARR works as intended with .NET Core 3.1+? – Csaba Toth Aug 18 '21 at 06:29
  • @CsabaToth again it has nothing to do with .net it self. .net handle request it does not care about that. – Vova Bilyachat Aug 18 '21 at 06:30
  • @CsabaToth so what is doing is that lets say i am your app user, if i got that cookie and my request was served from node1 then all other requests will be served to same node1 (for some time) so you node1 can have .net, php it does not matter what matters is that it always go to nodeX – Vova Bilyachat Aug 18 '21 at 06:31
  • 1
    all right so the answer is that it should work – Csaba Toth Aug 18 '21 at 06:31
  • 1
    @CsabaToth yes exactly – Vova Bilyachat Aug 18 '21 at 06:32
  • I've seen some SO entries (https://stackoverflow.com/questions/2245235/using-iis-application-request-routing-arr-for-asp-net-mvc) which suggested that ASP.NET MVC routing could happen before ARR routing and I was not sure how intimate IIS is with the whole ARR routing. IIS became more modular with each major version bump. Your answer gives me some confidence that things will probably work fine. I don't do any reverse proxy or rewriting or anything, just plain ARR. – Csaba Toth Aug 18 '21 at 06:35