Skip to content
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

CPU regression with NonBlockingStatsDClient #133

Open
elenatomlinson opened this issue Jan 13, 2021 · 1 comment
Open

CPU regression with NonBlockingStatsDClient #133

elenatomlinson opened this issue Jan 13, 2021 · 1 comment

Comments

@elenatomlinson
Copy link

Hi there,

We recently migrated from NonBlockingStatsDClient.java to DataDog's NonBlockingStatsDClient.java. We see significant increase of cpu usage, proportional to number of instances of the client. e.g. single application pod cpu usage in millicores increased from 2 to 10 after migration, then from 10 to 29 after instantiating 3x the number of clients during experimentation.

@conderls
Copy link

it seems that the sample rate is out of use when aggregation is enabled. the usage of cpu and memory may increase when monitoring massive messages.

https://github.com/DataDog/java-dogstatsd-client/blob/master/src/main/java/com/timgroup/statsd/NonBlockingStatsDClient.java#L1191-L1209

    private void send(String aspect, final long value, Message.Type type, double sampleRate, String[] tags) {
        if (statsDProcessor.getAggregator().getFlushInterval() != 0 && !Double.isNaN(sampleRate)) {
            switch (type) {
                case COUNT:
                    sampleRate = Double.NaN; // <-- reset sampleRate to NaN
                    break;
                default:
                    break;
            }
        }

        if (Double.isNaN(sampleRate) || !isInvalidSample(sampleRate)) {

            sendMetric(new StatsDMessage<Long>(aspect, type, value, sampleRate, tags) {
                @Override protected void writeValue(StringBuilder builder) {
                    builder.append(this.value);
                }
            });
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants