Hi @David Thielen turning off session affinity won't really be useful to you if I understand your scenario correctly because you're basically testing a stateless architecture and you don't have access to a specific server. Azure App Service is a PaaS offering which takes care of auto-scaling for you but if you need more control over the VMs, IP address on which your app runs, load balancing, scaling and all server management then consider using Azure Virtual Machines.
Here are my specific answers to your questions
- What/how should I test this?: You can also test session persistence, load balancing, failure handling
- Session persistence: Make requests that modify session state (e.g., add items to a cart) and then make subsequent requests to see if the state is maintained. With session affinity off, you should see inconsistencies.
- Load balancing: Send a high volume of requests quickly (you can use tools like Apache JMeter or Azure Load Testing) and monitor your logs to see if requests are distributed across both servers.
- Failure handling: Simulate a server failure by manually scaling down to one instance mid-test to see if requests are handled correctly by the remaining server.
- Hitting a specific server: the short answer is no. In Azure App Service, you don't have direct access to the underlying VMs or their IP addresses. The load balancer handles request distribution. With session affinity off, there's no way to target a specific server. That's the point—requests should be distributed randomly. Even with session affinity on, you can't choose which server handles a session; Azure manages this.
- Using
Environment.MachineName
in logs: Yes,Environment.MachineName
is a good approach. It provides a unique identifier for each server instance. In Azure App Service, this will typically be something likeRD00155D3809A0
or similar. This helps you track which server handled each request, especially useful when session affinity is off. - Setting up server machine names: Like I mentioned above, with Azure App Service you don't have direct control over the machine names. They are automatically assigned by Azure.
- Other considerations: you may want to monitor server resources (CPU, memory) in the Azure portal to ensure load is distributed, enable Application Insights to track request flows and server handling and test database connections to ensure they're being managed correctly across servers. You can also set up auto-scaling rules based on metrics like CPU or request count to test dynamic scale-out.
Hope that helps.
-Grace