Storm fields grouping

前端 未结 2 1360
-上瘾入骨i
-上瘾入骨i 2020-12-21 08:59

I\'m having the following situation:

  • There is a number of bolts that calculate different values
  • This values are sent to visualization bolt
  • Vi
2条回答
  •  离开以前
    2020-12-21 09:44

    I guess you can use Partial Key grouping (partialKeyGrouping). On the Storm documentation about stream groups says:

    Partial Key grouping: The stream is partitioned by the fields specified in the grouping, like the Fields grouping, but are load balanced between two downstream bolts, which provides better utilization of resources when the incoming data is skewed. This paper provides a good explanation of how it works and the advantages it provides.

    I implemented a simple topology using this grouping and the chart on Graphite server show a better load balance compared to fieldsGrouping. The full source code is here.

    topologyBuilder.setBolt(MqttSensors.BOLT_SENSOR_TYPE.getValue(), new SensorAggregateValuesWindowBolt().withTumblingWindow(Duration.seconds(5)), 2)
            // .fieldsGrouping(MqttSensors.SPOUT_STATION_01.getValue(), new Fields(MqttSensors.FIELD_SENSOR_TYPE.getValue()))
            // .fieldsGrouping(MqttSensors.SPOUT_STATION_02.getValue(), new Fields(MqttSensors.FIELD_SENSOR_TYPE.getValue()))
            .partialKeyGrouping(MqttSensors.SPOUT_STATION_01.getValue(), new Fields(MqttSensors.FIELD_SENSOR_TYPE.getValue()))
            .partialKeyGrouping(MqttSensors.SPOUT_STATION_02.getValue(), new Fields(MqttSensors.FIELD_SENSOR_TYPE.getValue()))
            .setNumTasks(4) // This will create 4 Bolt instances 
            .addConfiguration(TagSite.SITE.getValue(), TagSite.EDGE.getValue())
            ;
    

提交回复
热议问题