-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Consider a timeout heap #6
Comments
Would you like to send a PR? Overall this module is way less useful as |
For timeouts on sockets that are ~ 1 minute it's probably fine. We build an RPC framework and were pushing 1000 QPS with timeouts of 100ms by default under the motto of "Your P99 should be 100ms or go home". Trashing the event loop with 1000 timers of 100ms each was not a happy time :( After reading more of the README I think our use cases are very different. |
Since Node 11, the timers would have been deduplicated and you'd get only 10. |
I never got the chance to upgrade the version of node and check out the performance at scale 😞 |
We implemented a timeout Heap datastructure at uber ( https://github.com/uber/tchannel-node/blob/master/time_heap.js ).
It supports a
minTimeout
function or number which we use likeUsing a heap is better then an array or linked list for nuanced reasons I don't quite understand.
But what is better then
setTimeout
is to sayThis basically means that if you have 10,000 sockets you are garantueed a maximum of 10
setTimeout
calls on the libuv event loop every 10 seconds no matter what load there is.If you have a 5s or 30s timeout on sockets then an extra 100ms delay on the
socket.destroy()
is not a big deal in our usecase.Also
timeoutFuzz
is a super awesome feature to avoid "thundering herd" problems, if you restart all your servers at the same time they might all set a timeout to expire exactly 10s in the future, by adding 50ms fuzz to either side you can spread out a "thundering reconnection herd" over a 100ms window in time instead of a 0ms window in time.The text was updated successfully, but these errors were encountered: