C
C#8mo ago
coado

Databases load balancing

Hey everyone, I have to create a load balancer between databases. I am using EF core to build queries and manage database connections. I wonder if changing the database connection in interceptors is possible. For example, I have a DBContext instance connected to database1, and in the interceptor, I want to run a round-robin algorithm that will change the connection between database1, database2, etc. The second approach that came to my mind is to create a proxy that will act as a "database" (it will listen for queries). It would redirect the requests between multiple real databases. I will connect DBContext to my proxy in my server that uses EF Core. I am unsure if it's possible and how to go about this. I am new to C# and this is my assignment for university, so any help is appreciated. Thanks! Hey everyone, I have to create a load balancer between databases. I am using EF core to build queries and manage database connections. I wonder if changing the database connection in interceptors is possible. For example, I have a DBContext instance connected to database1, and in the interceptor, I want to run a round-robin algorithm that will change the connection between database1, database2, etc. The second approach that came to my mind is to create a proxy that will act as a "database" (it will listen for queries). It would redirect the requests between multiple real databases. I will connect DBContext to my proxy in my server that uses EF Core. I am unsure if it's possible and how to go about this. I am new to C# and this is my assignment for university, so any help is appreciated. Thanks!
4 Replies
Angius
Angius8mo ago
Database load balancing is not something that should be handled at the application level It should be a reverse proxy between the application and the databases Directing the queries from the application to the appropriate db Something like HAProxy for example
coado
coado8mo ago
Yes, that make sense. Is it possible to make very simple one from scratch and connects to it using EFCore or some other ORM?
Angius
Angius8mo ago
Sure All a reverse proxy, ultimately, does, is takes the incoming traffic and redirects it So you should be able to just run the proxy at the address and port of the database, capture the incoming traffic, and redirect it to the actual database
coado
coado8mo ago
Okay, but what about migrations? Is it possible to run migration on all databases at once?
Want results from more Discord servers?
Add your server
More Posts
✅ Make C# Application work directory independent, relativ work directory for exe fileHello guys, I want my C# Application Executable Everywhere, also on other PC's, currently my exe fiUnity Movement systemEverything works except for going up hills. It kinda lags out and does it very slowely only pushing ASP.Net Core MVC Razor view rendering data from controller with dynamic castingIn my MVC application I'm using IEnumerable interface inside my repository for the database model, a"ExtensionlessUrlHandler-Integrated-4.0"I've been struggling with getting my local IIS on Win 11 to host some older (4.5.1) MVC applicationsASP .NET 7 - Testing a JWT Token GeneratorI have an ASP .NET web api which calls a CreateToken() method inside a TokenService to generate a JWCount the number of sequences of characters "cd" in a line and delete those before itletter 'b' (reHow to do it in c#... I would be very grateful if anyone could help with a sample codeInconsistent accessibility: property type 'Exercises.Register.Gender' is less accessible than properI honestly have no clue how it's having issues with accessibility when both classes are within the scookie clicker storeHello i am here ones again asking for help. My store buttons need to be dissabled if i don't have teWhere to change working directory in VS2022?How do you change the working directory for a project in Visual Studio? The project I'm working on Can you store a unique function within a class?I'm new to working with classes in C# and would like to be able to use them for a game I'm working o