flume高并发优化——(1)load_balance


       通过一年多时间的使用,统一日志系统,已经接入公司前台,在20个节点,几十万用户,数百亿交易额的大压力下,仅仅使用了一个普通的服务器,承受住了严峻的考验,在公司今年更宏大的目标,也是为了给大数据组提供更加全面信息的需求下,公司所有项目,要接入ULOG系统,主要包含管理后台,wap,app等,流量一下达到一个峰值,flume的瓶颈凸显出来,在解决的过程中,对flume的了解以及性能调优,有了更深入的认识,接下的文章,会比较紧凑,请大家紧随脚步,看看我们这几周的调优结果。

        大家还记得以前的ulog部署方案吗?我们通过一张图来回忆一下:

专栏地址:大数据下的日志




这是一个最初的方案,这个方案,马上面临了以下问题:

1,flume使用memory作为channel经常丢失数据

2,两个节点分担压力有限


基于此,我们进行了第一次优化,加入flume以file为基础的负载均衡,大家看效果图:



大家看flume负载均衡端的配置文件:

[html]  view plain  copy
  1. balance.sources = source1  
  2. balance.sinks = k1 k2  
  3. balance.channels = channel1  
  4.   
  5. # Describe/configure source1  
  6. balance.sources.source1.type = avro  
  7. balance.sources.source1.bind = 192.168.10.83  
  8. balance.sources.source1.port = 12300  
  9.   
  10. #define sinkgroups  
  11. balance.sinkgroups=g1  
  12. balance.sinkgroups.g1.sinks=k1 k2  
  13. balance.sinkgroups.g1.processor.type=load_balance  
  14. balance.sinkgroups.g1.processor.backoff=true  
  15. balance.sinkgroups.g1.processor.selector=round_robin  
  16.   
  17. #define the sink 1  
  18. balance.sinks.k1.type=avro  
  19. balance.sinks.k1.hostname=192.168.10.83  
  20. balance.sinks.k1.port=12301  
  21.   
  22. #define the sink 2  
  23. balance.sinks.k2.type=avro  
  24. balance.sinks.k2.hostname=192.168.10.84  
  25. balance.sinks.k2.port=12302  
  26.   
  27. # Use a channel which buffers events in memory  
  28. # Use a channel which buffers events in memory  
  29. balance.channels.channel1.type = file  
  30. balance.channels.channel1.checkpointDir = /export/data/flume/flume-1.6.0/dataeckPoint/balance  
  31. balance.channels.channel1.useDualCheckpoints = true  
  32. balance.channels.channel1.backupCheckpointDir = /export/data/flume/flume-1.6.0/data/bakcheckPoint/balance  
  33. balance.channels.channel1.dataDirs =/export/data/flume/flume-1.6.0/data/balance  
  34. balance.channels.channel1.transactionCapacity = 10000  
  35. balance.channels.channel1.checkpointInterval = 30000  
  36. balance.channels.channel1.maxFileSize = 2146435071  
  37. balance.channels.channel1.minimumRequiredSpace = 524288000  
  38. balance.channels.channel1.capacity = 1000000  
  39. balance.channels.channel1.keep-alive=3  
  40.   
  41. # Bind the source and sink to the channel  
  42. balance.sources.source1.channels = channel1  
  43. balance.sinks.k1.channel = channel1  
  44. balance.sinks.k2.channel=channel1  

优化:

这样的初始方式,我们发现性能问题被解决了一小部分,但是仅仅是缓解,我们还需要优化,以便适应当下的需求,通过论坛,我们知道,sinkgroups,是单线程,意味着,我们启动的sink是一个线程在读数据,而如果删除sinkgroups,就是为每个sink启动一个线程,会优化文件的消费速度,大家看第二次的优化:

        

[html]  view plain  copy
  1. balance.sources = source1  
  2. balance.sinks = k1 k2  
  3. balance.channels = channel1  
  4.   
  5. # Describe/configure source1  
  6. balance.sources.source1.type = avro  
  7. balance.sources.source1.bind = 192.168.10.83  
  8. balance.sources.source1.port = 12300  
  9.   
  10. #define the sink 1  
  11. balance.sinks.k1.type=avro  
  12. balance.sinks.k1.hostname=192.168.10.83  
  13. balance.sinks.k1.port=12301  
  14.   
  15. #define the sink 2  
  16. balance.sinks.k2.type=avro  
  17. balance.sinks.k2.hostname=192.168.10.84  
  18. balance.sinks.k2.port=12302  
  19.   
  20. # Use a channel which buffers events in memory  
  21. # Use a channel which buffers events in memory  
  22. balance.channels.channel1.type = file  
  23. balance.channels.channel1.checkpointDir = /export/data/flume/flume-1.6.0/dataeckPoint/balance  
  24. balance.channels.channel1.useDualCheckpoints = true  
  25. balance.channels.channel1.backupCheckpointDir = /export/data/flume/flume-1.6.0/data/bakcheckPoint/balance  
  26. balance.channels.channel1.dataDirs =/export/data/flume/flume-1.6.0/data/balance  
  27. balance.channels.channel1.transactionCapacity = 10000  
  28. balance.channels.channel1.checkpointInterval = 30000  
  29. balance.channels.channel1.maxFileSize = 2146435071  
  30. balance.channels.channel1.minimumRequiredSpace = 524288000  
  31. balance.channels.channel1.capacity = 1000000  
  32. balance.channels.channel1.keep-alive=3  
  33.   
  34. # Bind the source and sink to the channel  
  35. balance.sources.source1.channels = channel1  
  36. balance.sinks.k1.channel = channel1  
  37. balance.sinks.k2.channel=channel1  

现象:

        我们去除sinkgroups后,虽然有些变化,但是数据依然有很大的延迟,随着时间推移,还是会达到性能瓶颈,具体,我们就要在下篇博客中介绍,如何从整体结构上优化数据传输效率。



总结:

        有时的负载均衡,也会成为性能瓶颈,在分配端,我们也要看,那种效率更高,效果更好,这样,我们就能找到合适的点,平衡我们的需求和性能。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值