Damian
Damian

Reputation: 3050

Can a Spring Boot application make HTTP request to itself?

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?

Upvotes: 1

Views: 2815

Answers (2)

Coma
Coma

Reputation: 305

try RestTemplate , you can consume any web service

Upvotes: 0

OneCricketeer
OneCricketeer

Reputation: 191953

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

Upvotes: 3

Related Questions