【问题标题】:Is it possible to use redis_store output plugin for fluentd to handle huge amount of logs?是否可以使用 fluentd 的 redis_store 输出插件来处理大量日志?
【发布时间】:2022-01-20 11:06:47
【问题描述】:

我正在尝试配置 fluentd 以将日志发送到不同服务器上的 redis(路径为 fluentbit-fluentd-redis-logstash-elastic),但我无法弄清楚一些性能问题。如果我只将日志保存在磁盘上,一切正常,所有日志都保存(每秒数千个),但是如果我添加 redis_store 部分,相同数量的数据会使 fluentd 慢得多,并且内存仍在增长,直到下次重新启动(天或二)。 我知道这可能是因为输入比输出快,但是如何处理,如何将这么多数据发送到redis?添加更多内存不是解决方案,它只能添加一些时间。是不是因为redis接收不了这么多线程的数据(但是redis没有超载,没有队列)?我不知道这是网络问题(但在这个插件中我不能尝试其他协议?),cpu 问题(cpu 是 cca 70%),还是插件本身? 如果我添加redis插件,与redis的通信太慢了,以至于fluentd不够快并且将数据添加到内存中。

配置

<system>
  workers 4
  root_dir /fluentd/log/buffer/
</system>

<worker 0-3>
<source>
 @type forward
  bind 0.0.0.0
  port 9880
</source>

<label @TEST>
<match test.**> 
 @type forest
 subtype copy
 <template>
 <store>
    @type file
    @id "test-#{worker_id}"
    @log_level debug
    path "fluentd/log/test-#{worker_id}.*.log"
    append true
 <buffer>
    flush_mode interval
    flush_interval 3
    flush_at_shutdown true
  </buffer>
 <format>
  @type single_value
  message_key log
 </format>
 </store>
 <store>
     @type redis_store
     host server_ip
     port 6379
     key test
     store_type list
 <buffer>
    flush_mode interval
    flush_interval 3
    flush_at_shutdown true
    flush_thread_count 4
  </buffer>
 </store>
  </template>
</match>
</label>
</worker>

有什么技巧可以提高 redis 的吞吐量吗? 谢谢

【问题讨论】:

    标签: redis fluentd


    【解决方案1】:

    如果您使用的是 redisstore 插件,您可以通过安装包装了 C redis API 的hiredis gem 获得更好的性能

    https://github.com/moaikids/fluent-plugin-redisstore

    【讨论】:

    • 谢谢你,我会试试你建议的插件,但直到现在我们都用这个github.com/pokehanai/fluent-plugin-redis-store。有没有机会让它更好地工作? (没有hiredis)我真的不明白问题出在哪里——它不能这么快地发送数据,所以我们不能在我们的环境中使用redis和elk——它会减慢整个流利的速度:/。
    • Hiredis 将比原生 ruby​​ redis 驱动程序快得多。在规模上,它确实会为您带来与众不同的体验
    • 所以我尝试了你提到的插件(fluent-plugin-redisstore),它不能用于多人 - 我们需要使用 MW 因为大量的数据......: /我也尝试了第二个,原来的..(fluent-plugin-redis)并且那个可以使用MW但不能与LIST一起使用....你知道如何解决它吗?我很失望,我们没有选择正确设置它...:(
    猜你喜欢
    • 1970-01-01
    • 2020-11-19
    • 2015-09-29
    • 1970-01-01
    • 2012-03-23
    • 1970-01-01
    • 1970-01-01
    • 2015-08-18
    • 1970-01-01
    相关资源
    最近更新 更多