-
Notifications
You must be signed in to change notification settings - Fork 12
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
Is it necessary to make refresh_lease one long-lived coroutine? #33
Comments
@garvenlee |
If this is a transient issue may be just spawn a warning and continue, otherwise check the server side and probably network for issues. |
Also the thread may be helpful #31. |
Yeah, but I suspect that the frequent creation of stream-stream requests is more stressful for the ETCD server? So can you evaluate this: async def refresh_lease(self, id):
await self.id_queue.put(id)
waiter = create_future()
self.waiter = waiter
return await wait_for(waiter, timeout)
async def grpc_lease_keepalive(self, id_queue):
async def request_iterator():
while True:
id = await id_queue.get()
yield LeaseKeepAliveRequest(ID=id)
async for reply in stub.LeaseKeepalive(request_iterator()):
if not self.waiter.done():
self.waiter.set_result(reply)
|
@garvenlee I think you don't need this operation to perform continuously. Usually there is a sane TTL, for example 10 seconds, and after that you don't need more than All the operations share one single channel and connection, so there should not be much overhead except for extreme cases. |
The lease machinery by itself solves the original KV TTL problem, when you have many entities and want to maintain TTL for all of them. With lease it is as easy as attach the same lease ID to all of them. I don't argue that there are no projects that will be limited by the one-stream-stream-per-refresh, but It's not an ordinary situation. When you have to maintain a large amount of keys with different TTLs leases are not the biggest concern. |
Indeed, all requests share a channel, but I think that since ETCD has designed LeaseKeepalive as a two-way stream method, reusing this same stream can avoid the cost of stream resources to a certain extent. |
Here is my code:
Two hours after the periodic execution of refresh_lease of my code, I got the following exceptions:
The text was updated successfully, but these errors were encountered: