I had an API returning correct data. But response time was too high. Issue turned out to be unnecessary data being fetched from DB. Reduced fields, optimized query. Small change, big impact. #Backend #Java #SpringBoot #Performance
Sameer Gupta’s Post
More Relevant Posts
-
A single slow Database query almost brought down a production system I worked on. Not because of the query itself, but because it consumed every available thread, leaving nothing for the services that actually mattered. The fix? Bulkhead Semaphore pattern. Isolate your thread pools. Set a queue. Define a fallback. The slides show exactly how. Full Resilience4j docs: https://lnkd.in/dyMxUx_j #java #springboot #backend #resilience4j #softwareengineering
To view or add a comment, sign in
-
Recently worked on improving API performance in a backend system ⚡ 📉 Problem: High response time under load 🔧 What I did: Optimized DB queries Introduced caching Refactored inefficient logic 📈 Result: ~40% performance improvement 🚀 💡 Lesson: Performance issues are rarely about one thing — it’s always a combination. Small improvements → Big impact. #BackendDevelopment #PerformanceOptimization #Java #Engineering
To view or add a comment, sign in
-
🚨 Fetching all data from DB is a silent performance killer I once saw an API fetching 50,000 records in one go. 💥 Result: High memory usage Slow response Occasional crashes ✅ Fix: Used pagination: Pageable pageable = PageRequest.of(page, size); 💡 Bonus: Added sorting + limit control from API 💡 Takeaway: Never trust frontend to “handle large data” Backend should enforce limits. #Java #SpringBoot #BackendDevelopment #SoftwareEngineering #Microservices #JPA #RESTAPI #DeveloperLife #CareerGrowth
To view or add a comment, sign in
-
When updating data in a Spring Boot API, standard validation can be too restrictive, often requiring all fields to be sent even for minor changes. A more flexible solution is to use @Validated with validation groups. This approach allows you to define separate sets of rules. For example, you can have a "create" group that requires all fields to be present, and a "default" group that only checks the format of fields that are actually provided in the request. In your controller, you then apply the appropriate rule set: the strict rules for creating new items and the flexible rules for updating them. This allows your API to handle both full and partial updates cleanly while reusing the same data object, resulting in more efficient code. #SpringBoot #Java #API #Validation #SoftwareDevelopment
To view or add a comment, sign in
-
-
How I improved API performance by ~40% 🚀 Problem: Slow response time due to heavy DB queries What I changed: • Optimized SQL queries • Added indexing • Reduced unnecessary joins • Used proper pagination Result: Faster APIs Better user experience Most performance issues are not in code, they’re in the database. #Backend #Java #Performance #Microservices #TechTips
To view or add a comment, sign in
-
🚀 Developed a basic REST API using Spring Boot to handle HTTP requests and responses. 🔹 What I implemented: Created a REST Controller using @RestController Used @RequestMapping to define base URL (/api) Built a GET API using @GetMapping("/student") 🔹 API Endpoint: http://localhost:8080/api/student 🔹 Output: "Student data" 🔹 Key Learnings: How Spring Boot handles HTTP requests Understanding request → controller → response flow Basics of REST API development Excited to move next into POST APIs and sending real data using @RequestBody 🔥 #SpringBoot #Java #BackendDevelopment #LearningJourney #CSE
To view or add a comment, sign in
-
-
Stop wasting memory on threads that do nothing. 🛑 If you’re building Java backends, you’ve probably seen this: More users → more threads → more RAM usage I recently explored Virtual Threads (Java 21 / Project Loom), and this concept finally clicked for me. 💡 The Problem In standard Java: 1 request = 1 Platform Thread During DB/API call → thread gets blocked It’s like a waiter standing idle while food is cooking 🍽️ 👉 Wasted resources + poor scalability 🔍 The Solution: Virtual Threads 👉 Lightweight threads managed by JVM (not OS) Cheap to create Can run thousands easily Perfect for I/O-heavy backend systems ⚙️ How it actually works (Mounting / Unmounting) 1️⃣ Mounting Virtual Thread runs on a Carrier Thread (Platform Thread) 2️⃣ I/O Call (DB/API) Your code looks blocking 3️⃣ Unmounting (Parking) Virtual Thread is paused & parked in heap memory 👉 It releases the Carrier Thread 4️⃣ Carrier Thread is free Handles another request immediately 5️⃣ Remounting (Resume) Once response comes → Virtual Thread continues 💻 The "magic" in code // Looks like blocking code Runnable task = () -> { System.out.println("Processing: " + Thread.currentThread()); String data = fetchDataFromDB(); // DB/API call System.out.println("Result: " + data); }; // Run using Virtual Thread Thread.ofVirtual().start(task); 🧩 What’s happening behind the scenes? 👉 Thread.ofVirtual() Creates a lightweight thread (stored in heap, not OS-level) 👉 During DB/API call Virtual Thread gets unmounted (parked) Carrier Thread becomes free 👉 While waiting Same thread handles other requests 👉 When response comes Scheduler remounts Virtual Thread Execution continues 📈 Result No idle threads Better resource usage Simple synchronous code High scalability without complex async code 🧠 Biggest takeaway 👉 “Code looks blocking… but system is not blocked.” That’s the mindset shift. Have you tried Virtual Threads in your services yet? Did you see any real performance improvement? 🤔 #Java #BackendEngineering #VirtualThreads #ProjectLoom #Java21 #Microservices #Performance
To view or add a comment, sign in
-
-
Recently, I shared how reducing multiple API calls improved performance. This time, I ran into a different issue. My API response looked fine… until I saw the payload size. While working on a feature, everything was working as expected. But the response felt heavier than it should be. After checking, I realized I was returning full objects, even when only a few fields were actually needed. So for a single request, I was sending a large JSON response unnecessarily. I made a small change: Instead of returning everything, I started sending only what the client actually needs. Used DTOs to control the response and removed unused fields. That made a clear difference: - Smaller payload - Faster response - Cleaner API Last time, the issue was too many API calls. This time, it was too much data in one call. (Check the previous post: https://lnkd.in/gxSKFVbk) Sometimes performance issues are not about complex fixes… they’re about reducing unnecessary work. #Java #BackendDevelopment #SpringBoot #API #Performance #LearningInPublic
To view or add a comment, sign in
-
-
How Spring Boot Handles Requests Internally (Deep Dive) Ever wondered what happens when you hit an API in Spring Boot? 🤔 Here’s the real flow 👇 🔹 DispatcherServlet Acts as the front controller receives all incoming requests 🔹 Handler Mapping Maps the request to the correct controller method 🔹 Controller Layer Handles request & sends response 🔹 Service Layer Contains business logic 🔹 Repository Layer Interacts with database using JPA/Hibernate 🔹 Response Handling Spring converts response into JSON using Jackson 🔹 Exception Handling Handled globally using @ControllerAdvice 💡 Understanding this flow helped me debug issues faster and design better APIs. #Java #SpringBoot #BackendDeveloper #Microservices #RESTAPI #FullStackDeveloper #LearningInPublic
To view or add a comment, sign in
-
-
🚀 Spring Boot — Why I stopped using Entity in request body Earlier, I used to accept Entity directly in my APIs: @PostMapping("/users") public User createUser(@RequestBody User user) { return userService.save(user); } It worked… but later I realized the problem. ⸻ Issues I faced: ✔ Unnecessary fields coming from request ✔ Hard to control what client sends ✔ Tight coupling with DB structure What I do now: Use DTO instead: @PostMapping("/users") public User createUser(@RequestBody UserDto dto) { return userService.create(dto); } ✔ Only required fields ✔ Better validation ✔ Cleaner API contract ⸻ ⭐ Simple rule: 👉 Entity → database 👉 DTO → request/response Small change, but made APIs much safer. Do you accept Entity or DTO in your request body? #SpringBoot #JavaDeveloper #BackendDevelopment #LearningInPublic #Java
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