You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

关于AWS Kinesis中TRIM_HORIZON、LATEST与checkpoint关联的确认请求

Verifying Kinesis TRIM_HORIZON/LATEST & Checkpoint Behavior

Great question — I’ve spent a ton of time troubleshooting Kinesis consumer behavior, and your theory lines up perfectly with how the service actually works. Let me break this down with clear, actionable details:

TRIM_HORIZON: What Actually Happens

  • New application name: The consumer starts reading from the oldest available record in the stream (the "trim horizon," set by your stream's data retention period, default 24 hours). You’ll get every record currently stored in the stream, no exceptions.
  • Existing application name: Kinesis prioritizes the last saved checkpoint for that application name (tied to the stream and individual shards). The consumer resumes reading immediately after the checkpointed sequence number — the TRIM_HORIZON setting is effectively ignored here because the checkpoint takes precedence.

LATEST: What Actually Happens

  • New application name: The consumer only pulls records that are added to the stream after the consumer initializes. All existing records in the stream are skipped entirely.
  • Existing application name: Again, the checkpoint wins. The consumer picks up right where it left off at the last checkpointed position, not from the latest incoming records.

Edge Case to Watch For

If the last checkpointed sequence number for your application has been trimmed from the stream (i.e., it’s older than the stream’s retention period), the consumer will fall back to your configured initial position (TRIM_HORIZON or LATEST) for that shard. This is a gotcha that trips up a lot of folks!

Here’s a quick code snippet to illustrate how this ties into KCL configuration (the most common way to consume Kinesis streams):

// KCL Consumer Config Example
KinesisClientLibConfiguration consumerConfig = new KinesisClientLibConfiguration(
    "my-stream-consumer-app", // This name drives checkpoint tracking
    "my-production-kinesis-stream",
    DefaultAWSCredentialsProviderChain.getInstance(),
    "worker-instance-123"
).withInitialPositionInStream(InitialPositionInStream.LATEST);

内容的提问来源于stack exchange,提问作者Ida Amit

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 09:09:38