Repository navigation
Replies: 2 comments
|
please help me |
|
The fix should be to gate Spring Cloud/Nacos HTTP registration on application readiness, rather than adding a startup sleep:
This removes the race without coupling correctness to timing. The useful verification is a cold start with the gateway polling discovery: no traffic should be routed before readiness, and after readiness a request should not be the first operation that creates a |
Uh oh!
There was an error while loading. Please reload this page.
Pre-check
Apache Dubbo Component
Java SDK (apache/dubbo)
Details
Background
After upgrading our application from Dubbo 2 to Dubbo 3, we found that an
application containing many Dubbo consumers may receive HTTP traffic before all
Dubbo consumers have finished initialization.
The application is also registered with Spring Cloud Nacos Discovery to receive
HTTP traffic from an upstream gateway.
This problem did not occur, or was not noticeable, when we were using Dubbo 2
with JDK 8.
Environment
Nacos is used for both:
The application contains many
@DubboReferenceconsumers. Lazy initializationis not enabled, and the previous
init = falsesettings have been removed.Some references use
check = false, because the application should still beable to start when an optional provider is temporarily unavailable.
Problem
During startup, the embedded Tomcat server starts before the Dubbo application
and all consumer references have completed startup.
Spring Cloud Nacos may register the HTTP service instance after the web server
has started. The upstream gateway can then discover the instance and send HTTP
requests to it.
At this time, Dubbo is still initializing consumers, including operations such
as:
ReferenceConfigWhen an HTTP request invokes one of these consumers during this period, the
request may block during consumer initialization or service discovery. In some
cases, the request duration is close to the configured Dubbo timeout.
After all consumers have been initialized, subsequent requests return to normal.
Startup timeline
The following is an example from our startup log:
All reactions