AWS Training
Modules Listen Certification

← Data Engineer IV — Role Review

Starts this lesson and continues through 10 more to the end of the course.

Streaming with Confluent Kafka — source and sink connectors

Why a Connect question is really a "where did my record go" question

A record left Postgres, landed in a topic, and either never reached S3, reached it twice, or reached it in an object Athena can't read. The engineer who can name which component decided that — source task, converter, partitioner, rotation rule, or offset commit — gets hired. This lesson is that component map, with the knobs that control each one.

What the posting is really asking

"Implement real-time data streaming solutions using Confluent Kafka with source and sink connectors"

Translated: stand up a CDC source (database → topics), a storage sink (topics → S3), choose serialization the lake can read, and explain the delivery guarantee you are actually getting. The follow-up is always "why Confluent Cloud and not MSK?" — hence the table at the end.

Kafka Connect architecture

From Connect concepts (verified 2026-10-30):

Piece What it is The sentence to say in an interview
Connector (instance) "a logical job that manages the copying of data between Kafka and another system" The connector plans; it does not move bytes
Task "the main actors in the data model" — a connector "break[s] a single job into many tasks" Tasks move the bytes; "tasks themselves store no state"
Worker "the running processes that execute connectors and tasks" — two types, standalone and distributed A JVM; add workers to add capacity
Converter "change the format of data from bytes to a Connect internal data format and vice versa" Decoupled from the connector, so one Avro converter serves every connector
Transform (SMT) "a simple function that accepts one record as an input and outputs a modified record"; can be chained Per-record only — anything multi-record belongs in ksqlDB / Kafka Streams
Dead Letter Queue "only applicable for sink connectors" Routes invalid records to a topic instead of failing the task

Standalone vs distributed. Standalone is "a single process … responsible for executing all connectors and tasks" — for dev and tests. Distributed mode starts "many worker processes using the same group.id"; "behind the scenes, Connect workers use consumer groups to coordinate and rebalance". A rebalance happens when a connector is submitted, when task counts change, when config changes, or when a worker fails.

⚠️ A failed task does not trigger a rebalance and is not auto-restarted on self-managed Connect: "the framework does not restart failed tasks; restart them using the REST API". If your alerting only watches connector state, a dead task sits silently until someone looks.

Distributed workers share three internal topics, and every worker in a cluster must agree on them (user guide, verified 2026-10-30):

group.id
config.storage.topic
offset.storage.topic
status.storage.topic

"Connect clusters cannot share group IDs or internal topics." And because "Connect creates a consumer group based on the connector name", connector names must be unique across Connect clusters on one Kafka cluster.

Fully managed (Confluent Cloud) vs self-managed Connect

Confluent Cloud ships "pre-built, fully managed" connectors with "elastic scaling with no infrastructure to manage". The trade is control: no plugin.path, no converter class names, no worker properties — you pick input.data.format / output.data.format enums and the service picks the converter (cc-s3-sink). Cloud sinks also "autogenerate the DLQ topic"; on Platform you create it.

The Amazon S3 Sink connector

Source: S3 Sink overview and configuration reference, verified 2026-10-30.

Self-managed class: connector.class=io.confluent.connect.s3.S3SinkConnector. Object names encode "the topic, the Kafka partition, and the start offset of this data chunk":

<prefix>/<topic>/partition=<kafkaPartition>/<topic>+<kafkaPartition>+<startOffset>.<format>

Partitioners (partitioner.class)

Partitioner Encoded partition in the key Deterministic?
io.confluent.connect.storage.partitioner.DefaultPartitioner <topic>/partition=<kafkaPartition> Always
…FieldPartitioner (partition.field.name, STRUCT values only) <topic>/<fieldName>=<fieldValue> Always
…TimeBasedPartitioner (path.format, partition.duration.ms, locale, timezone, timestamp.extractor) e.g. year=YYYY/month=MM/day=dd/hour=HH Only with timestamp.extractor=Record or RecordField
…DailyPartitioner / …HourlyPartitioner TimeBased with preset path.format and duration 86400000 / 3600000 ms Same rule

timestamp.extractor values: Wallclock (the default — system time at processing), Record (broker/producer timestamp), RecordField (field named by timestamp.field).

Rotation — when a file closes

Property Behaviour (quoted) Default
flush.size "maximum number of records that should be written to a single S3 object. There is no default for this setting." (self-managed) none; Cloud: 1000
rotate.interval.ms file timespan "starts with the record timestamp of the first record written to the file"; rotate when the next record doesn't fit -1 (disabled)
rotate.schedule.interval.ms timespan "starts with the system time"; commit "at the scheduled time, regardless of the previous commit time or number of messages" -1 (disabled)
s3.part.size multipart upload part size 26214400 (25 MB)
schema.compatibility NONE | BACKWARD | FORWARD | FULL; a schema change also rotates the file NONE

