🧠 Phase 4: How Requests Are Handled (Real System Design) This is where things get serious. Every request follows this pattern: 👉 1 request = 1 thread Flow: Request hits server A thread is assigned Your code executes Response is sent back Thread is released Simple… but powerful. ⚠️ Here’s the catch: That thread is blocked until the request completes. So if: Your DB call takes 2 seconds That thread is stuck for 2 seconds Now imagine: 100 requests → 100 threads → potential bottleneck To manage this: Thread pools are used Requests are queued under load Limits are applied 💡 This is the foundation of backend scalability decisions If you understand this, you’ve already moved beyond most developers. #SpringBoot #Java #BackendDevelopment #SoftwareEngineering #SystemDesign #WebDevelopment #Programming #Developers #Scalability #PerformanceEngineering #Concurrency #SystemDesignInterview #BackendEngineering
How Requests Are Handled in Real System Design
More Relevant Posts
-
𝗢𝗽𝘁𝗶𝗼𝗻𝗮𝗹.𝗼𝗿𝗘𝗹𝘀𝗲() 𝗘𝘅𝗲𝗰𝘂𝘁𝗲𝘀 𝗘𝘃𝗲𝗻 𝗪𝗵𝗲𝗻 𝗩𝗮𝗹𝘂𝗲 𝗣𝗿𝗲𝘀𝗲𝗻𝘁 ⚠️ Looks harmless. It’s not. User user = findUserInCache(userId) .orElse(loadUserFromDatabase(userId)); Many developers read this as: 👉 "load from DB only if cache missed" But that is not what happens. 🔥 What actually happens orElse(...) is eager. That means the argument is evaluated before orElse() is called. So even when user is already present in cache, this still runs: 👉 loadUserFromDatabase(userId) Effectively: User fallback = loadUserFromDatabase(userId); // always executed User user = findUserInCache(userId).orElse(fallback); 💥 Why this hurts in production That fallback is often not cheap. It can be: 🔹 DB query 🔹 remote API call 🔹 disk read 🔹 heavy object construction So what looked like a safe fallback becomes hidden work on every request. 👉 extra CPU 👉 unnecessary IO 👉 more latency 👉 performance regression that is easy to miss in review ✅ The correct approach Use orElseGet(...) when fallback is expensive. User user = findUserInCache(userId) .orElseGet(() -> loadUserFromDatabase(userId)); Now the fallback runs only if Optional is empty. ⚠️ When orElse() is fine orElse() is still okay when the fallback is trivial: String name = maybeName.orElse("unknown"); Constant value, already computed value, or something very cheap. 🧠 Takeaway orElse() is not lazy. If you pass a method call there, that method may execute even when the value is already present. That is exactly the kind of tiny thing that later turns into: "Why is the DB getting hit so much?" 🤦 Have you ever seen a small Java convenience API cause a very non-convenient production problem? 👀 #java #springboot #performance #backend #softwareengineering #programming #coding
To view or add a comment, sign in
-
-
🚨 Multithreading is not about making your code faster. It’s about not breaking your system under load. After years of building backend systems, one thing is clear: 👉 Most multithreading issues don’t appear in development 👉 They explode in production 💡 The biggest misconception: “More threads = more performance” Not always. Sometimes it means: ❌ Race conditions ❌ Deadlocks ❌ Thread starvation ❌ Unpredictable bugs 🔹 What actually matters? 👉 Thread safety Can multiple threads access safely? 👉 Shared state management Avoid it, or control it properly 👉 Right abstractions Use ExecutorService, not raw threads 👉 Understanding locks synchronized vs ReentrantLock — know when to use what 🔹 Real-world example 👇 Two threads updating the same balance: Thread A → reads 100 Thread B → reads 100 A writes 120 B writes 130 👉 Final value = 130 (wrong) That’s not a code bug. That’s a concurrency problem. 💡 What experienced engineers do differently: 👉 Minimize shared state 👉 Prefer immutability 👉 Use concurrent collections 👉 Think about failure, not just success 👉 Multithreading is powerful 👉 But only when you understand the risks Most developers learn syntax. Few understand behavior under concurrency. That’s the real difference. Want to go deeper into Java & System Design? 👉 https://lnkd.in/gjQhR3_Y Follow for more on AI, Java & System Design 🚀 #Java #Multithreading #Concurrency #BackendDevelopment #SoftwareEngineering #SystemDesign #Developers #Tech
To view or add a comment, sign in
-
-
Most backend bugs in production aren't caused by bad code. They arise from assumptions that were never questioned during development. Common assumptions include: - "This API will always return data." - "The network will always be stable." - "No one will hit this endpoint 1000 times a minute." Defensive programming isn't pessimism; it's simply experience wearing a helmet. #BackendDevelopment #SoftwareEngineering #Java #LessonsLearned
To view or add a comment, sign in
-
Most developers think @Autowired is just dependency injection. It's not ❌ It's Reflection + Proxies + Runtime Wiring. Which means : ⭕ Dependencies are injected at runtime (not compile time) ⭕ You might be calling a proxy, not your actual class ⭕ Field injection hides dependencies and hurts testability ⭕ Startup time increases as your app grows The biggest surprise : 👉 this.method() can bypass Spring logic completely (broken @Transactional) Lesson : "Convenience annotations often hide real complexity." Do you still use Field Injection in production ? #SpringBoot #Java #BackendEngineering #SoftwareArchitecture
To view or add a comment, sign in
-
🔍 What does @ComponentScan do in Spring? Manually registering beans? Not anymore. With @ComponentScan, Spring automatically: ✅ Scans your packages ✅ Detects components (@Service, @Repository, @Controller, etc.) ✅ Registers them as beans 💡 It’s the backbone of Dependency Injection in Spring applications. ⚠️ Tip: If your classes are outside the scan path, Spring won’t find them! Understanding this = cleaner, scalable architecture 🚀 #SpringBoot #Java #BackendDevelopment #SoftwareEngineering #Microservices #Developers
To view or add a comment, sign in
-
-
Day 7/60 – Backend Development Journey (Multithreading & Synchronization) Today I worked on Java Multithreading and understood how concurrent execution works along with synchronization. What I built Task 1: Parallel Execution: Created two threads to print numbers: • Thread 1 → prints 1 to 5 • Thread 2 → prints 6 to 10 Both run simultaneously using Runnable Task 2: Shared Counter with Synchronization: • Two threads increment a shared counter • Ensured correct final value using locking mechanism Key Concepts Applied 1. Multithreading Running multiple threads in parallel to improve performance. Example 1: • Thread A → handles API requests • Thread B → processes background tasks Example 2: • Thread 1 → file download • Thread 2 → UI updates 2. Race Condition Multiple threads accessing shared data can cause incorrect results. Example 1: • Two threads incrementing the same variable → wrong count Example 2: • Bank balance updates → inconsistent values 3. Synchronization & Locking • Used ReentrantLock to ensure only one thread updates the counter at a time. 4. Thread Coordination • Used join() to wait for threads to finish before printing result. #Java #Multithreading #Concurrency #Threading #Synchronization
To view or add a comment, sign in
-
-
🚀 What happens inside Spring Framework when your application starts? From bootstrapping to dependency injection, here’s a complete step-by-step flow of how Spring works internally. Understanding this flow helps developers write better and optimized applications. #Java #SpringBoot #BackendDevelopment #SoftwareEngineering
To view or add a comment, sign in
-
-
🔍 Debugging is not guessing. Junior approach: 👉 “Check the code” Senior approach: • Check logs • Check metrics • Check dependencies • Check recent changes 💡 Reality: Most bugs aren’t in code. They’re in interactions. Good debugging = narrowing possibilities. #Debugging #Backend #Observability #Java #SoftwareEngineering #Microservices #SystemDesign #Engineering
To view or add a comment, sign in
-
-
Some weeks in tech, you don’t build anything new. You just investigate, monitor, restart, compare logs, ask questions, and slowly narrow down one issue. And honestly? That’s real engineering too. Not every productive week ends with a feature release. Sometimes it ends with better understanding. The more I work in backend systems, the more I realize: Building is exciting. Debugging builds experience. #BackendEngineering #Learning #Java
To view or add a comment, sign in
-
Spring Boot Circular Dependency — Dangerous issue ⚠️ Example: Service A → depends on Service B Service B → depends on Service A 👉 Boom 💥 Circular dependency error 💡 Why it happens: Poor design & tight coupling Solutions 👇 ✅ Refactor logic ✅ Use constructor injection properly ✅ Introduce third service ✅ Use @Lazy (temporary fix) ⚠️ Avoid: Field injection (hard to debug) 👉 Best practice: Use constructor injection ALWAYS Clean architecture prevents these issues 🔥 #SpringBoot #Java #CleanCode
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
🚀 Navigation for this Series: ⏭️ Next up:https://www.garudax.id/posts/tharun-kumar-cheripally-aba722253_springboot-java-backenddevelopment-activity-7455137280492736512-WPTT? 🌟 Catch up on the first post: here:https://www.garudax.id/posts/tharun-kumar-cheripally-aba722253_springboot-java-backenddevelopment-share-7455130246393012224-CHJE