使用flume thrift source的一点心得

来源:互联网 发布:淘宝网羽绒服女装 编辑:程序博客网 时间:2024/05/29 12:14

最近一直在使用flumethrift source,刚开始搭建就遇到很多问题(依赖的其他程序较多),之后是编译程序编不过(用g++,需-lg++ -g -DHAVE_NETr/local/include/thrift -L/usr/local/lib flumethriftclient.cpp gen-cpp/flume_constants.cpp gen-cpp/flume_types.cpp gen-cpp/ThriftSourceProtocol.cpp  -o  flumeclient -lthriftnb -levent -lthrift -lrt),这两点已经进行了总结。

之后在线测试发现一条一条append消息给flume太慢,性能差,所以修改为批量发送appendBatch,设置的batchsize50100,不是很大,性能有很大的提升。

flume的配置文件中源配置为thrift,使用memorychannel,刚开始设置如下:

producer.sources.netcatSource.type = thrift

producer.sources.netcatSource.bind = 10.0.6.227

producer.sources.netcatSource.port = 5496

producer.sources.netcatSource.channels = memoryChannel

producer.channels.memoryChannel.capacity = 1000

之后,看flume的用户手册,发现thrift source可以多线程接受,所以添加:

producer.sources.netcatSource.threads= 16

 

此时,去线上测试性能,设置batchsize100,发现消息量少,发送速度也不够,所以修改为200,但总是发送失败,flume也不报error,只有warn"Thrift source %s could not append events to the channel."

查阅资料,咨询大神后,才明白,这和memory channel的另一个参数有关:transactionCapacity,(The maximum number of events the channel will take from a source or give to a sink per transaction)表明sourcechannelchannelsink一次发送的event个数,如果不设置,默认值为100。所以当我设置batchsize100时,可以正确发送,但是超过100,就发送失败。

 

所以,解决方案为:

1. producer.channels.memoryChannel.capacity = 100000

2. producer.channels.memoryChannel.transactionCapacity= 1000

3. 同时,在flume-ng文件中,设置-Xmx1000m,将flume允许使用的最大内存设置大一点;

4. 那么,此时的batchsize可以设置为小于1000的任何值。值越大,发送消息越快。

 

可见flumesourcechannel还是息息相关的。

0 0
原创粉丝点击