<p>Looking for recommendations on improving Spring Boot startup speeds on Kubernetes. We're running a REST API built on Spring Boot on a relatively low amount of resources (obviously I'm aware I can throw more compute at the problem, but I want to optimise other aspects first).</p>
<p>One of the major sticking points is the fact that dispatcherServlet only initialises after the first HTTP request is received. Can this be started up before this.</p>
<p>Additionally, how can I eagerly establish the connection to our JPA Datasource (in this circumstance, a MySQL server)</p>
<p>Lastly, we use JobRunr as a background job processor. Can this be abstracted to a different container within the pod, or a different pod altogether?</p>
<p>This is our Dockerfile:</p>
<pre><code>FROM alpine
RUN apk update
RUN apk upgrade --available
RUN apk --no-cache add openjdk17-jre-headless
RUN mkdir /opt/app
COPY target/app.jar /opt/app
CMD [&quot;java&quot;, &quot;-Xmx400m&quot;, &quot;-jar&quot;, &quot;/opt/app/app.jar&quot;]
</code></pre>
<p>Tips/Tricks/Suggestions welcomed.</p>

Flinty926
<p>Refer to, [Spring Boot Common Properties] <a href="https://docs.spring.io/spring-boot/docs/current/reference/html/application-properties.html#appendix.application-properties.web%5D" rel="nofollow noreferrer">https://docs.spring.io/spring-boot/docs/current/reference/html/application-properties.html#appendix.application-properties.web]</a></p>
<p>spring.mvc.servlet.load-on-startup = 1</p>
