Search code examples
asp.net-coreamazon-elb

Does load balancer run startup.cs multiple times?


I have an app that deployed to AWS ELB with a load balancer. in my startup.cs I have logic where when it runs the first time I change all active records in DB to another state. and I've noticed especially when lots of people request to the server the state change automatically.

I just wanted to know is it possible for that load balancer runs the startup.cs multiple times when it needed to stretch to multiple computers? e.g first it runs the program on one computer and when more people joining it creates another instance and runs the startup.cs again in another machine?


Solution

  • Yes. It runs on app startup for each instance. It's not the "load balancer" that executes the startup file 5 times, ASP.NET will execute it when the instance starts and if you have 5 instances it will execute 5 times (once per instance).