简体   繁体   English

如何在Kafka和Flink环境下测试性能?

[英]How performance can be tested in Kafka and Flink environment?

How is performance tested for Flink with kafka as input source.如何使用 kafka 作为输入源对 Flink 进行性能测试。 Also, recommend if any performance test tools are available for this case.另外,建议是否有任何性能测试工具可用于这种情况。

Flink includes metrics for both throughput (numRecordsInPerSecond and numRecordsOutPerSecond) and latency . Flink 包括吞吐量(numRecordsInPerSecond 和 numRecordsOutPerSecond)和延迟的指标

If you want to more carefully measure latency end-to-end, you can add a custom metric in a sink (or other terminal node) that compares timestamps in your events to the current time.如果您想更仔细地测量端到端的延迟,您可以在接收器(或其他终端节点)中添加自定义指标,将事件中的时间戳与当前时间进行比较。 That would look something like this:这看起来像这样:

public class LatencyMeasuringSink<T> extends RichSinkFunction<T> {
  private transient DescriptiveStatisticsHistogram eventTimeLag;
  private static final int EVENT_TIME_LAG_WINDOW_SIZE = 10_000;

  @Override
  public void open(Configuration parameters) throws Exception {
    super.open(parameters);

    eventTimeLag = getRuntimeContext().getMetricGroup().histogram("eventTimeLag",
            new DescriptiveStatisticsHistogram(EVENT_TIME_LAG_WINDOW_SIZE));
  }

  @Override
  public void invoke(T dataPoint, Context context) throws Exception {
    eventTimeLag.update(System.currentTimeMillis() - dataPoint.getTimeStampMs());
  }
}

You might want to configure your Kafka producer to put LogAppendTime timestamps in your events, and use those as the basis for comparison.您可能希望将 Kafka 生产者配置为将LogAppendTime时间戳放在您的事件中,并将其用作比较的基础。 This assumes, of course, that the clocks in the different machines involved are synchronized well enough for this measurement to be meaningful -- or you might run the tests on a single machine.当然,这假设所涉及的不同机器中的时钟同步得足够好,以使这种测量有意义——或者您可以在单台机器上运行测试。

FLIP-83: Flink End-to-end Performance Testing Framework may also be of interest. FLIP-83:Flink 端到端性能测试框架也可能引起关注。 This is work in progress.这是正在进行中的工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM