fix(pubsub): increase subscription buffer size to prevent message drops #1989
+5
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Messages from
libp2p
were being validated successfully but were not reaching the message queue.Upon enabling logs for the
libp2p pubsub
package, it was discovered that the following error was causing message drops:This occurred because the default subscription buffer size was too small (32), resulting in messages being dropped when the buffer was full.
Solution
128
to handle bursts of incoming messages and reduce message drops.After increasing the subscription buffer size to 128, we observed a drop in transmit bandwidth and rate of transmitted packets (see attached screenshot). This is a positive outcome, as the change mitigates message loss by providing more time for subscribers to process messages under load. The reduced bandwidth usage likely results from fewer message drops and retries, as the larger buffer prevents the "subscriber too slow" errors that previously caused excessive retransmissions.
Additionally, the CPU usage dropped slightly but not significantly, and memory usage remained unchanged. These resource metrics suggest the fix improved message handling efficiency without introducing notable overhead.
Further tuning may still be required based on actual workload