I have a simple ASP Core based website that is connected to my local SQL Server Express, some of the third party plugins used, do have reliance on other products i.e. scheduling timers.
I would like to test this site to ensure when it is on a Load Balanced environment it would work as expected. For that reason i have
- Installed and configured docker.
- Created a
Dockerfile
within the website - Created an image of my site.
- The site is using
host.internal
as part of the connection string for SQL Express - The site runs from docker and connects to the database which is hosted on my machine.
I have 2 websites (one hosted locally and the other from the image/container in docker). One database. Both sites connect to the same database.
After further research i believe i need to setup a load balancer next but confused as after reading more into it, some have it so the docker (or at least the way i think the recommend approach is) setup should mimic what i need to test and to open up ports.
What would be the next recommended step in this journey to get the site tested? I know this maybe an open question but if i can see which way i need to head then that would really help.
-
1"I would like to test this site to ensure when it is on a Load Balanced environment it would work as expected." --- I'm not sure what "it would work as expected" means in this context. Are you testing the application functionality? Performance? Are you testing that it is load balanced?Greg Burghardt– Greg Burghardt2025年05月07日 12:21:55 +00:00Commented May 7 at 12:21
-
docs.docker.com/guides/traefikEwan– Ewan2025年05月07日 16:50:32 +00:00Commented May 7 at 16:50
-
Generally speaking it is imprecise to test how something operates in a specific environment when not testing it in that specific environment. Even if you run multiple instances on your local machine, it cannot accurately portray the performance profile of running instances on separate machines. This question seems rooted in a lack of a production-like testing environment, and it may prove to be a significantly more productive avenue to simply provision such an environment instead of trying to come up with novel ways of avoiding doing so.Flater– Flater2025年05月08日 01:32:12 +00:00Commented May 8 at 1:32
1 Answer 1
Add a load balancer container (using NGINX, HAProxy etc.) in your Docker setup to distribute incoming requests between your two website instances. Use Docker Compose to orchestrate the load balancer and the app containers, ensuring that your connection string adjusts (e.g., using host.docker.internal if needed) and that stateful features like in-memory sessions and scheduled timers are properly managed in a multi-instance environment.
This answer reflects my personal experience and research. Your specific environment may require additional tuning or architectural changes, so please consult the latest documentation for load balancing in .NET Core environments. If you have any questions or need clarification—or if you can share other approaches from your own experience—I'd be happy to discuss further or update my answer. I am also here to learn if anybody knows better opinion or clarification open to discuss.
Disclaimer: I'm not very experienced with this particular topic and I'm still learning, but I’d like to try sharing my approach based on what I've gathered so far.
You can consider these links:
Explore related questions
See similar questions with these tags.