How a Single @Transactional Annotation Can Crash Your Spring Boot App Under Load
A common but dangerous pattern in Spring Boot applications involves placing the @Transactional annotation on methods that also make external HTTP calls, such as payment gateway requests. When this happens, a database connection is borrowed from the HikariCP pool at the start of the transaction and held open for the entire duration, including the time spent waiting for the third-party API to respond. Since external calls can take seconds, even moderate traffic can exhaust all available connections in the pool, causing new requests to time out and the application to become unresponsive. The outage can appear misleading because CPU, memory, and database metrics all look healthy, masking the real bottleneck. Developers can fix this by using programmatic transaction boundaries, domain events with @TransactionalEventListener, or the Transactional Outbox pattern to ensure database connections are not held during external I/O.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.



Discussion (0)
Log in to join the discussion and vote.
Log in