This repository has been archived by the owner on Jan 14, 2022. It is now read-only.
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.
This PR improves how Flodgatt behaves when Redis has a very large number of messages available at the same time (a situation that is rare on small instances, but that could occur more frequently on larger instances).
First, it implements a modified ring buffer and limits the amount of data it fetches from Redis in one syscall to 8 KiB (two pages on most systems). Flodgatt will process all complete messages it receives from Redis and then re-use the same buffer for the next time it retrieves data. If
Flodgatt received a partial message, it will copy the partial message to the beginning of the buffer before its next read.
This change has little effect on Flodgatt under light load (because it was rare for Redis to have more than 8 KiB of messages available at any one time). However, my hope is that this will significantly
reduce memory use on the largest instances.
Second, this PR alters how Flodgatt behaves if it receives enough messages for a single client to fill that client's channel. (Because the clients regularly send their messages, should only occur if a single client receives a large number of messages nearly simultaneously; this is rare, but could occur, especially on large instances).
Previously, Flodgatt would drop messages in the rare case when the client's channel was full. Now, Flodgatt will pause the current Redis poll and yield control back to the client streams, allowing the
clients to empty their channels; Flodgatt will then resume polling Redis/sending the messages it previously received. With the approach, Flodgatt will never drop messages.
This PR also adds a new
/status/backpressure
endpoint that displays the current length of the Redis input buffer (which should typically be low or 0). Like the other/status
endpoints, thisendpoint is only enabled when Flodgatt is compiled with the
stub_status
feature.