Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring first request very slow

I have application in Spring Boot. After initialization of Spring Boot with embeded tomcat, the first response is very slow. How can I fix it? Has spring boot any warmup command/mode? I am thinking too about connection with database and I am wondering about connection database, probably spring connects with Postgres during first request.

like image 753
Matrix12 Avatar asked Jun 22 '26 11:06

Matrix12


1 Answers

You could either use ApplicationRunner or CommandlineRunner to run something on startup:

https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-command-line-runner

like image 139
Simon Martinelli Avatar answered Jun 24 '26 01:06

Simon Martinelli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!