How to load balance a Spring Boot microservice database application
I’ve been working on microservices. I’ve used Spring Boot and seen how easy it is to get started. In my research, I read that this is a good approach, that each microservice, that is, a microservice that makes data access from a database, has its own database.
I’m curious how this works when starting multiple instances of the same microservice. Can those instances of the same microservice use only one database, or do they also need a separate database? My dilemma is that the data will vary across multiple databases. How does the load balancing microservice respond to this?
Edit after the first 3 comments
I appreciate the comments. I feel like I lack the idea behind explaining this issue. I’m used to building monolithic applications. I’ve used Spring and Hibernate (HibernatedAOSUPPORT) and, more recently, Hibernate Envers. I use Spring’s transaction management to manage the commit and rollback of the database. This has worked for me so far. I’ve started working on microservices, but so far I haven’t been able to find a proper explanation for how to use Spring Transaction Management with Hibernate and Envers as microservices with a single database. I can only understand that one instance of this microservice is working, but I’m curious if multiple instances of this microservice work correctly on one database. Especially considering the fact that hibernate caches database objects for performance reasons, not to mention envers and its operations.