⚙️ Blocking Requests to Real-Time Async Uploads: Built a Production-Ready File Upload System In a recent project, I came across a complex challenge for our analytics platform: how to handle high-volume, concurrent file uploads while providing live, user-facing progress tracking and maintaining data enrichment. The Challenge: The initial sync endpoint blocked for ~20 seconds during S3 uploads and providing status update, freezing the UI and introducing data corruption risks with concurrent users due to unsynchronized HashMap writes. Traditional HashMap can return incorrect values/statuses or provide nulls when multiple threads try to perform read/write operations which gives incorrect updates to endpoints.Worse, Tomcat was deleting temp files before async tasks could process them, causing unexplained failures. My Solution Approach: - Enabled async processing in Spring Boot via @Async + custom ThreadPoolTaskExecutor, letting uploads run in the background and API responses return instantly. - Built live status tracking: Used Angular’s RxJS polling (100ms intervals) with switchMap/takeWhile, so users saw every step—“Queued” → “Validating” → “Uploading” → “Completed”—in real time. - Concurrent status management: Adopted ConcurrentHashMap (new ConcurrentHashMap<>(32, 0.75f, 8)) for safe, lock-free concurrent reads and up to 8 parallel writes, eliminating race conditions, lost updates, and ConcurrentModificationException. - File integrity for async: Converted MultipartFile to byte arrays in-controller before async handling, solving the Tomcat temp file deletion problem once and for all. - Fine-grained error handling: Added detailed error tracking & logging for every validation and upload stage, funneling meaningful messages to user-facing modals. Key Technical Wins: - Robust to spikes in concurrent uploads (8-user uploads stress tested) - No blocking or thread starvation; backend always responsive - Data integrity and system stability under all concurrency levels - Clean, production-grade error management and user feedback loop Tech stack: Spring Boot | Angular | AWS S3 | Java Concurrency | RxJS Takeaway: Deep understanding of Java concurrency—knowing when to employ ConcurrentHashMap and async design—let me build a solution that's both performant and bulletproof. #SpringBoot #AsyncProgramming #Java #Angular #AWS #SoftwareEngineering #BackendDevelopment #Concurrency #SystemDesign
Solved High-Volume File Uploads with Async Processing and ConcurrentHashMap
More Relevant Posts
-
🌐 Day 14 — Dynamic URLs, Path Variables & Query Parameters in Spring Boot Continuing my 100 Days of Java Backend, Spring Boot & AI Integration journey 🚀 Today, I explored how to make APIs dynamic and flexible using Path Variables, Query Parameters, and Request Headers in Spring Boot. Even though I already knew these concepts, revisiting them gave me a deeper understanding of how real-world APIs handle client input dynamically 💡 ------------------------------------------------------------------------------- 💡 What I Learned 🔗 Dynamic URLs with Path Variables (@PathVariable) Learned how to capture data directly from the URL — for example, /users/{id} — and map it to method parameters in the controller. 🔍 Query Parameters using @RequestParam Explored how to filter, sort, and search data using parameters like /products?category=electronics&price=500. 🧩 Handling Multiple Query Parameters Understood how Spring automatically binds multiple query parameters and how to make some of them optional. 📬 Using @RequestHeader Annotation Learned how to extract information from HTTP headers, such as authentication tokens or client metadata. ⚙️ Combining All — PathVariable + RequestParam + RequestHeader Built APIs that use all three together, simulating real-world backend operations where client, server, and request metadata all interact. ------------------------------------------------------------------------------- This day reinforced how Spring Boot empowers developers to design robust and interactive APIs that adapt to real-world use cases 💪 Next, I’ll dive deeper into database connectivity and JPA integration — where APIs meet persistent data 🔗 #100DaysOfJavaBackend #Day14 #SpringBoot #RESTAPI #JavaDeveloper #PathVariable #RequestParam #RequestHeader #BackendDevelopment #LearningJourney #SpringFramework #SoftwareEngineering #CleanCode #AIDeveloper
To view or add a comment, sign in
-
🚀 Virtual Threads in Java – The Most Underused Superpower in Modern Concurrency 🧵 We’ve all battled with scaling backend services — thread pools exhausted, reactive frameworks adding complexity, and debugging async flows turning into nightmares. Then came Project Loom (Java 21) — quietly transforming concurrency with Virtual Threads. 🧩 What Are Virtual Threads? They’re JVM-managed lightweight threads, not tied to OS threads. You can spawn thousands or even millions of them without worrying about memory or blocking calls. Each virtual thread costs ~2KB vs 1MB for a platform thread — a thousand-fold efficiency boost. ⚙️ Where They Shine ✅ I/O-bound workloads (DB calls, REST APIs, file or network I/O) ✅ Microservices handling high request volume ✅ Gateway or aggregation services calling multiple downstream APIs ✅ ETL / crawler systems needing high concurrency ✅ Load testing simulations mimicking thousands of users Example: try (var executor = Executors.newVirtualThreadPerTaskExecutor()) { urls.forEach(url -> executor.submit(() -> crawl(url))); } Readable, blocking-style code — no CompletableFuture chaos, no reactive boilerplate. 🚫 Where Not to Use ❌ CPU-bound work (heavy computation — no gain) ❌ Synchronized blocks or JNI (can cause thread pinning) ❌ ThreadLocal-heavy frameworks (consider ScopedValues instead) ❌ Old JDBC drivers or native libraries You can detect pinning via: -Djdk.tracePinnedThreads=full 🧠 Real-World Example Imagine a microservice that fetches user data and order history: try (var scope = new StructuredTaskScope.ShutdownOnFailure()) { var user = scope.fork(() -> userService.getUserById(1)); var orders = scope.fork(() -> orderService.getOrders(1)); scope.join(); return new UserProfile(user.resultNow(), orders.resultNow()); } Simple, structured, and scalable — each call runs in its own virtual thread, but the JVM parks them efficiently when blocked. 🔍 The Takeaway Virtual Threads don’t replace parallelism — they make concurrency practical again. #Java #VirtualThreads #Java21 #Concurrency #SoftwareEngineering #BackendDevelopment #Microservices #PerformanceEngineering #Scalability #SystemDesign #Developers #EngineeringExcellence
To view or add a comment, sign in
-
#java 🟩 Day 57 – Logging + Monitoring with ELK Stack + Prometheus + Grafana (HinEnglish, Step-by-Step, #Tech57) आज का लक्ष्य: Apne system ko andar se dekhna — logs aur metrics ke zariye har heartbeat track karna --- 🔹 Step 1: What is Logging vs Monitoring? HinEnglish: - Logging: Application ke events ko record karna (e.g., errors, requests, DB queries) - Monitoring: System ke health metrics ko track karna (e.g., CPU, memory, response time) 🧠 Real-world analogy: > Logging = CCTV footage > Monitoring = Heart rate monitor --- 🔹 Step 2: ELK Stack for Centralized Logging ✅ Elasticsearch: Stores and indexes logs ✅ Logstash: Parses and ships logs ✅ Kibana: Visualizes logs in dashboards 🧱 Spring Boot Integration: - Use logback-spring.xml to format logs - Send logs to Logstash via TCP/UDP - Use JSON format for structured logging --- 🔹 Step 3: Prometheus + Grafana for Monitoring ✅ Prometheus: Pulls metrics from apps ✅ Grafana: Visualizes metrics in real-time ✅ Micrometer: Bridge between Spring Boot and Prometheus 🧠 Example: `yaml management: endpoints: web: exposure: include: "*" metrics: export: prometheus: enabled: true ` --- 🔹 Step 4: Java Full Stack Integration ✅ Spring Boot: Expose /actuator/metrics ✅ React: Track frontend errors with Sentry or custom logger ✅ Docker: Run ELK + Prometheus + Grafana containers ✅ Postman: Simulate load to generate logs/metrics ✅ GitHub: Push config files + dashboards + README ✅ CI/CD: Alert on failed builds or high error rates --- 🔹 Step 5: DSA + Tools Relevance ✅ DSA: Graph = service dependency + alert flow ✅ Tools: - ELK Stack - Prometheus + Grafana - Spring Boot Actuator ✅ Security: Mask sensitive data in logs ✅ Optimization: Use log levels (INFO, DEBUG, ERROR) wisely --- 🔹 Step 6: Interview Questions - Q1: What is the difference between logging and monitoring? - Q2: How does ELK Stack work? - Q3: What is Micrometer in Spring Boot? - Q4: How do you monitor memory and CPU usage? - Q5: How do you handle log rotation and retention? --- 🔹 Step 7: Practice Tasks - ✅ Setup ELK Stack using Docker Compose - ✅ Configure Spring Boot to send logs to Logstash - ✅ Setup Prometheus to scrape metrics - ✅ Create Grafana dashboard for API latency and error rate - ✅ Document logic in Day57_LoggingMonitoring/README.md - ✅ Push code, dashboards, and screenshots to GitHub --- 🎯 प्रेरणा का संदेश: > “A system that speaks is a system that survives. आज आपने apne code ko bolna सिखाया.” #JavaFullStack #Logging #Monitoring #ELKStack #Prometheus #Grafana #SpringBoot #ReactJS #JavaMastery #Tech57 #GitHubShowcase #LinkedInReady #DigitalIndia #NamasteBharat #StructuredLearning #PrintReady #LegacyDriven #OpenToWork #TechHiring #CareerInTech #CodeToInspire #Observability #InterviewPrep
To view or add a comment, sign in
-
🚀 Migrating from Thread Pools to Virtual Threads — Your Practical Checklist (Java 21+) If you’re planning to move your application from traditional executor-based concurrency to Virtual Threads, here’s a clear and actionable migration checklist—without repeating what Virtual Threads are or how they work. This is purely about how to migrate safely and successfully 👇 ⸻ ✅ 1. Modernize Your Platform & Dependencies Before switching to virtual-thread executors: • Upgrade to Java 21 or later • Move to supported framework versions (Spring Boot 3.2+, Tomcat/Jetty latest, Quarkus/Micronaut latest) • Ensure JDBC, HTTP, messaging, and cache drivers handle blocking I/O correctly • Update build tools: Maven 3.9+ / Gradle 8+ ⸻ ✅ 2. Replace Fixed Thread Pools This is the first major code change: Old: Executors.newFixedThreadPool(200) New: Executors.newVirtualThreadPerTaskExecutor() This removes most thread-pool tuning completely. ⸻ ✅ 3. Adopt Structured Concurrency for Multi-Task Operations Instead of juggling Futures or callbacks: try (var scope = new StructuredTaskScope.ShutdownOnFailure()) { var a = scope.fork(() -> callA()); var b = scope.fork(() -> callB()); scope.join(); } Cleaner error handling, cancellation, and orchestration. ⸻ ✅ 4. Replace ThreadLocal with Scoped Values For context propagation, use: ScopedValue.where(USER, "alice").run(...) This avoids ThreadLocal overhead when using thousands of virtual threads. ⸻ ✅ 5. Review Blocking & Native Code Some constructs still block carrier threads: ⚠️ Watch out for: • Long synchronized sections • Native/JNI calls • Legacy drivers using internal locks Refactor or isolate these before adopting virtual threads widely. ⸻ ✅ 6. Tune Your Resource Pools Virtual Threads lift concurrency limits — but backend systems still have limits. Check: • DB connection pool sizing • HTTP client pool limits • Timeouts & retry strategies • Thread-based context assumptions in libraries ⸻ ✅ 7. Load Test Before Full Rollout A must-do step: • High-concurrency load • DB saturation behavior • Carrier thread utilization • Memory footprint under 50k–100k VTs • Compare latency vs old thread pool Roll out with canaries → validate → then expand. ⸻ 🎯 Final Takeaway Migrating to Virtual Threads is not just a code change — it’s an opportunity to simplify your threading model, clean up old async code, and reduce operational complexity. Use this checklist to adopt them safely and confidently.
To view or add a comment, sign in
-
🚀 RestTemplate vs WebClient — Understanding the Differences in the Spring Ecosystem If you’ve worked with Java and REST APIs, you’ve probably used RestTemplate at some point. But with the arrival of Spring WebFlux, WebClient has become the new standard — and for good reasons. 👇 🔹 1️⃣ RestTemplate (Synchronous & Blocking) RestTemplate is the traditional HTTP client in the Spring ecosystem. It performs blocking calls — meaning the thread waits until the response is received. ➡️ Ideal for Spring MVC (Servlet-based) applications ➡️ Simple to use, but doesn’t scale well under heavy load Example: RestTemplate restTemplate = new RestTemplate(); String result = restTemplate.getForObject("https://lnkd.in/de876icn", String.class); 🔹 2️⃣ WebClient (Asynchronous & Non-blocking) With Spring WebFlux, the WebClient came to replace RestTemplate. It’s reactive, non-blocking, and based on the publisher/subscriber model from Project Reactor, providing high scalability and better resource utilization. ➡️ Perfect for reactive systems or high-concurrency environments ➡️ Can be used in both synchronous and asynchronous modes Example: WebClient webClient = WebClient.create("https://api.example.com"); Mono<String> result = webClient.get() .uri("/data") .retrieve() .bodyToMono(String.class); 🔹 Quick Summary FeatureRestTemplateWebClientStyleSynchronous / BlockingAsynchronous / Non-blockingParadigmImperativeReactivePerformanceLimited under loadHighly scalableFramework baseSpring MVCSpring WebFluxFuture⚠️ Deprecated✅ Recommended by the Spring Team 💡 In short: If you’re building new applications or migrating to more scalable architectures, WebClient is the way to go. Even though RestTemplate still works, the Spring Team has marked it as legacy, and it won’t receive new feature updates. ✍️ Have you already migrated your HTTP calls to WebClient? Share your experience or migration challenges in the comments — let’s discuss! 🚀 ☕ 🔖 #Java #SpringBoot #SpringWebFlux #WebClient #RestTemplate #BackendDevelopment #SoftwareEngineering #APIDevelopment #JavaDeveloper #BackendEngineer
To view or add a comment, sign in
-
-
💾 𝑻𝒉𝒆 𝑮𝒓𝒆𝒂𝒕 𝑱𝒂𝒗𝒂 𝑺𝒆𝒓𝒊𝒂𝒍𝒊𝒛𝒂𝒕𝒊𝒐𝒏 𝑴𝒚𝒔𝒕𝒆𝒓𝒚 aka “When your 𝐏𝐎𝐉𝐎 refuse to leave home” 🎬 𝑺𝒄𝒆𝒏𝒆 𝑺𝒆𝒕𝒖𝒑 Friday evening at Office a dev happily sends a User object from one microservice to another. All seems peaceful…until suddenly 🚨 𝐣𝐚𝐯𝐚.𝐢𝐨.𝐍𝐨𝐭𝐒𝐞𝐫𝐢𝐚𝐥𝐢𝐳𝐚𝐛𝐥𝐞𝐄𝐱𝐜𝐞𝐩𝐭𝐢𝐨𝐧: 𝐜𝐨𝐦.𝐦𝐢𝐜𝐫𝐨𝐬𝐨𝐟𝐭.𝐚𝐩𝐩.𝐦𝐨𝐝𝐞𝐥𝐬.𝐔𝐬𝐞𝐫 That’s the moment when coffee stopped helping, and debugging began. ☕💻 🧠 𝑾𝒉𝒂𝒕’𝒔 𝑹𝒆𝒂𝒍𝒍𝒚 𝑮𝒐𝒊𝒏𝒈 𝑶𝒏? #𝐒𝐞𝐫𝐢𝐚𝐥𝐢𝐳𝐚𝐭𝐢𝐨𝐧→ Converting your Java object into bytes so it can travel (across a network, file, or queue). #𝐃𝐞𝐬𝐞𝐫𝐢𝐚𝐥𝐢𝐳𝐚𝐭𝐢𝐨𝐧 → Rebuilding that object from bytes. 𝑰𝒏 𝒔𝒉𝒐𝒓𝒕: Your object: “I’m heading to Azure Service Bus 🌩️” JVM: “Hold on! Where’s your Serializable passport? 🛂” ⚙️ 𝑻𝒉𝒆 𝑪𝒍𝒂𝒔𝒔𝒊𝒄 𝑩𝒖𝒈 class 𝐔𝐬𝐞𝐫{ private String name; private String email; } When this travels across services 💣 Boom NotSerializableException ✅ 𝑻𝒉𝒆 𝑹𝒆𝒔𝒄𝒖𝒆 𝑷𝒍𝒂𝒏 import java.io.Serializable; class User implements Serializable { 𝒑𝒓𝒊𝒗𝒂𝒕𝒆 𝒔𝒕𝒂𝒕𝒊𝒄 𝒇𝒊𝒏𝒂𝒍 𝒍𝒐𝒏𝒈 𝒔𝒆𝒓𝒊𝒂𝒍𝑽𝒆𝒓𝒔𝒊𝒐𝒏𝑼𝑰𝑫 = 1𝑳; private String name; private String email; } Now your POJO can safely journey through REST APIs, Kafka, or message queues like a pro. 🚀 🌿 𝑩𝒐𝒏𝒖𝒔: 𝑺𝒑𝒓𝒊𝒏𝒈𝑩𝒐𝒐𝒕 𝑹𝑬𝑺𝑻 Spring Boot uses Jackson under the hood for automatic 𝐉𝐒𝐎𝐍 (𝒅𝒆)𝒔𝒆𝒓𝒊𝒂𝒍𝒊𝒛𝒂𝒕𝒊𝒐𝒏. @𝐆𝐞𝐭𝐌𝐚𝐩𝐩𝐢𝐧𝐠("/user") public 𝐔𝐬𝐞𝐫 𝐠𝐞𝐭𝐔𝐬𝐞𝐫() { return new 𝐔𝐬𝐞𝐫("abc", "abc@gmail.com"); } 𝑱𝒂𝒄𝒌𝒔𝒐𝒏 𝒉𝒂𝒏𝒅𝒍𝒆𝒔 𝒕𝒉𝒆 𝑱𝑺𝑶𝑵 𝒎𝒂𝒈𝒊𝒄 - 𝑩𝒖𝒕 𝒃𝒆𝒘𝒂𝒓𝒆 𝒐𝒇 𝒇𝒆𝒘 𝒕𝒓𝒂𝒑𝒔 ⚠️ 🔁 Circular references (bidirectional JPA relationships) 🙈 Missing @𝑱𝒔𝒐𝒏𝑰𝒈𝒏𝒐𝒓𝒆 for sensitive data 🔍 Debugging Checklist ✅ Verify if class implements Serializable 🔗 Check nested objects for serialization support 🧩 Ensure 𝒔𝒆𝒓𝒊𝒂𝒍𝑽𝒆𝒓𝒔𝒊𝒐𝒏𝑼𝑰𝑫 is consistent after class changes 📜 Enable 𝒔𝒑𝒓𝒊𝒏𝒈.𝒋𝒂𝒄𝒌𝒔𝒐𝒏.𝒔𝒆𝒓𝒊𝒂𝒍𝒊𝒛𝒂𝒕𝒊𝒐𝒏 logs ⚡ Use @𝑱𝒔𝒐𝒏𝑰𝒈𝒏𝒐𝒓𝒆 smartly to avoid recursion 🧾 𝑩𝒆𝒔𝒕 𝑷𝒓𝒂𝒄𝒕𝒊𝒄𝒆𝒔 𝑺𝒖𝒎𝒎𝒂𝒓𝒚 ☑️ Implement 𝐒𝐞𝐫𝐢𝐚𝐥𝐢𝐳𝐚𝐛𝐥𝐞 for persistent/transmittable objects ☑️ Always include a 𝐬𝐞𝐫𝐢𝐚𝐥𝐕𝐞𝐫𝐬𝐢𝐨𝐧𝐔𝐈𝐃 ☑️ Prefer 𝐃𝐓𝐎𝐬 over Entities in APIs ☑️ Mark confidential fields as 𝐭𝐫𝐚𝐧𝐬𝐢𝐞𝐧𝐭 ☑️ Validate 𝐉𝐒𝐎𝐍 mapping via 𝐎𝐛𝐣𝐞𝐜𝐭𝐌𝐚𝐩𝐩𝐞𝐫 💬 𝑨 𝑸𝒖𝒐𝒕𝒆 𝒇𝒓𝒐𝒎 𝒕𝒉𝒆 𝑫𝒆𝒗 𝑹𝒐𝒐𝒎 “My #𝐏𝐎𝐉𝐎 refused to travel until I gave it a passport turns out that passport was #𝐒𝐞𝐫𝐢𝐚𝐥𝐢𝐳𝐚𝐛𝐥𝐞!” 😂 #JavaDeveloper #BackendDeveloper #FullStackDeveloper #SoftwareEngineering #TechInterview #CodingInterview #InterviewPreparation #TechCareer #ProgrammerLife #ITJobs #SpringBoot #SpringFramework #JavaProgramming #CoreJava #AdvancedJava #Microservices #RESTAPI #SpringSecurity #JavaTips #JavaCommunity #Docker #Kubernetes #Containerization #DevOpsTools #CI_CD #TechInnovation Tushar Desai
To view or add a comment, sign in
-
#DAY62 #100DaysOfCode #JavaFullStackDevelopment Journey Hello LinkedIn family! Day 62 – Hierarchy of Collection Framework in Java Today, I learned about one of the core pillars of Java — the Collection Framework, introduced in Java 1.2 to simplify how data is stored and managed. It provides built-in data structures and algorithms that make handling data efficient, scalable, and clean. It provides ready-to-use data structures and algorithms that help us store, manipulate, and retrieve data efficiently. -->Hierarchy Overview At the top of the framework, we have the Iterable interface, which allows objects to be iterated using the for-each loop. 1️⃣ Iterable (Java 1.2) The root interface for all collection classes. Contains the method iterator() to iterate elements. 2️⃣ Collection (Java 1.2) Extends Iterable. The base interface for all types of collections like List, Set, and Queue. 1️⃣ List Interface (Java 1.2) Represents an ordered collection that allows duplicates. Provides index-based access to elements. ♦️Main Classes: ArrayList: Dynamic array, fast for random access. LinkedList: Doubly linked list, best for insertions/deletions. Vector: Legacy synchronized list. Stack: Extends Vector and follows LIFO order. 2️⃣ Queue Interface (Java 1.5) Maintains FIFO (First-In-First-Out) order. Ideal for processing tasks sequentially. ♦️Main Classes: PriorityQueue: Sorts elements naturally or using a custom comparator. Deque (Java 1.6): Double-ended queue. ArrayDeque: Faster alternative to Stack and LinkedList for stack operations. 3️⃣ Set Interface (Java 1.2) Stores unique elements only. No duplicate entries allowed. ♦️Main Classes: HashSet: Unordered and based on hashing. LinkedHashSet: Maintains insertion order. SortedSet (Java 1.2): Keeps elements sorted. TreeSet: Implements SortedSet; uses a TreeMap internally. 4️⃣ Map Interface (Java 1.2) Stores data in key–value pairs. Does not extend Collection because it handles mappings differently. ♦️Main Classes: HashMap: Unordered and fast; most common. LinkedHashMap: Maintains insertion order. Hashtable: Legacy synchronized version of HashMap. SortedMap (Java 1.2): Keeps keys in sorted order. TreeMap: Implements SortedMap using a red-black tree. -->In Simple Terms List → Ordered & allows duplicates Set → Unique & unordered Queue → FIFO processing Map → Key–value pairs -->Conclusion The Java Collection Framework provides a powerful and unified way to manage data. It helps developers focus more on logic and less on reinventing data structures, offering performance, flexibility, and code reusability. A big thanks to my mentor Gurugubelli Vijaya Kumar Sir and the 10000 Coders institute for constantly guiding me and helping me build a strong foundation in programming concepts. #Java #Day62 #Collections #Programming #LearningJourney #CodeWithMe #Developer
To view or add a comment, sign in
-
-
🚀 𝐇𝐨𝐰 𝐈 𝐑𝐞𝐝𝐮𝐜𝐞𝐝 𝐌𝐲 𝐒𝐩𝐫𝐢𝐧𝐠 𝐁𝐨𝐨𝐭 𝐃𝐨𝐜𝐤𝐞𝐫 𝐈𝐦𝐚𝐠𝐞 𝐒𝐢𝐳𝐞 𝐛𝐲 ~𝟑𝟓𝟎 𝐌𝐁 Recently, I optimized one of my Java Spring Boot Docker images and managed to cut down nearly 350 MB from the final image size. Here’s how I did it 👇 🧱 𝐓𝐡𝐞 𝐏𝐫𝐨𝐛𝐥𝐞𝐦 Most Java base images (like amazoncorretto:17) are JDK-based — full of development-time tools we never need in production: Compiler (javac) Debugger tools Header files Source code Mission Control, javadoc, etc. All these add unnecessary weight and easily bloat the image to 450–500 MB. And after Amazon Corretto 11, AWS stopped publishing standalone JRE images. That means for Java 17+, you’re forced to ship a full JDK even if you only need a runtime. 🔸 Note: Other distributions like Eclipse Temurin (by Adoptium) still provide official JRE builds and Docker images — a great alternative if you want a maintained lightweight runtime base. ⚙️ 𝐓𝐡𝐞 𝐒𝐨𝐥𝐮𝐭𝐢𝐨𝐧 👉 Create a custom JRE image using the JDK itself. 1. Start from Corretto JDK 17 (official image). 2. Use jlink (available since JDK 9) to generate a minimal runtime containing only the modules your app actually needs: jlink \ --module-path $JAVA_HOME/jmods \ --add-modules java.base,java.logging,java.sql,java.xml \ --output /custom-jre \ --strip-debug \ --no-man-pages \ --no-header-files \ --compress=2 3. Use that /custom-jre as your runtime in the final Docker image. 4. Apply a multi-stage Docker build so the JDK and build tools never reach your production layer. 📦 𝐓𝐡𝐞 𝐑𝐞𝐬𝐮𝐥𝐭 Image size dropped from ~600 MB → ~250 MB Faster pull/push in CI/CD pipelines Quicker container startup Smaller attack surface 🔗 𝐁𝐨𝐧𝐮𝐬 𝐓𝐢𝐩 If you want a prebuilt runtime, check out: 👉 pnavato/amazoncorretto-jre (unofficial community image) Or use Eclipse Temurin JRE — it’s an official lightweight option from Adoptium that stays updated and secure. Still, building your own custom JRE gives you full control and ensures nothing extra is shipped to production. #Java #SpringBoot #Docker #DevOps #Microservices #CICD #AmazonCorretto #EclipseTemurin #PerformanceOptimization #CloudEngineering
To view or add a comment, sign in
-
-
#java day11 questions 🟦 Day 11 – Spring Boot & REST API: Interview & Practice Questions (English, #Tech11) Build scalable, production-ready backend services with ease --- 🔹 Spring Boot Fundamentals - What is Spring Boot and how is it different from Spring Framework? - What are starter dependencies in Spring Boot? - What is the role of @SpringBootApplication annotation? - How does Spring Boot simplify configuration? --- 🔹 REST API Basics - What is a RESTful API? - What are the main HTTP methods used in REST? - What is the difference between GET, POST, PUT, DELETE? - What is the role of @RestController and @RequestMapping? --- 🔹 Annotations & Routing - What is the use of @GetMapping, @PostMapping, etc.? - How do you pass path variables and query parameters? - What is the difference between @PathVariable and @RequestParam? - How do you handle request and response bodies? --- 🔹 Data Handling - How do you connect Spring Boot to a database? - What is Spring Data JPA? - What is the role of @Entity, @Repository, and @Service? - How do you perform CRUD operations using JPA? --- 🔹 Error Handling & Validation - How do you handle exceptions in REST APIs? - What is the use of @ExceptionHandler? - How do you validate request data using @Valid and @NotNull? --- 🔹 Best Practices - What are REST API naming conventions? - What is idempotency and why is it important? - How do you version REST APIs? --- 🔹 Practice Tasks - ✅ Create a Spring Boot project with REST endpoints - ✅ Build a StudentController with CRUD operations - ✅ Connect to H2 or MySQL database using Spring Data JPA - ✅ Use @GetMapping and @PostMapping with parameters - ✅ Implement exception handling for invalid input - ✅ Validate incoming data using annotations Technology #Innovation #IT #Tech #SoftwareDevelopment #Programming #AI #CloudComputing #DevOps #Cybersecurity #Java #SpringBoot #Microservices #BackendDevelopment #FullStack #ReactJS #JavaScript #TypeScript #Docker #Kubernetes #AWS #Cloud #DataScience #MachineLearning #WebDevelopment #Coding #CodeNewbie #Developer #SoftwareEngineer #TechJobs #CareerInTech #DigitalTransformation #CloudNative #SystemDesign #DataStructures #Algorithms #OpenToWork #TechHiring #JobSearch #ITJobs #Google #Microsoft #Amazon #Meta #Apple #Netflix #Uber #Airbnb #LinkedIn #Adobe #Salesforce #Oracle #SAP #IBM #Intel #Cisco #VMware #PayPal #Stripe #Twitter #Spotify #Tesla #NVIDIA #Accenture #TCS #Infosys #Wipro #Cognizant #Capgemini #TechMahindra #HCL #Dell #HP #Samsung #Sony #Qualcomm #Broadcom #ServiceNow #Workday #Slack #Zoom #Atlassian #Snowflake #Databricks #MongoDB #Elastic #GitHub #GitLab `
To view or add a comment, sign in
-
💡 Why Does Java Still Use Primitive Data Types in 2025? With all the progress in Java — from records and sealed classes to virtual threads — you might wonder: 👉 Why does Java still have int, double, boolean, etc., instead of just using objects like Integer or Double everywhere? Let’s break it down 👇 ⚙️ 1️⃣ Performance at the Core Primitives are stored directly on the stack (or in registers), not as heap objects. That means: No object allocation overhead No garbage collection pressure Faster CPU-level access 📘 Example: int sum = 0; for (int i = 0; i < 1_000_000; i++) { sum += i; } This loop runs orders of magnitude faster than using Integer sum = 0; because the latter constantly creates and boxes new Integer objects. 🧠 2️⃣ Memory Efficiency Every object in Java has header metadata (usually 12–16 bytes). With primitives, there’s no per-value overhead — crucial when handling large data arrays. int[] numbers = new int[1_000_000]; // ~4 MB Integer[] numbersObj = new Integer[1_000_000]; // ~16 MB+ due to object headers That’s a 4x+ difference in memory use — and it matters in high-performance systems. 🔄 3️⃣ Simplicity in Low-Level Computation Primitives give direct control over arithmetic and bitwise operations without abstraction layers. This is essential for: Numeric computations Game engines High-frequency trading systems Data processing pipelines 🚀 4️⃣ But What About “Everything is an Object”? Java’s design balances OO principles with practical performance. Yes, Integer, Double, and Boolean exist — but they’re wrappers, not replacements. You can use them when you need features like null handling, generics, or collections. 🔬 5️⃣ Project Valhalla (Coming Soon) Java’s future (Project Valhalla) aims to introduce value types — combining the performance of primitives with the flexibility of objects. That might finally bridge this gap. But until then, primitives remain the foundation of Java performance. 🏁 In short: Java keeps primitives because they’re fast, memory-efficient, and predictable — all vital for scalable, low-latency systems. Object wrappers add flexibility — but primitives keep Java grounded in performance reality. 💬 What’s your take — should Java eventually unify primitives and objects, or keep them separate for clarity and performance? #Java #Performance #Programming #SoftwareEngineering #JVM #Javadeveloper
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