DataDog / logstash-output-datadog_logs

DatadogLogs lets you send logs to Datadog based on LogStash events.
Apache License 2.0
13 stars 9 forks source link

Concurrency level limits performance #26

Open pz07 opened 2 years ago

pz07 commented 2 years ago

Hi, I've noticed the output is single-threaded. This limits performance significantly. In our case lag of sending log messages to DD is sometimes greater than 30 mins. This is mainly caused by the fact that only one worker thread sends messages to DD. All other worker threads that finished processing inputs and filters are blocked. This is due to the default concurrency level used by the plugin, which is :legacy.

Is it possible to change concurrency level of the plug-in to :shared to allow sending requests to DD in parallel? The code change is described here: https://www.elastic.co/guide/en/logstash/current/output-new-plugin.html From the doc:

# This sets the concurrency behavior of this plugin. By default it is :legacy, which was the standard
  # way concurrency worked before Logstash 2.4
  #
  # You should explicitly set it to either :single or :shared as :legacy will be removed in Logstash 6.0
  #
  # When configured as :single a single instance of the Output will be shared among the
  # pipeline worker threads. Access to the `#multi_receive/#multi_receive_encoded/#receive` method will be synchronized
  # i.e. only one thread will be active at a time making threadsafety much simpler.
  #
  # You can set this to :shared if your output is threadsafe. This will maximize
  # concurrency but you will need to make appropriate uses of mutexes in `#multi_receive/#receive`.
  #
  # Only the `#multi_receive/#multi_receive_encoded` methods need to actually be threadsafe, the other methods
  # will only be executed in a single thread
  concurrency :single

If you agree this is a good idea, I can do the change and create pull request.

I'm using Logstash v.6.x.x

pz07 commented 2 years ago

HTTP client the plug-in uses seems to be thread safe, so this seems to be simple configuration change https://github.com/cheald/manticore