<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/improving-first-request-latency-in-java-spring-application-ngw8nzoq2" -->

---
title: Improving First Request Latency in Java Spring Application
description: An investigation into why a Java Spring Boot financial ledger service showed first-request latency more than double subsequent requests. Testing Java 26's new...
canonical: https://daily.dev/posts/improving-first-request-latency-in-java-spring-application-ngw8nzoq2
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Improving First Request Latency in Java Spring Application | daily.dev
og:description: An investigation into why a Java Spring Boot financial ledger service showed first-request latency more than double subsequent requests. Testing Java 26's new...
og:url: https://daily.dev/posts/improving-first-request-latency-in-java-spring-application-ngw8nzoq2
og:image: https://api.daily.dev/og/posts/nGw8nZOq2.png
og:image:alt: Improving First Request Latency in Java Spring Application
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Improving First Request Latency in Java Spring Application

**[Awesome Java Newsletter](https://daily.dev/sources/java_libhunt)** · 4 min read · 26 upvotes · 0 comments

## Summary

An investigation into why a Java Spring Boot financial ledger service showed first-request latency more than double subsequent requests. Testing Java 26's new Ahead-of-Time (AOT) features (class loading/linking, method profiling, object caching) against baseline G1 and ZGC garbage collectors showed consistent but modest 22-27% median latency improvements. The real breakthrough came from diagnosing that Spring Boot's fat-jar custom class loader forces expensive class lookups (via loadClass failing then falling back to findClass) for classes like Jackson and Hibernate on the first request. Bypassing the fat jar and launching via the real main class dropped first-request latency by ~82%, from 467.52ms to 85.37ms, while subsequent requests stayed steady at 8-9ms regardless of configuration.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://adrian.md/2026/09/03/first-request-latency>

## Questions this post answers

### Why is the first HTTP request to my Spring Boot fat jar so much slower than subsequent requests?

Spring Boot's fat jar uses a custom class loader so the app can run via java -jar, since the JVM cannot natively load classes from nested jars. That loader's loadClass call delegates to the JDK, which fails to find nested-jar classes, throws ClassNotFoundException, and only then falls back to a findClass method that actually locates them. Classes like Jackson and Hibernate get loaded this way on the first request, adding significant latency (measured at 433.58 ms first request vs 10.40 ms subsequent).

_Developers chasing cold-start latency in Spring Boot services can track fixes like this on daily.dev._

### How much does Java 26's AOT cache with any GC improve first request latency for a Spring Boot app?

Java 26's AOT cache (JEP 516, Ahead-of-Time Object Caching with Any GC) gave roughly 22-27% better median latency compared to no cache. With G1 garbage collector median latency dropped from 467.52 ms to 342.53 ms, and with ZGC it dropped from 501.80 ms to 392.19 ms across benchmark runs on the Spring Pet Clinic REST application.

_Teams evaluating JVM AOT features for Java 26 can follow benchmarks like this on daily.dev._

### How do I fix Spring Boot cold-start latency caused by the fat jar class loader?

Bypass the fat jar and launch the application through its real main class instead of java -jar, a documented approach in Spring's own Docker guide. Doing so dropped first-request latency from 467.52 ms (fat jar baseline) to 85.37 ms, an approximately 82% reduction, while subsequent request latency stayed steady at 8-9 ms in either configuration.

_Engineers tuning Spring Boot cold starts can find practical fixes like this on daily.dev._

## Similar posts on daily.dev

- [How is Leyden improving Java Performance? Part 2 of](https://daily.dev/posts/how-is-leyden-improving-java-performance-part-2-of-k95xs5i7z) · Foojay.io · 1 upvotes · 0 comments
- [Speed up Java Startup with Spring Boot and Project Leyden](https://daily.dev/posts/speed-up-java-startup-with-spring-boot-and-project-leyden-14bdnocfp) · Piotr Minkowski TechBlog · 13 upvotes · 1 comments
- [Run Into the New Year with Java’s Ahead-of-Time Cache Optimizations – Inside.java](https://daily.dev/posts/run-into-the-new-year-with-java-s-ahead-of-time-cache-optimizations-inside-java-75zsl41gf) · Inside Java · 1 upvotes · 0 comments
- [A Guide to Ahead-of-Time Cache in the Java](https://daily.dev/posts/a-guide-to-ahead-of-time-cache-in-the-java-xfptxkmvl) · Baeldung · 3 upvotes · 0 comments

---

Tags: [#performance](https://daily.dev/tags/performance), [#java](https://daily.dev/tags/java), [#spring-boot](https://daily.dev/tags/spring-boot), [#jvm](https://daily.dev/tags/jvm)

[View this post on daily.dev](https://daily.dev/posts/improving-first-request-latency-in-java-spring-application-ngw8nzoq2)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Improving First Request Latency in Java Spring Application","url":"https://daily.dev/posts/improving-first-request-latency-in-java-spring-application-ngw8nzoq2","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/improving-first-request-latency-in-java-spring-application-ngw8nzoq2"},"datePublished":"2026-09-10T20:58:11.372Z","dateModified":"2026-10-15T02:22:11.216Z","description":"An investigation into why a Java Spring Boot financial ledger service showed first-request latency more than double subsequent requests. Testing Java 26's new...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/99991a1858f72c483d6a34a1adeadca3?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/99991a1858f72c483d6a34a1adeadca3?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Awesome Java Newsletter","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Awesome Java Newsletter","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/7729929f2ca649d7b13f6b04aa94d300","url":"https://daily.dev/sources/java_libhunt"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/improving-first-request-latency-in-java-spring-application-ngw8nzoq2","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":26},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"performance,java,spring-boot,jvm","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Awesome Java Newsletter","item":"https://daily.dev/sources/java_libhunt"},{"@type":"ListItem","position":3,"name":"Improving First Request Latency in Java Spring Application"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/improving-first-request-latency-in-java-spring-application-ngw8nzoq2#faq","mainEntity":[{"@type":"Question","name":"Why is the first HTTP request to my Spring Boot fat jar so much slower than subsequent requests?","acceptedAnswer":{"@type":"Answer","text":"Spring Boot's fat jar uses a custom class loader so the app can run via java -jar, since the JVM cannot natively load classes from nested jars. That loader's loadClass call delegates to the JDK, which fails to find nested-jar classes, throws ClassNotFoundException, and only then falls back to a findClass method that actually locates them. Classes like Jackson and Hibernate get loaded this way on the first request, adding significant latency (measured at 433.58 ms first request vs 10.40 ms subsequent). Developers chasing cold-start latency in Spring Boot services can track fixes like this on daily.dev."}},{"@type":"Question","name":"How much does Java 26's AOT cache with any GC improve first request latency for a Spring Boot app?","acceptedAnswer":{"@type":"Answer","text":"Java 26's AOT cache (JEP 516, Ahead-of-Time Object Caching with Any GC) gave roughly 22-27% better median latency compared to no cache. With G1 garbage collector median latency dropped from 467.52 ms to 342.53 ms, and with ZGC it dropped from 501.80 ms to 392.19 ms across benchmark runs on the Spring Pet Clinic REST application. Teams evaluating JVM AOT features for Java 26 can follow benchmarks like this on daily.dev."}},{"@type":"Question","name":"How do I fix Spring Boot cold-start latency caused by the fat jar class loader?","acceptedAnswer":{"@type":"Answer","text":"Bypass the fat jar and launch the application through its real main class instead of java -jar, a documented approach in Spring's own Docker guide. Doing so dropped first-request latency from 467.52 ms (fat jar baseline) to 85.37 ms, an approximately 82% reduction, while subsequent request latency stayed steady at 8-9 ms in either configuration. Engineers tuning Spring Boot cold starts can find practical fixes like this on daily.dev."}}]}
```