"Rotation occurs whenever any of the strategies signals a rotation."

⚠️ rotate.interval.ms alone can leave a file open indefinitely: "if the connector has no more records to process, the connector may keep the file open until the connector can process another record (this can be a long time)". Low-volume topics need rotate.schedule.interval.ms — and "set the timezone configuration property before setting rotate.schedule.interval.ms. If timezone is not set, the connector throws an exception."

Exactly-once, as documented — and the trap

"Records that are exported using a deterministic partitioner are delivered with exactly-once semantics regardless of the eventual consistency of S3." Mechanism: deterministic partitioners "split files always at the same offsets for a given set of Kafka records", so a re-upload after a crash-before-offset-commit produces the same object, and "is transparent to the user of the S3 bucket".

⚠️ "Setting rotate.schedule.interval.ms is nondeterministic and will invalidate exactly-once guarantees." Wallclock extraction does the same. So the two settings people reach for to make low-volume topics flush on time are exactly the two that downgrade you to at-least-once. Pick one: timely files or exactly-once files. Say that out loud in the interview.

Cloud S3 sink: the JSON Confluent publishes

Copied from cc-s3-sink.html (verified 2026-10-30):

{
   "name" : "confluent-s3-sink-time",
   "connector.class": "S3_SINK",
   "kafka.auth.mode": "KAFKA_API_KEY",
   "kafka.api.key": "<my-kafka-api-key>",
   "kafka.api.secret": "<my-kafka-api-secret>",
   "aws.access.key.id" : "<my-aws-access-key>",
   "aws.secret.access.key": "<my-aws-access-key-secret>",
   "input.data.format": "JSON",
   "output.data.format": "JSON",
   "compression.codec": "JSON - gzip",
   "s3.compression.level": "6",
   "s3.bucket.name": "<my-bucket-name>",
   "partitioner.class": "TimeBasedPartitioner",
   "locale": "en",
   "timezone": "UTC",
   "time.interval" : "HOURLY",
   "flush.size": "1000",
   "tasks.max" : "1",
   "topics": "<topic-1>, <topic-2>"
}
confluent connect cluster create --config-file s3-sink-config.json

input.data.format accepts AVRO, JSON_SR, PROTOBUF, JSON, BYTES, STRING; output.data.format accepts AVRO, PARQUET, JSON, BYTES. Prefer PARQUET output for anything Athena/Redshift Spectrum reads (lesson 3). Authentication can instead use IAM roles via "Confluent Provider Integration" rather than static keys.

Cloud limits (limits.html, verified 2026-10-30): "One task can handle up to 100 partitions, but is limited to 1 partition when using FieldPartitioner." "flush.size defaults to 1000 … The value can be lowered (1 minimum) if you are running a Dedicated Confluent Cloud cluster. The minimum value is 1000 for non-dedicated clusters." ⚠️ I could not find a published per-cluster connector or total-task quota for Confluent Cloud on the pages fetched — check docs.confluent.io/cloud/current/connectors/limits.html before quoting one.

A CDC source: PostgreSQL CDC Source V2 (Debezium) on Confluent Cloud

Source: cc-postgresql-cdc-source-v2-debezium, verified 2026-10-30.

{
  "connector.class": "PostgresCdcSourceV2",
  "name": "PostgresCdcSourceV2Connector_0",
  "kafka.auth.mode": "KAFKA_API_KEY",
  "kafka.api.key": "****************",
  "kafka.api.secret": "****************************************************************",
  "database.hostname": "debezium-1.<host-id>.us-east-2.rds.amazonaws.com",
  "database.port": "5432",
  "database.user": "postgres",
  "database.password": "**************",
  "database.dbname": "postgres",
  "topic.prefix": "cdc",
  "slot.name": "dbz_slot",
  "publication.name": "dbz_publication",
  "table.include.list":"public.passengers",
  "output.data.format": "JSON",
  "tasks.max": "1"
}

Facts that matter:

Schema Registry and converters

From Schema Registry + Connect and serdes, verified 2026-10-30:

key.converter=io.confluent.connect.avro.AvroConverter
key.converter.schema.registry.url=http://localhost:8081
value.converter=io.confluent.connect.avro.AvroConverter
value.converter.schema.registry.url=http://localhost:8081

Swap the class for io.confluent.connect.protobuf.ProtobufConverter or io.confluent.connect.json.JsonSchemaConverter. Without a registry, use org.apache.kafka.connect.json.JsonConverter, StringConverter, or ByteArrayConverter.

The default wire format is a 5-byte prefix: byte 0 = version byte (0), bytes 1–4 = the 4-byte schema ID, then the payload. Subject names default to TopicNameStrategy.

⚠️ The S3 sink's schema evolution "only works if the records are generated with the default naming strategy, which is TopicNameStrategy"; with other strategies set schema.compatibility=NONE and expect "small object files because the sink connector creates a new file every time the schema ID changes".

Error handling: the dead letter queue

Sink connectors only. errors.tolerance is none (default — task fails) or all (Connect "ignores all errors … writes no errors to the worker log"). To capture rather than ignore:

errors.tolerance=all
errors.deadletterqueue.topic.name=dlq-s3-sink-01
errors.deadletterqueue.context.headers.enable=true

Headers are off by default; with them on, the DLQ record carries _connect.errors.* headers explaining the failure. On Confluent Cloud the DLQ "is automatically created" and the name defaults to dlq-${connector}.

⚠️ errors.tolerance=all without a DLQ topic is silent data loss by configuration.

Delivery semantics and ordering

From delivery semantics and introduction, verified 2026-10-30:

Confluent Cloud vs Amazon MSK + MSK Connect

MSK facts from what-is-msk, msk-connect, capacity, limits, verified 2026-10-30.

Dimension Confluent Cloud Amazon MSK + MSK Connect
Broker Fully managed, Confluent-operated "runs open-source versions of Apache Kafka"; Provisioned (Standard / Express brokers) or Serverless; ZooKeeper or KRaft
Connect runtime Fully managed connectors; custom connectors can be uploaded "Kafka Connect versions 2.7.1 or 3.7.x"; you upload a plugin ZIP to S3 as a custom plugin (the tutorial uses the Lenses S3 sink)
Capacity unit Tasks per connector (tasks.max) MCU = "1 vCPU of compute and 4 GiB of memory"; 1–8 vCPU per worker, autoscaling between min/max workers
Task restarts Connector-level auto-restart (Cloud) "Automatic restarting of Connect tasks"
Quotas S3 sink: 100 partitions/task; CDC: 1 task/connector (not adjustable) 100 custom plugins, 100 worker configs, 60 connect workers, 10 workers per connector — "To request higher quota … go to the Service Quotas console" (adjustable)
Brokers n/a (abstracted) 90 brokers/account; 30 per ZooKeeper cluster, 60 per KRaft cluster — adjustable
Schema Registry Built in ⚠️ not on the pages fetched — check AWS Glue Schema Registry docs before claiming
Network Provider Integration (IAM role) to reach S3 Workers "consume IP addresses in the customer-provided subnets"; PrivateLink to sources/sinks

Prefer Confluent Cloud when the connector catalogue and Schema Registry are the point; prefer MSK when data must stay in your VPC under your IAM and you already run open-source Kafka tooling.

Check yourself

  1. Which S3 sink setting makes small-topic files appear on time, and what does it cost you?
  2. A Connect task dies at 02:00 on self-managed Connect. What does the framework do?
  3. Postgres CDC on Cloud is too slow. Can you raise tasks.max to 4?
  4. errors.tolerance=all is set and the DLQ topic is empty. Does that prove nothing failed?
  5. Why must the CDC record key be the table primary key?
  6. How many workers can one MSK Connect connector have by default, and is it adjustable?
Answers
  1. rotate.schedule.interval.ms (needs timezone set). It is "nondeterministic and will invalidate exactly-once guarantees" — you drop to at-least-once for that connector.
  2. Nothing. "When a task fails, no rebalance occurs … the framework does not restart failed tasks; restart them using the REST API." The connector can still show RUNNING.
  3. No. The Cloud connector has "a limit of one task per connector (tasks.max: 1)". Split tables across multiple connectors instead.
  4. No. Only if errors.deadletterqueue.topic.name is set do failed records go anywhere; with tolerance all and no DLQ, Connect "writes no errors to the worker log". Compare source vs sink record counts.
  5. Ordering is guaranteed per partition, and same-key events go to the same partition. Without the PK as key, an UPDATE and the later DELETE for one row can land on different partitions and be applied out of order downstream.
  6. 10 workers per connector (60 connect workers per account). Adjustable — the page says to request higher quota via the Service Quotas console.

Teaching this section

← PreviousBatch ETL on AWS — Glue, EMR with PySpark, and LambdaNext →Query and warehouse — Athena and Redshift