Limit the number of rrd_create threads #640
Closed
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.
Hello,
PR #262 is a nice feature (create asynchronous threads for rrd files creation).
However, when too many new metrics come, there is still an issue : too many rrdcreate threads (I can have more than 1000 at the same time). And more there are, slower they become.
PR #244 has already proven to me that it was useful, but it does not help when the problem comes from too many RRD files to create.
So we should limit the number or create threads.
Check the attached patch and the new option
CreateFilesAsyncLimit
, that defaults to 0 (no limit, current behaviour) but that can be set to limit the number of threads.Description
There is a list (
async_creation_list
) of rrd files being created. I added a var (async_creation_list_size
) with the size of this list.Before the thread is created,
async_creation_list_size
is checked quickly (no lock) to see if the rrd file can be created or if there are already too many threads.If there are too many threads, the metric is dropped and we hope that it will be sent again in 60 seconds (or whatever the interval is) and file can be created then.
This check is done fast, outside a pthread_locked section, so it is reliable only if there are too many threads.
If
async_creation_list_size
is small enough, the thread is created. A new check is done onasync_creation_list_size
because many threads can start and launch file creation at the same time (1st check was out of the pthread_locked section). The second check is reliable because it is done inside the locked section.Note : 1st check is reliable when there are already too many threads running. This is why I implemented it : no need to start a new thread to see that it was useless.