zhouchaogithub / spring-cloud

SpringCloud学习项目
0 stars 0 forks source link

Why Is It so Slow to Register a Service? #2

Open zhouchaogithub opened 6 years ago

zhouchaogithub commented 6 years ago

Being an instance also involves a periodic heartbeat to the registry (through the client’s serviceUrl) with a default duration of 30 seconds. A service is not available for discovery by clients until the instance, the server, and the client all have the same metadata in their local cache (so it could take 3 heartbeats). You can change the period by setting eureka.instance.leaseRenewalIntervalInSeconds. Setting it to a value of less than 30 speeds up the process of getting clients connected to other services. In production, it is probably better to stick with the default, because of internal computations in the server that make assumptions about the lease renewal period.

作为实例还涉及到注册表(通过客户端serviceUrl)的定期心跳,默认持续时间为30秒。在实例,服务器和客户端在其本地缓存中都具有相同的元数据之前,客户端无法发现服务(因此可能需要3次心跳)。您可以通过设置更改期间eureka.instance.leaseRenewalIntervalInSeconds。将其设置为小于30的值可加快使客户端连接到其他服务的过程。在生产中,最好坚持使用默认值,因为服务器中的内部计算会对租赁续订期做出假设。