StormCrawler:集群的最佳拓扑

StormCrawler: best topology for cluster

我正在使用 stormcrawler 来抓取 40k 个站点,max_depth=2,我想尽可能快地完成它。 我有 5 个风暴节点(具有不同的静态 ips)和 3 个弹性节点。 目前我最好的拓扑结构是:

spouts:
  - id: "spout"
    className: "com.digitalpebble.stormcrawler.elasticsearch.persistence.CollapsingSpout"
    parallelism: 10

bolts:
  - id: "partitioner"
    className: "com.digitalpebble.stormcrawler.bolt.URLPartitionerBolt"
    parallelism: 1
  - id: "fetcher"
    className: "com.digitalpebble.stormcrawler.bolt.FetcherBolt"
    parallelism: 5
  - id: "sitemap"
    className: "com.digitalpebble.stormcrawler.bolt.SiteMapParserBolt"
    parallelism: 5
  - id: "parse"
    className: "com.digitalpebble.stormcrawler.bolt.JSoupParserBolt"
    parallelism: 100
  - id: "index"
    className: "com.digitalpebble.stormcrawler.elasticsearch.bolt.IndexerBolt"
    parallelism: 25
  - id: "status"
    className: "com.digitalpebble.stormcrawler.elasticsearch.persistence.StatusUpdaterBolt"
    parallelism: 25
  - id: "status_metrics"
    className: "com.digitalpebble.stormcrawler.elasticsearch.metrics.StatusMetricsBolt"
    parallelism: 5

和爬虫配置:

config: 
  topology.workers: 5
  topology.message.timeout.secs: 300
  topology.max.spout.pending: 250
  topology.debug: false
  fetcher.threads.number: 500
  worker.heap.memory.mb: 4096

问题: 1) 我应该使用 AggreationsSpout 还是 CollapsingSpout,有什么区别?我尝试了 AggregationSpout,但性能相当于 1 台默认配置机器的性能。

2) 这种并行配置是否正确?

3) 当我从 1 节点配置跳转到 5 节点配置时,我发现 "FETCH ERROR" 增加了 ~20% 并且很多站点未正确获取。可能是什么原因?

更新:

es-conf.yaml:

# configuration for Elasticsearch resources

config:
  # ES indexer bolt
  # adresses can be specified as a full URL
  # if not we assume that the protocol is http and the port 9200
  es.indexer.addresses: "1.1.1.1"
  es.indexer.index.name: "index"
  es.indexer.doc.type: "doc"
  es.indexer.create: false
  es.indexer.settings:
    cluster.name: "webcrawler-cluster"

  # ES metricsConsumer
  es.metrics.addresses: "http://1.1.1.1:9200"
  es.metrics.index.name: "metrics"
  es.metrics.doc.type: "datapoint"
  es.metrics.settings:
    cluster.name: "webcrawler-cluster"

  # ES spout and persistence bolt
  es.status.addresses: "http://1.1.1.1:9200"
  es.status.index.name: "status"
  es.status.doc.type: "status"
  #es.status.user: "USERNAME"
  #es.status.password: "PASSWORD"
  # the routing is done on the value of 'partition.url.mode'
  es.status.routing: true
  # stores the value used for the routing as a separate field
  # needed by the spout implementations
  es.status.routing.fieldname: "metadata.hostname"
  es.status.bulkActions: 500
  es.status.flushInterval: "5s"
  es.status.concurrentRequests: 1
  es.status.settings:
    cluster.name: "webcrawler-cluster"

  ################
  # spout config #
  ################

  # positive or negative filter parsable by the Lucene Query Parser
  # es.status.filterQuery: "-(metadata.hostname:stormcrawler.net)"

  # time in secs for which the URLs will be considered for fetching after a ack of fail
  es.status.ttl.purgatory: 30

  # Min time (in msecs) to allow between 2 successive queries to ES
  es.status.min.delay.queries: 2000

  es.status.max.buckets: 50
  es.status.max.urls.per.bucket: 2
  # field to group the URLs into buckets
  es.status.bucket.field: "metadata.hostname"
  # field to sort the URLs within a bucket
  es.status.bucket.sort.field: "nextFetchDate"
  # field to sort the buckets
  es.status.global.sort.field: "nextFetchDate"

  # Delay since previous query date (in secs) after which the nextFetchDate value will be reset
  es.status.reset.fetchdate.after: -1

  # CollapsingSpout : limits the deep paging by resetting the start offset for the ES query 
  es.status.max.start.offset: 500

  # AggregationSpout : sampling improves the performance on large crawls
  es.status.sample: false

  # AggregationSpout (expert): adds this value in mins to the latest date returned in the results and
  # use it as nextFetchDate
  es.status.recentDate.increase: -1
  es.status.recentDate.min.gap: -1

  topology.metrics.consumer.register:
       - class: "com.digitalpebble.stormcrawler.elasticsearch.metrics.MetricsConsumer"
         parallelism.hint: 1
         #whitelist:
         #  - "fetcher_counter"
         #  - "fetcher_average.bytes_fetched"
         #blacklist:
         #  - "__receive.*"

1) Should I use AggreationsSpout or CollapsingSpout, what is the difference? I tried AggregationSpout, but performance was equal to performance of 1 machine with default configuration.

顾名思义,AggregationSpout 使用聚合作为按主机(或域或 IP 或其他)对 URL 进行分组的机制,而 CollapsingSpout 使用 collapsing。如果您将其配置为每个桶 (es.status.max.urls.per.bucket) 超过 1 URL,后者可能会更慢,因为它会为每个桶发出子查询。 AggregationSpout 应该具有良好的性能,尤其是当 es.status.sample 设置为 true 时。 CollapsingSpouts 在这个阶段是实验性的。

2) Is this configuration of parallelism correct?

这可能比需要的 JSoupParserBolts 多。实际上,与 Fetcherbolt 相比 1:4 的比率即使有 500 个获取线程也很好。 Storm UI 对于发现瓶颈和哪些组件需要扩展很有用。其他一切看起来都不错,但实际上,您应该查看 Storm UI 和指标,以将拓扑调整为最适合您抓取的设置。

3) I found that "FETCH ERROR" increased by ~20% and lot of sites not fetched properly, when I jumped from 1 node to 5 node configuration. What could be the reason?

这可能表明您正在使网络连接饱和,但在使用更多节点时情况不应如此,相反。也许检查 Storm UI FetcherBolts 如何分布在节点上。一个工人 运行 所有的实例还是他们都得到相同的数量?查看日志以查看发生了什么,例如是否有大量超时异常?