🚀 **Java Fact of the Day:** You can scale servers with lightweight threads. Virtual threads make this possible! Virtual threads (Project Loom) are extremely lightweight, allowing you to write simple, synchronous code that runs with massive concurrency. They reduce the burden of traditional thread pools and make high I/O wait times much more efficient. **Real-world use case:** A REST API using virtual threads can handle tens of thousands of concurrent requests with straightforward code instead of a complex reactive setup. The code stays readable while the runtime handles scheduling efficiently. Have you tried virtual threads in your projects? What challenges did you face? #Java #ProjectLoom #Concurrency #JavaPerformance #JavaTips
How Virtual Threads Improve Java Concurrency
More Relevant Posts
-
⚡ Java 21 Virtual Threads in real APIs Swapped a blocking fan-out (DB + 2 downstream calls) to virtual threads—same code style, way more concurrency, fewer timeouts. Why it works: I/O-heavy workloads, simpler thread management, smoother bursts. Tip: keep timeouts/back-pressure; CPU-bound stays on platform threads. #Java #Java21 #VirtualThreads #SpringBoot #Performance #Concurrency 🚀
To view or add a comment, sign in
-
🧠 Thread vs ThreadPool — The Hidden Performance Difference Ever created a new thread for every task? It works… until it doesn’t. 🧵 Threads Each thread = its own memory Creating hundreds can kill performance. ✅ Fine for simple, one-off tasks ❌ Not scalable for high-load systems 🏊♂️ ThreadPool (ExecutorService) Instead of creating new threads, it reuses a pool of them. Tasks queue up, and free threads pick them up. ✅ Efficient, scalable, and avoids resource exhaustion 💡 Example: ExecutorService pool = Executors.newFixedThreadPool(10); pool.submit(() -> doWork()); ⚙️ The magic: Spring Boot, Tomcat, and even modern async frameworks use thread pools internally to handle concurrent requests efficiently. 💬 What’s your go-to strategy for managing concurrency? #Java #SpringBoot #Concurrency #Multithreading #SystemDesign #BackendDevelopment #PerformanceEngineering
To view or add a comment, sign in
-
Just published a deep-dive on Java Memory Management , the guide I wish I had years ago. In the article, I break down: ➡️ Heap vs Native memory ➡️Thread stack sizing ➡️GC tuning (HotSpot & OpenJ9) ➡️Metaspace, class caches & direct memory ➡️Tomcat thread pool tuning ➡️Monitoring with Prometheus ➡️Real-world OOM troubleshooting Whether you run Tomcat, Spring Boot, or any JVM-based service, this is the definitive guide to avoiding hidden memory traps. Read it here: https://lnkd.in/dfDUkHs3 #Java #JVM #OpenJDK #OpenJ9 #Tomcat #SRE #Performance #DevOps #BackendEngineering
To view or add a comment, sign in
-
🧠 Traditional Threads vs Virtual Threads - Java 21 (JEP 444, Project Loom) 🍁 What Are They? Virtual Threads are lightweight, JVM-managed threads that let your app handle tens of thousands of concurrent tasks — without the overhead of OS threads. 🧵 Before Java 21: Platform Threads - Each thread = 1 OS thread → heavy, limited by system resources. - Blocking calls waste memory and CPU. - It creates bottlenecks, high context-switching cost, and complex async workarounds. ⚡ Now in Virtual Threads - Each thread = lightweight task managed by the JVM. - Blocking is no longer a problem — threads park instead of blocking OS resources. 💡 Why It Matters - Massive scalability — 100k+ concurrent requests with ease - No code rewrites — works with existing APIs (Thread, ExecutorService, etc.) - Ideal for I/O-bound apps — servers, microservices, DB access #Java21 #VirtualThreads #ProjectLoom #Concurrency #BackendDevelopment #SpringBoot #JavaDeveloper
To view or add a comment, sign in
-
-
Virtual Threads → 10x simpler concurrency for I/O-heavy apps Swapped a fixed thread pool for virtual threads today and removed a ton of complexity (and queue backlogs) in an API service. Same logic, cleaner code, far better throughput. // Java 21 try (var exec = Executors.newVirtualThreadPerTaskExecutor()) { urls.forEach(u -> exec.submit(() -> httpClient.send(u))); } // CPU-bound? keep platform threads. I/O-bound? virtual threads shine. Why it worked for us Each request gets its own lightweight thread → no blocking penalties. No hand-rolled async plumbing or callback hell. Backpressure is simpler: rate-limit at the edges, let virtual threads park cheaply. Quick checklist before you flip the switch ✅ I/O-bound workloads (DB calls, HTTP, messaging) ✅ JDBC driver & HTTP client play nicely with blocking semantics ✅ Sensible limits (connection pools, timeouts, retry policy) Results Lower p95 latency, fewer timeouts under peak, and simpler code to maintain. #Java21 #VirtualThreads #Loom #SpringBoot #Performance #CleanCode
To view or add a comment, sign in
-
👋 Hi Everyone, Today, I explored one of the powerful features of Spring Boot — Interceptors. They allow us to perform actions before and after a request is handled by a controller, making them ideal for logging, authentication, or performance monitoring. 💡 Concept Covered: Created a custom LoggingInterceptor to log incoming requests. Configured it using InterceptorConfig to apply globally across endpoints. Understood the methods: preHandle() → Executes before controller logic postHandle() → Executes after controller logic but before the view afterCompletion() → Executes after the request is fully completed 🧠 This helped me understand how to handle cross-cutting concerns cleanly within a Spring Boot application. 👉 Check out the interceptor implementation here: https://lnkd.in/gBxe8UiZ 📌 That’s all for today’s post. Stay tuned for the next topic in the Spring Boot series! 🚀 #SpringBoot #Interceptor #Java #SpringMVC #GitHub #SpringBootSeries #Learning #BackendDevelopment
To view or add a comment, sign in
-
While working on a Spring Boot project, I explored the important concept of HTTP Connection Pooling. HTTP Connection Pooling is used to manage and reuse HTTP connections efficiently. Here’s how it works:- 1. When an application needs to make an HTTP request, it first checks the connection pool. 2. If an existing connection is available for the same host and port, it’s retrieved from the pool and reused. 3. The application uses this connection to send the request and receive the response. 4. Instead of closing the connection afterwards, it’s returned to the pool in an idle state and ready for reuse by upcoming requests. 5. If no suitable connection exists, a new one is created and added to the pool for future use. So, why is pooling required? Because creating a new connection for every single request is time-consuming. Also, Connection pooling avoids this overhead, resulting in faster and more efficient communication between microservices. In the code below, Connection Manager manages and reuses HTTP connections. The maximum total open connections is 100, with a maximum of 100 connections per specific host. It closes unused connections after 30 seconds, waits up to 10 seconds to get a connection from the pool, 10 seconds to establish a new connection if needed, and 15 seconds to wait for the server response. #Java #SpringBoot #Microservices #ConnectionPooling #JavaDeveloper
To view or add a comment, sign in
-
-
I spent this weekend migrating my #vscode shortcuts and vim bindings to #intelliJ just to get cross-language navigation working. The Language Server Protocol doesn't provide a mechanism for language servers to communicate with each other, so in mixed-language codebases like Kafka (Java/Scala), go-to-definition fails across language boundaries while intellij's unified engine handles this with no issue. Microsoft - #LSP needs to define how clients should handle cross-language navigation between language servers
To view or add a comment, sign in
-
Java 21: the 5-minute change that boosted our throughput by 27%. We swapped a blocking REST endpoint to use virtual threads in Spring Boot. Same code, better scalability under load. What changed Tomcat thread pool stayed small, but each request got its own virtual thread DB calls still block—but now they don’t burn platform threads Tail latency dropped because queues stopped growing How to try ? Use JDK 21 Add spring.threads.virtual.enabled=true (Spring Boot 3.2+) Keep your blocking JDBC; measure before/after Results (our case) +27% throughput @ p95 ≤ previous p95 Fewer timeouts during peak hour Not a silver bullet—watch JDBC pool, DB CPU, and backpressure. Have you rolled virtual threads to prod yet? What did you see? #Java21 #SpringBoot #Performance #Microservices #Engineering
To view or add a comment, sign in
-
Why Multithreading Matters in Microservices 1. Better Throughput A single service often handles thousands of requests per minute. Multithreading allows parallel processing → higher throughput → faster responses. 2. Non-blocking I/O Modern frameworks (Spring WebFlux, Quarkus, Vert.x) use event loops + multithreading to handle massive concurrency with fewer threads. 3. Decoupled Services, Parallel Workflows A request in one service may involve: DB calls REST calls to 2–3 other services Cache lookups Running these in parallel can reduce latency by 40–70%. 4. Efficient CPU Utilization Microservices are often containerized and deployed in clusters. Multithreading ensures the CPU shares assigned to a pod/container are fully utilized. #microservices #java #springboot #multithreading #backenddevelopment #concurrency #softwareengineering #programming
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