How do you implement load balancing for gRPC in Spring Boot?
gRPC keeps one HTTP/2 connection, so plain TCP balancing fails. Configure round_robin, DNS targets and headless services in Spring Boot to spread calls.
Spread Your Knowledge. Questions with answers, tutorials and articles, newest first.
gRPC keeps one HTTP/2 connection, so plain TCP balancing fails. Configure round_robin, DNS targets and headless services in Spring Boot to spread calls.
Route each request to a different database in Spring using AbstractRoutingDataSource, from multi-tenant routing to read replicas, with safe context handling.
AbstractRoutingDataSource lets a single DataSource pick a target database at runtime from a lookup key. Learn multi-tenant routing, read/replica splitting and common pitfalls.
StatusRuntimeException is the unchecked grpc-java exception that wraps a gRPC Status. See how to return errors from servers, handle them in clients and add details.
Define one DataSource per database, mark one @Primary, and give each its own JPA entity manager factory and transaction manager.
Mark read-only service methods with @Transactional(readOnly = true) to skip Hibernate flushing and enable replica routing, and learn why it is a hint, not a guarantee.
Return the right gRPC status codes from Spring Boot services, map exceptions in one @GrpcAdvice class, and handle StatusRuntimeException on the client.
StreamObserver is gRPC Java's callback interface for sending and receiving message streams. See how it powers server, client and bidirectional streaming.
REQUIRES_NEW suspends the active transaction and runs the method in a separate one. See batch and audit use cases, rollback outcomes and pitfalls.
Understand all seven Spring propagation levels, when to use REQUIRES_NEW or NESTED, and why propagation settings are sometimes ignored.
@Rollback controls whether a Spring test transaction is rolled back or committed after each test. See the defaults, @Commit and what rollback does not undo.
TransactionTemplate runs code in a transaction without annotations. See execute, rollback, propagation and timeout settings, and when to prefer @Transactional.
Implement gRPC server, client and bidirectional streaming in Spring Boot with StreamObserver, a complete proto file, working client code and deadline handling.
TransactionSynchronizationManager is Spring's thread-bound registry for transaction resources and callbacks. See how it works and when to use it directly.
ManagedChannel is the long-lived client connection in gRPC Java. Learn how to build, share, configure and shut it down correctly.
Configure Spring transaction management in Boot or plain Spring, handle several data sources, and use TransactionalEventListener for post-commit work.
Spring Boot auto-configures the transaction manager, so @Transactional on service methods is usually enough. Learn rollback rules, propagation and pitfalls.
PlatformTransactionManager defines how Spring begins, commits and rolls back transactions. Compare its implementations and see how @Transactional uses it.
Extend AbstractPlatformTransactionManager, bind your resource to the thread and register the manager so @Transactional works for a custom data source.
@Transactional comes from Spring, not Hibernate. See how it controls the Session, dirty checking, lazy loading and rollback in a Hibernate app.