Can a Spring Boot application make HTTP request to itself?

2/21/2020

We are deploying Spring Boot app to the Kubernetes. When the firs user requests comes it takes more than 10s to response. Subsequent requests take 200ms. I have created a warmup procedure to run the key services in @PostConstruct. I reduces the time to process the first query to 4s. So I wanted to simulate this first call. I know that Kubernetes rediness probe can make a POST request, but I need authorization and other things. Can I make a real HTTP call to the controller from the app itself?

-- Damian
java
kubernetes
spring-boot

2 Answers

2/21/2020

try RestTemplate , you can consume any web service

-- Coma
Source: StackOverflow

2/21/2020

Sure, you can always make an HTTP client to localhost

The solution isnt specific to k8s or Spring or Java, but any web server

You could also try making your readiness probe just the tcp port or some internal script

-- OneCricketeer
Source: StackOverflow