Quarkus: Disable warning about slow localhost lookup for container and serverless deployments

Created on 24 Apr 2020  路  13Comments  路  Source: quarkusio/quarkus

Description

When deploying Quarkus on serverless (but I suppose slow container engines too), the localhost lookup warning is triggered. This is a warning that is here to help for development mode particularly.

But in cloud environment, people cannot do much about it (though it will slow down their startup time unnecessarily).

https://stackoverflow.com/questions/61241906/quarkus-startup-warning

Implementation ideas

If we can detect that we run in the serverless environment or in a container (orchestrator), disable the warning.
Thoughts @maxandersen @patriot1burke ?

A more general thinking would be to not have to do these lookups altogether, not sure that's doable @stuartwdouglas

areamazon-lambda arecore kinenhancement

Most helpful comment

This javadoc from Netty has some information https://netty.io/4.1/api/io/netty/channel/ChannelId.html. From what I read there, I think it's OK to set the value to what's proposed above, especially since that javadoc says:

The global uniqueness of the generated identifier mostly depends on the MAC address and the current process ID, which are auto-detected at the class-loading time in best-effort manner. If all attempts to acquire them fail, a warning message is logged, and random values will be used instead. 

I'll come up with a PR with this proposed change and let's see how it goes.

All 13 comments

even in serverless/cloud >1 second for resolving localhost is a concern is it not ?

I assume at best we can have a option to disable it

Yes it is a concern but what can you do when AWS gets it slow? I thought about properties but it鈥檚 for the weak, I鈥檇 prefer something smarter.

when AWS gets it slow ? today you can be aware and if you don't care you turn the warning off.
If we make it smarter it won't show up and we wouldn't know if there actually is a problem.

Do we know it always takes >1s for this in amazon ?

When moving from 512 to 1024MB of RAM for the function, the warning disappeared for the user https://stackoverflow.com/questions/61241906/quarkus-startup-warning. So it's comorbid to the amount of CPU available (RAM and CPU are joint in AWS)

the simplest way to disable it is to change the log level for that category. It's really not great that this is an issue though, that is basically adding a second to our startup time.

Looking at what really happens on that call to DefaultChannelId.newInstance();[1] (the call whose timing we track to report this warn message), the main intensive work seems to happen in the call to defaultMachineId()[2] where it tries to find the best MAC address (by going through the available network interfaces) and creating a machine id out of it.
Perhaps we could just set the io.netty.machineId system property[3] in Quarkus and just bypass this whole computation? Something like:

final byte[] machineIdBytes = new byte[8];
java.util.concurrent.ThreadLocalRandom.current().nextBytes(machineIdBytes);
final String machineId = io.netty.util.internal.MacAddressUtil.formatAddress(machineIdBytess);
System.setProperty("io.netty.machineId", machineId);

I'm not too familiar with Netty in general, but given that the Netty code does fallback to something similar, I guess this shouldn't be a problem?

[1] https://github.com/netty/netty/blob/4.1/transport/src/main/java/io/netty/channel/DefaultChannelId.java#L58
[2] https://github.com/netty/netty/blob/4.1/common/src/main/java/io/netty/util/internal/MacAddressUtil.java#L133
[3] https://github.com/netty/netty/blob/4.1/transport/src/main/java/io/netty/channel/DefaultChannelId.java#L86

When moving from 512 to 1024MB of RAM for the function, the warning disappeared for the user https://stackoverflow.com/questions/61241906/quarkus-startup-warning. So it's comorbid to the amount of CPU available (RAM and CPU are joint in AWS)

The number of network interfaces on the system will also play a role here (looking at the above logic). Plus I'm not really sure that the current log message is accurate since this really isn't about how long it takes to resolve localhost, unless I missed something in that code.

That MAC thing is interesting! I always wondered whether there is more to it since adjusting hosts never made a difference on my Windows machine.

This seems like a good idea to me, although I am not sure what implications this will have. @vietj @cescoffier do you know how important the machine ID is?

If I remember correctly, it鈥檚 mostly used for clustering. I will check if it鈥檚 used somewhere else.

I was confused and was referring to serverId. I don't believe machineId is used by Vert.x, it's a Netty thing.

This javadoc from Netty has some information https://netty.io/4.1/api/io/netty/channel/ChannelId.html. From what I read there, I think it's OK to set the value to what's proposed above, especially since that javadoc says:

The global uniqueness of the generated identifier mostly depends on the MAC address and the current process ID, which are auto-detected at the class-loading time in best-effort manner. If all attempts to acquire them fail, a warning message is logged, and random values will be used instead. 

I'll come up with a PR with this proposed change and let's see how it goes.

I've opened https://github.com/quarkusio/quarkus/pull/9246 with the potential fix.

Was this page helpful?
0 / 5 - 0 ratings