Improve websocket message coalescing to handle thundering herds better (#118268)
* Increase websocket peak messages to match max expected entities
During startup the websocket would frequently disconnect if more than
4096 entities were added back to back. Some MQTT setups will have more
than 10000 entities. Match the websocket peak value to the max expected
entities
* coalesce more
* delay more if the backlog gets large
* wait to send if the queue is building rapidly
* tweak
* tweak for chrome since it works great in firefox but chrome cannot handle it
* Revert "tweak for chrome since it works great in firefox but chrome cannot handle it"
This reverts commit 439e2d76b1
.
* adjust for chrome
* lower number
* remove code
* fixes
* fast path for bytes
* compact
* adjust test since we see the close right away now on overload
* simplify check
* reduce loop
* tweak
* handle ready right away
This commit is contained in:
parent
b94bf1f214
commit
79bc179ce8
5 changed files with 124 additions and 69 deletions
|
@ -25,8 +25,15 @@ PENDING_MSG_PEAK_TIME: Final = 5
|
|||
# Maximum number of messages that can be pending at any given time.
|
||||
# This is effectively the upper limit of the number of entities
|
||||
# that can fire state changes within ~1 second.
|
||||
# Ideally we would use homeassistant.const.MAX_EXPECTED_ENTITY_IDS
|
||||
# but since chrome will lock up with too many messages we need to
|
||||
# limit it to a lower number.
|
||||
MAX_PENDING_MSG: Final = 4096
|
||||
|
||||
# Maximum number of messages that are pending before we force
|
||||
# resolve the ready future.
|
||||
PENDING_MSG_MAX_FORCE_READY: Final = 256
|
||||
|
||||
ERR_ID_REUSE: Final = "id_reuse"
|
||||
ERR_INVALID_FORMAT: Final = "invalid_format"
|
||||
ERR_NOT_ALLOWED: Final = "not_allowed"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue