Coder Social home page Coder Social logo

Comments (3)

jarpy avatar jarpy commented on May 31, 2024 2

Ah! Thanks for explaining. I was making assumptions based on my own experience, not yours. Sorry for the trouble.

from riemann.

jarpy avatar jarpy commented on May 31, 2024

It's not super-obvious, but the docs for influxdb2 suggest that:

For performance, you should wrap this stream with batch or an asynchronous queue.

You can use the async queue to call influxdb2 only once. Below is a sketch based on how I do this for Logstash. Note that I have not tested this sketch (sorry), but I think the same principles will apply for your use-case.

;; Establish a dedicated queue and thread(s) for sending metrics to InfluxDB.
(let [influx-queue (async-queue!
                    :influx-output-queue {:queue-size 1000 :core-pool-size 1 :max-pool-size 1}
                    (influxdb2 {:host "influxdb.example.com"
                                :organization "riemann"
                                :bucket "riemann"
                                :token "riemann"}))]

  ;; We've now defined the queue. Importantly, we've done it only once, in the
  ;; let-binding. Now we can define a stream function that closes over the queue
  ;; so that we can send many events to the single queue instance.
  (defn send-to-influx
    "A stream for sending events to influxdb2 via an async queue."
    [& children]
    (fn [event]
      (call-rescue event (conj children influx-queue)))))

from riemann.

node13h avatar node13h commented on May 31, 2024

@jarpy thanks, but I've already got it wrapped in async-queue! once. The VisualVM screenshots above were taken while influxdb2 was wrapped in async-queue!.
The problem is not in influxdb2, but in post-data which keeps creating a new instances of WriteApi on each invocation.

My config:

influxdb-batch-sender (batch 100 1
    (async-queue! :agg {:queue-size 1000
                        :core-pool-size 2
                        :max-pool-size 16}
                  (influxdb2 influxdb-creds)))

EDIT: formatting, and clarifications.

from riemann.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.