SShortSingh.
Back to feed

Spring Boot Batch Inserts Cut API Response Time 40% by Fixing Transactional Misuse

0
·1 views

A common misuse of Spring Boot's @Transactional annotation causes Hibernate to execute a separate database query for every item saved inside a loop, leading to severe performance degradation. For example, saving 50 items this way triggers 51 SQL queries instead of just 2. The fix involves enabling JDBC batch processing via Hibernate properties in application.properties and replacing individual repository.save() calls inside loops with repository.saveAll(). This change allows Hibernate to group all inserts into a single batched statement, drastically reducing database load. The optimization reportedly reduced API response time by 40%, highlighting that @Transactional manages transactions but does not automatically batch queries.

Read the full story at DEV Community

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

Related stories

0
ProgrammingDEV Community ·

How to Audit an Existing Subnet Plan Before a Cloud Migration

Teams preparing for cloud migration often inherit outdated network documentation, conflicting configurations, and unverified subnet allocations rather than a clean starting point. A structured audit requires gathering all router, firewall, DHCP, DNS, VPN, and cloud VPC data into a single inventory spreadsheet before any changes are made. Each subnet entry should include its CIDR, VLAN ID, gateway, DHCP range, owning team, and last-modified date to expose stale or redundant allocations. Common issues uncovered during audits include overlapping ranges from company acquisitions, oversized subnets justified by low host counts, and documentation that no longer matches live router configurations. The goal is to confirm that existing subnets remain fit for purpose and that new VPC ranges will not collide with anything carried over after cutover.

0
ProgrammingDEV Community ·

WebCodecs and WebGPU Enable Full Video Editing Inside the Browser

A new architectural approach allows developers to build real-time video editors that run entirely in the browser, eliminating the need for cloud-based GPU servers. By combining the WebCodecs API, WebGPU, and HTML5 Canvas, video decoding, processing, and re-encoding can be handled directly on a user's local hardware. This sidesteps the high latency and server costs associated with traditional cloud pipelines, where raw video data had to travel to remote infrastructure for processing. The WebCodecs API exposes hardware-accelerated codec access and delivers decoded frames as raw memory buffers, which can be fed into a WebGPU rendering pipeline without costly memory transfers. Paired with lightweight JavaScript demuxers, this stack enables a zero-copy, hardware-accelerated editing engine that runs fully client-side.

0
ProgrammingDEV Community ·

Connection Pool Exhaustion, Not Slow Queries, Was Behind Mysterious API Lag

A backend engineer recounts diagnosing a recurring production slowdown where API response times spiked from under 120ms to nearly 10 seconds every few hours, with no crashes or obvious errors in logs. Initial investigations into database queries, caching, and recent code commits yielded no answers, as the team was largely guessing rather than systematically tracing the problem. The breakthrough came from tracing a single slow request end-to-end, which revealed the application and database were both performing normally, pointing to an issue upstream of the application layer. The root cause turned out to be database connection pool exhaustion under certain traffic patterns, forcing new requests to queue for an available connection rather than execute a slow query. The incident highlights a broader lesson: slow systems are often waiting — for connections, locks, or resources — rather than performing expensive computation, making CPU and memory metrics alone unreliable indicators of latency problems.

0
ProgrammingDEV Community ·

AWS Strands Agent on Bedrock AgentCore Connects to Google and Azure via A2A Protocol

A developer has built a multi-cloud AI agent system where separate agents running on AWS, Google Cloud, and Azure communicate using the open Agent2Agent (A2A) protocol. The AWS side runs a Strands agent hosted on Amazon Bedrock AgentCore Runtime, a serverless container environment that isolates sessions in microVMs and handles scaling. A coordinator agent sends the same research query to all three cloud agents and returns the median result, keeping credentials out of shared storage. The project highlights key differences in container requirements across runtimes, including AgentCore's mandatory port 9000, ARM64 architecture, and a specific health-check endpoint at /ping. All source code is publicly available on GitHub, building on an earlier project that first demonstrated cross-cloud A2A connectivity between the three platforms.

Spring Boot Batch Inserts Cut API Response Time 40% by Fixing Transactional Misuse · ShortSingh