Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#4598] Supports traffic warm-up when the service is just started #4599

Open
wants to merge 16 commits into
base: 2.8.x
Choose a base branch
from

Conversation

chengyouling
Copy link
Contributor

No description provided.

Comment on lines 30 to 32
service:
warmup:
enabled: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature will cause demo-edge fail? Is it an incompatible feature?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compatible for edge

Comment on lines 75 to 76
String registerTimeStr = StringUtils.isBlank(server.getInstance().getTimestamp()) ? "0" :
server.getInstance().getTimestamp();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all Discovery implementation has timestamp and service center is server time not application time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to set register time by instance property

Comment on lines 193 to 194
// add register time for warm up
propertiesMap.put(InstancePropertiesConst.REGISTER_TIME_KEY, String.valueOf(System.currentTimeMillis()));
Copy link
Contributor

@liubao68 liubao68 Nov 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Distributed time may not always same for different instance, and weighted for instance is not only depended on instance startup time, but time accessed of the consumer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add provider invoke time to calculate weight

Comment on lines 82 to 93
private void refreshMapCache() {
List<String> removeKeys = new ArrayList<>();
for (Map.Entry<String, Long> entry : instanceInvokeTime.entrySet()) {
if (System.currentTimeMillis() - entry.getValue() > ignoreWarmUpTime) {
removeKeys.add(entry.getKey());
}
}
if (CollectionUtils.isEmpty(removeKeys)) {
return;
}
removeKeys.forEach(instanceInvokeTime::remove);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it removing not exist instance? Seems remove invoked instance will cause problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 20 to 22
public class InstancePropertiesConst {
public static final String REGISTER_TIME_KEY = "registerTime";
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If can make it simple, do not depends on register time? I think first access time is quite enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

.setNameFormat("warm-up-cache-refresh-%d")
.build());
ignoreWarmUpTime = getIgnoreWarmUpTime();
executor.scheduleAtFixedRate(this::refreshMapCache, 0, 10, TimeUnit.MINUTES);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe do not need a timer. You can remove not exist instance id every more 10 minutes when choosing server(condition e.g. not exist and last accessed time is more than 30 minutes).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants