首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何减缓卡夫卡制作人的写作速度?

如何减缓卡夫卡制作人的写作速度?
EN

Stack Overflow用户
提问于 2019-11-01 08:30:19
回答 2查看 569关注 0票数 0

我用这种方式向卡夫卡写数据。

df.write()格式(“kafka”)保存()

我能控制卡夫卡的写作速度以避免对卡夫卡的压力吗?有什么办法可以帮助减慢速度吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-11-01 11:35:28

我认为将linger.ms设置为非零值会有帮助。因为它控制在发送当前批之前等待其他消息的时间。代码可以如下所示

代码语言:javascript
复制
df.write.format("kafka").option("linger.ms", "100").save()

但这取决于很多事情。如果你的卡夫卡足够大,配置得当,我不会太担心速度。毕竟,卡夫卡就是为了应对这种情况而设计的(交通高峰)。

票数 0
EN

Stack Overflow用户

发布于 2019-11-04 09:56:28

一般情况下,结构化流将尝试在默认情况下尽可能快地处理数据。每个源中都有允许控制处理速率的选项,例如文件源中的maxFilesPerTrigger和卡夫卡源中的maxOffsetsPerTrigger。

代码语言:javascript
复制
val streamingETLQuery = cloudtrailEvents
  .withColumn("date", $"timestamp".cast("date") // derive the date
  .writeStream
  .trigger(ProcessingTime("10 seconds")) // check for files every 10s
  .format("parquet") // write as Parquet partitioned by date
  .partitionBy("date")
  .option("path", "/cloudtrail")
  .option("checkpointLocation", "/cloudtrail.checkpoint/")
  .start()

val df = spark.readStream
  .format("text")
  .option("maxFilesPerTrigger", 1)
  .load("text-logs")

有关更多详细信息,请阅读下列链接:

https://jaceklaskowski.gitbooks.io/spark-structured-streaming/spark-sql-streaming-KafkaSource.html https://jaceklaskowski.gitbooks.io/spark-structured-streaming/spark-sql-streaming-FileStreamSource.html https://databricks.com/blog/2017/01/19/real-time-streaming-etl-structured-streaming-apache-spark-2-1.html http://spark.apache.org/docs/latest/structured-streaming-programming-guide.html#input-sources http://spark.apache.org/docs/latest/structured-streaming-kafka-integration.html

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58656194

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档