Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is hello-world example project so slow to startup in micronaut?

Tags:

micronaut

Is it normal for Micronaut to take ~75 seconds to start it's hello-world example project? This seems very much at odds with the way the framework has been described. I am running this on a MacBook pro with decent specs and the project was created following the steps in the Micronaut User Guide without any customization. The same happens whether I start from my IDE or the uber jar.

java -jar ./libs/hello-world-0.1-all.jar
04:53:39.715 [main] INFO  io.micronaut.runtime.Micronaut - Startup completed in 76248ms. Server Running: http://localhost:8080

FWIW, I was intrigued by Micronaut since I stumbled across it a few months back in part because Spring has become too bloated and I was looking for alternatives. I was planning to build a simple REST service and compare it with the same service in SpringBoot but I view this slowness as a blocker.

At first I was thinking that this might be the Annotation Processors doing their IOC stuff but, that can't be the culprit because it is just as slow using the uber jar which shouldn't incur this cost. Any ideas?

like image 601
Brian D Avatar asked Mar 06 '23 04:03

Brian D


1 Answers

Check your hostname with:

hostname

and add it to /etc/hosts for 127.0.0.1 and ::1 addresses.

According to Micronaut's official guide there is a known bug causing delay when calling java.net.InetAddress.getLocalHost() on Mac OS when the hostname is not present in the /etc/hosts file.

/etc/hosts

127.0.0.1       localhost <hostname>
::1             localhost <hostname>

https://docs.micronaut.io/latest/guide/index.html#problems

like image 92
Szymon Stepniak Avatar answered Mar 13 '23 23:03

Szymon Stepniak