Most Spring Boot apps don’t have performance problems… They have invisible problems 🔴 Built with Spring Boot + Hibernate, everything looks clean: ✔️ Controllers ✔️ Services ✔️ Repositories But behind the scenes: → 1 API call → 30+ queries → Duplicate executions → N+1 issues And you don’t notice… until production slows down. 📉 So I built something to expose it. 🛡️ Query Guard A Spring Boot starter that shows exactly what your database is doing per request. What it gives you: → Detects N+1 queries → Finds duplicate queries → Shows query execution flow (like tracing) → Works out-of-the-box with Prometheus + Grafana + Loki ⚡ Quick facts: ✅ Published on Maven Central ⚙️ Works with Spring Boot 3 & 4 🔌 Plug & play (no code changes) 📎 Inbuilt Dashboard & Query Explorer 🧪 I have built a demo app With intentional: → N+1 issues → Duplicate queries 👉 So you can see the problem, not just read about it Demo: https://lnkd.in/gvtAnPHw Starter: https://lnkd.in/gC5hKjg3 Most tools tell you: ❌ “Your API is slow” This tells you: ✅ Why ✅ Where ✅ How often Would love your feedbacks... #SpringBoot #Java #Backend #Performance #Hibernate #OpenSource #PoojithaIrosha
Exposing Hidden Performance Issues in Spring Boot Apps with Query Guard
More Relevant Posts
-
Your Spring Boot API is slow. Not because of bad code. Because of invisible garbage. A simple request like GET /api/users/123 looks harmless. But Spring Boot creates a storm of temporary objects you never see: → Tomcat builds request/response objects → Spring Security creates SecurityContext → Filters wrap everything in decorators → Hibernate creates lazy-load proxies → Dirty checking snapshots entity state → Jackson builds serialization objects → @Transactional wraps services in proxies You wrote 15 lines. The framework created thousands of objects. At 100 RPS? Fine. At 1,000 RPS? Disaster. Young Gen fills every second GC runs constantly p99 latency spikes CPU burns on cleanup, not business logic No crash. No exception. Just mysteriously slow performance. ━━━━━━━━━━━━━━━━ How I reduce object creation: Return DTOs, not entities Use @Transactional(readOnly = true) for reads Use log placeholders: log.info("User {}", id) Prefer primitives (int vs Integer) in hot paths Avoid streams/maps in performance-critical loops Tune JVM Young Gen size Profile with Java Flight Recorder ━━━━━━━━━━━━━━━━ The real performance truth: The fastest code isn't code that executes the fastest. It's code that creates the least garbage. Master this, and your APIs will scale. What's your go-to optimization for high-traffic Spring Boot apps? #SpringBoot #Java #Microservices #BackendDevelopment #SoftwareArchitecture
To view or add a comment, sign in
-
-
Most slow Spring Boot apps have the same problem. It's not the database. It's how you ask it. After years debugging production performance, I see the same pattern over and over: The N+1 query problem. You fetch a list of orders. Looks fine. Then you loop through them and access order.getCustomer(). Hibernate happily fires one extra query per order. 100 orders → 101 queries. Your endpoint goes from 50ms to 4 seconds. Your database CPU climbs. Nobody understands why. The trap is that the code looks clean. Lazy loading is doing exactly what it said it would. The framework isn't broken. The mental model is. What actually fixes it: - JOIN FETCH for predictable, single-use queries - @EntityGraph for reusable fetch plans - Batch fetching (hibernate.default_batch_fetch_size) when you need lazy but not crazy - DTO projections when you don't need the full entity at all ⚠️ The mistake most teams make is enabling spring.jpa.show-sql=true, seeing 5 queries per request, and shrugging. Five becomes fifty under load. Fifty becomes the incident. The fix is not "tune the database." The fix is reading what your ORM is actually doing. Hibernate is not slow. Most Hibernate code is. What's the worst N+1 you've seen in production? #Java #SpringBoot #Backend #Hibernate #Performance #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 Spring Boot Annotations Cheat Sheet – A Must for Every Java Developer! Just revised 120+ essential Spring Boot annotations and it’s a solid reminder of how much power is packed into the framework. From core configuration to advanced topics, here’s a quick breakdown 👇 🔹 Core Annotations - "@SpringBootApplication" – Entry point of your app - "@Configuration", "@Bean", "@Component" – Backbone of Spring context 🔹 Dependency Injection - "@Autowired", "@Qualifier", "@Inject" – Clean and flexible wiring 🔹 Stereotype Layers - "@Controller", "@Service", "@Repository" – Clear separation of concerns 🔹 Spring MVC - "@RequestMapping", "@GetMapping", "@PostMapping" – API handling made simple - "@RequestBody", "@PathVariable", "@RequestParam" – Data binding essentials 🔹 Spring Data JPA - "@Entity", "@Id", "@OneToMany", "@Transactional" – ORM simplified 🔹 Configuration & Profiles - "@ConfigurationProperties", "@Profile", "@Conditional*" – Environment control 🔹 Async & Scheduling - "@Async", "@Scheduled", "@EnableScheduling" – Performance & automation 🔹 Validation & Caching - "@Valid", "@NotNull", "@Cacheable", "@CacheEvict" – Clean & optimized apps 🔹 Testing & Security - "@SpringBootTest", "@MockBean", "@PreAuthorize" – Reliable & secure systems 📌 What stands out: Spring Boot abstracts complexity but still gives fine-grained control when needed. If you're working with Spring daily, mastering these annotations is not optional—it’s foundational. 📄 Source: Spring Boot Annotations Cheat Sheet 💬 Which Spring annotation do you use the most in your projects? #SpringBoot #Java #BackendDevelopment #Microservices #Hibernate #API #Developers
To view or add a comment, sign in
-
A well-made cheat sheet can save hours of confusion. Came across this clear Spring Boot annotations guide and found it genuinely useful for beginners learning backend development. It helps in understanding: ✅ Which annotation is used where ✅ Why it is used ✅ How different layers connect in Spring projects ✅ Common annotations worth knowing first Big appreciation to the Akash Baghel 👏 for simplifying such a wide topic into an easy visual format. My takeaway: don’t try to memorize all annotations at once. Learn them gradually while building projects and understanding real use cases. Definitely worth saving for anyone learning Java + Spring Boot. #Java #SpringBoot #BackendDevelopment #Programming #LearningJourney #SoftwareEngineering
🚀 Spring Boot Annotations Cheat Sheet – A Must for Every Java Developer! Just revised 120+ essential Spring Boot annotations and it’s a solid reminder of how much power is packed into the framework. From core configuration to advanced topics, here’s a quick breakdown 👇 🔹 Core Annotations - "@SpringBootApplication" – Entry point of your app - "@Configuration", "@Bean", "@Component" – Backbone of Spring context 🔹 Dependency Injection - "@Autowired", "@Qualifier", "@Inject" – Clean and flexible wiring 🔹 Stereotype Layers - "@Controller", "@Service", "@Repository" – Clear separation of concerns 🔹 Spring MVC - "@RequestMapping", "@GetMapping", "@PostMapping" – API handling made simple - "@RequestBody", "@PathVariable", "@RequestParam" – Data binding essentials 🔹 Spring Data JPA - "@Entity", "@Id", "@OneToMany", "@Transactional" – ORM simplified 🔹 Configuration & Profiles - "@ConfigurationProperties", "@Profile", "@Conditional*" – Environment control 🔹 Async & Scheduling - "@Async", "@Scheduled", "@EnableScheduling" – Performance & automation 🔹 Validation & Caching - "@Valid", "@NotNull", "@Cacheable", "@CacheEvict" – Clean & optimized apps 🔹 Testing & Security - "@SpringBootTest", "@MockBean", "@PreAuthorize" – Reliable & secure systems 📌 What stands out: Spring Boot abstracts complexity but still gives fine-grained control when needed. If you're working with Spring daily, mastering these annotations is not optional—it’s foundational. 📄 Source: Spring Boot Annotations Cheat Sheet 💬 Which Spring annotation do you use the most in your projects? #SpringBoot #Java #BackendDevelopment #Microservices #Hibernate #API #Developers
To view or add a comment, sign in
-
N+1 Query Problem (Hibernate / JPA) Your Spring Boot app is fast… until it hits the database. Then suddenly: 👉 1 query becomes 101 👉 and your API dies under load I saw this in a production audit last week. // ❌ Looks harmless List<User> users = userRepository.findAll(); for (User user : users) { System.out.println(user.getOrders().size()); } 🚨 What actually happens: • 1 query to fetch users • +1 query PER user to fetch orders 👉 This is called the N+1 problem 💥 Real production impact: • DB overload • Massive latency increase • Works in dev… crashes in prod ⚠️ Important nuance (don’t get roasted in comments 😄) This happens when: 👉 @OneToMany(fetch = LAZY) (default) If it's EAGER, behavior changes (but creates other problems) ✅ Fix: // ✔️ Use fetch join @Query("SELECT u FROM User u JOIN FETCH u.orders") List<User> findAllWithOrders(); OR // ✔️ Use EntityGraph @EntityGraph(attributePaths = "orders") List<User> findAll(); 🧠 Takeaway: If you don’t control your queries… your database will control you. Are you sure your app isn’t doing 100 hidden queries right now? #JavaDev #SpringBoot #Hibernate #JavaPerformance #Backend #SoftwareEngineering
To view or add a comment, sign in
-
-
Is FetchType.EAGER silently killing your performance? 🚨 One mistake I’ve seen repeatedly in Spring Boot applications is overusing EAGER fetching. Looks harmless… until it hits production. The problem 👇 Every time you fetch a parent entity, Hibernate also loads the entire child collection. Now imagine: → A user with 5,000 orders → A department with 50,000 employees Your “simple query” just became a massive memory load. This doesn’t just slow things down… it stresses your entire JVM. What I follow instead 👇 ✔ Default to LAZY ✔ Use JOIN FETCH when needed ✔ Use @EntityGraph for controlled fetching Your entity design is not just structure. It’s a performance decision. Better to write 1 extra query… than load 10,000 unnecessary records. Curious to hear from other devs 👇 Do you treat FetchType.EAGER as a bad practice? Or still use it in some cases? #Java #SpringBoot #JPA #Hibernate #BackendDevelopment #SoftwareEngineering #Performance #TechDiscussion
To view or add a comment, sign in
-
-
Spring Boot Annotations Cheat Sheet – A Must for Every Java Developer! Just revised 120+ essential Spring Boot annotations and it’s a solid reminder of how much power is packed into the framework. From core configuration to advanced topics, here’s a quick breakdown 👇 🔹 Core Annotations - "@SpringBootApplication" – Entry point of your app - "@Configuration", "@Bean", "@Component" – Backbone of Spring context 🔹 Dependency Injection - "@Autowired", "@Qualifier", "@Inject" – Clean and flexible wiring 🔹 Stereotype Layers - "@Controller", "@Service", "@Repository" – Clear separation of concerns 🔹 Spring MVC - "@RequestMapping", "@GetMapping", "@PostMapping" – API handling made simple - "@RequestBody", "@PathVariable", "@RequestParam" – Data binding essentials 🔹 Spring Data JPA - "@Entity", "@Id", "@OneToMany", "@Transactional" – ORM simplified 🔹 Configuration & Profiles - "@ConfigurationProperties", "@Profile", "@Conditional*" – Environment control 🔹 Async & Scheduling - "@Async", "@Scheduled", "@EnableScheduling" – Performance & automation 🔹 Validation & Caching - "@Valid", "@NotNull", "@Cacheable", "@CacheEvict" – Clean & optimized apps 🔹 Testing & Security - "@SpringBootTest", "@MockBean", "@PreAuthorize" – Reliable & secure systems 📌 What stands out: Spring Boot abstracts complexity but still gives fine-grained control when needed. If you're working with Spring daily, mastering these annotations is not optional—it’s foundational. 📄 Source: Spring Boot Annotations Cheat Sheet 💬 Which Spring annotation do you use the most in your projects? #SpringBoot #Java #BackendDevelopment #Microservices #Hibernate #API #Developers
To view or add a comment, sign in
-
🚀 Spring Framework 🌱 | Day 6 Spring Framework Important Annotations Cheat Sheet If you're working with Spring, mastering annotations can save you tons of development time and make your code clean & maintainable. Here’s a quick cheat sheet 👇 🔹 Core Annotations ✔ @Component → Generic Spring-managed bean ✔ @Service → Business logic layer ✔ @Repository → DAO layer (handles DB exceptions) ✔ @Controller → Web controller (returns view) ✔ @RestController → REST APIs (returns JSON) 🔹 Dependency Injection ✔ @Autowired → Inject dependency automatically ✔ @Qualifier → Resolve multiple bean conflicts ✔ @Primary → Set default bean 🔹 Request Handling (Spring MVC) ✔ @RequestMapping → Map HTTP requests ✔ @GetMapping / @PostMapping / @PutMapping / @DeleteMapping ✔ @PathVariable → Read values from URL ✔ @RequestParam → Read query params ✔ @RequestBody → Read JSON input ✔ @ResponseBody → Return JSON response 🔹 Configuration ✔ @Configuration → Java-based config ✔ @Bean → Define custom beans ✔ @Value → Inject values from properties 🔹 Validation ✔ @Valid → Trigger validation ✔ @NotNull / @Size / @Email (JSR-303) 🔹 Exception Handling ✔ @ExceptionHandler → Handle specific exceptions ✔ @ControllerAdvice → Global exception handling 🔹 Advanced (Must Know) ✔ @Transactional → Manage DB transactions ✔ @EnableAutoConfiguration → Auto config (Spring Boot) ✔ @SpringBootApplication → Main class annotation 💡 Clean code + right annotations = scalable applications #SpringFramework #Java #SpringBoot #BackendDevelopment #SoftwareEngineering #InterviewPreparation
To view or add a comment, sign in
-
-
🚀 What Really Happens When You Hit an API in Spring Boot? (Most beginners skip this — don't be one of them!) When I first started using Spring Boot, I knew how to write an API — but I had no idea what happened the moment I hit that endpoint. Turns out, there's an entire journey happening behind the scenes. Here's the full flow, broken down simply 👇 🔹 Tomcat — The Gatekeeper Every request first lands on the embedded Tomcat server. It listens on port 8080 and receives the raw HTTP request before anything else. 🔹 DispatcherServlet — The Front Controller This is the real entry point of Spring MVC. One servlet handles every single request and decides where it needs to go — like a receptionist routing calls across an office. 🔹 Handler Mapping — The Directory DispatcherServlet doesn't guess. It asks Handler Mapping — which controller owns this URL and HTTP method? 🔹 Interceptor — The Security Check Before your code even runs, interceptors handle cross-cutting concerns — authentication, logging, rate limiting. 🔹 Controller → Service → Repository — The Layers You Already Know The request flows through your layered architecture exactly the way we discussed last time. Controller routes, Service processes, Repository fetches. 🔹 Jackson — The Translator On the way back, Jackson silently converts your Java object into JSON. No extra code needed. 🔹 Response — Back to the Client Clean JSON, delivered. 💡 The biggest shift for me? Realizing that even a simple GET /users/1 triggers an entire coordinated flow — and Spring Boot handles most of it invisibly, so you can focus on what matters. #SpringBoot #Java #BackendDevelopment #SoftwareEngineering #JavaDeveloper #SpringFramework #APIDesign #CodingJourney
To view or add a comment, sign in
-
-
#Java #Spring #Bean 🌱 Spring Bean Lifecycle 👉 In Spring Framework, bean lifecycle has 5 simple steps: 🔄 Lifecycle Steps 1️⃣ Instantiate ➡️ Spring creates object 2️⃣ Inject Dependencies 💉 ➡️ Dependencies added (@Autowired) 3️⃣ Initialize ⚙️ ➡️ Setup using @PostConstruct 4️⃣ Use Bean 🚀 ➡️ Business logic runs 5️⃣ Destroy 🧨 ➡️ Cleanup using @PreDestroy 🧠 One-Line 👉 Spring Bean Lifecycle = Create → Inject → Initialize → Use → Destroy (managed by Spring Container)
To view or add a comment, sign in
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development