Slow to start application on different connections
I'm experiencing some weirdness with a Spring Boot application.
When I'm connected to WIFI A (my home network) or disconnected from the internet entirely, the application starts within 6 seconds.
When I'm connected to WIFI B (my work network) the application takes 1.5 minutes to start.
This is a simple Hello, world! spring application. The main class looks like this:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
System.out.println("START := " + System.currentTimeMillis());
SpringApplication.run(Application.class, args);
System.out.println("STOP := " + System.currentTimeMillis());
}
}
I see that the START timestamp is printed at roughly the same speed, so it must be the SpringApplication.run. This is a bare class, so there is no spring configurations otherwise. Why would a change in WIFI connection cause such lag to start? I'm running it both using mvn spring-boot:run
on Mac OSX
I was having a very similar problem to this. A very Simple Spring Boot app would take around 45 seconds to start on office network, and under 10 seconds on my home network.
It seems there was a delay identifying my external IP address, but running the following command fixed it on my Mac.
scutil --set HostName "localhost"
@chrylis is correct, it was a DNS lookup issue. By changing my DNS resolving settings on my work internet, the startup time improved infinitely.
Now I wonder why spring boot is slower when there is a slow DNS resolver, or maybe is it a MacOSX issue?
链接地址: http://www.djcxy.com/p/48704.html上一篇: @EnableAspectJAutoProxy不起作用
下一篇: 慢启动应用程序在不同的连接