DEV Community

Cover image for ๐Ÿšจ Why Your Spring Boot API Takes 3 Seconds to Respond (And How We Reduced It to 200 ms)
Pramod Kumar
Pramod Kumar

Posted on

๐Ÿšจ Why Your Spring Boot API Takes 3 Seconds to Respond (And How We Reduced It to 200 ms)

Before optimization: ~3000 ms
After optimization: ~200 ms

Our Spring Boot API suddenly started taking 3 seconds to respond in production.

But in development it was only 150โ€“200 ms.

After profiling the system we discovered the issue wasn't one big problem.

It was several small performance bottlenecks working together:

  • N+1 Hibernate queries
  • missing database indexes
  • blocking controller operations
  • excessive logging
  • large JSON responses

After fixing them step by step, the response time dropped from 3 seconds to around 200 ms.

Here are the exact improvements that made the difference.

๐Ÿ‘‰ Originally published on Medium. Republished here for the Dev.to community:
https://medium.com/@pramod.er90/why-your-spring-boot-api-takes-3-seconds-to-respond-and-how-to-fix-it-160f37a4aaa7

Top comments (1)

Collapse
 
pramod_kumar_0820 profile image
Pramod Kumar

Whatโ€™s the slowest API response time youโ€™ve ever debugged?