When Kafka applications generate thousands or millions of events, storing all records in a few large S3 directories can make data management difficult. Developers often need to retrieve records for a particular day, hour, or smaller time window. Without a suitable directory structure, queries may scan more data than necessary, and downstream processing becomes harder to manage.
The Amazon S3 Sink connector for Confluent Cloud provides a TimeBasedPartitioner that organizes Kafka records into time-based directories. In addition to daily and hourly partitioning, developers can define a custom interval in milliseconds.
For example, an application that produces financial transactions may need to organize records into 15-minute intervals. A monitoring application may prefer 30-minute folders, while an event-processing system may need smaller time windows for frequent analysis.
The custom time interval option makes these layouts possible without writing a custom Kafka Connect partitioner.
This article explains how time-based partitioning works, how to configure custom intervals in the Confluent Cloud S3 Sink connector, and how to choose suitable settings for production workloads.
Understanding Time-Based Partitioning in Kafka
Apache Kafka stores records in topics, and each topic contains one or more partitions. Kafka partitions help distribute records across brokers and allow consumers to process data in parallel.
However, Kafka's partition structure does not automatically provide the time-based directory layout that many data platforms need in object storage.
Consider an application that publishes customer activity events to a Kafka topic named customer-events. The records may contain information such as:
{
"eventId": "evt-1001",
"customerId": "C1024",
"eventType": "purchase",
"amount": 2499.00,
"eventTimestamp": "2026-12-03T10:15:30Z"
}
The S3 Sink connector consumes these records and writes them as objects in an Amazon S3 bucket.
Without time-based partitioning, the connector can organize files according to Kafka topic partitions. With TimeBasedPartitioner, it can organize records into directories based on their timestamps.
For example, an hourly layout might look like this:
s3://company-data/
customer-events/
year=2026/
month=12/
day=03/
hour=10/
customer-events+0+100.avro
customer-events+1+200.avro
A custom interval can create more granular directories, depending on the configured duration and path format.
The main benefit is that downstream applications can locate data for a specific time range without scanning unrelated directories.
Understanding the Three S3 Sink Partitioners
The Confluent Cloud S3 Sink connector supports three partitioner classes.
Partitioner | How it organizes records | Typical use |
|---|
DefaultPartitioner | Uses Kafka topic partition numbers | Preserving Kafka partition organization |
FieldPartitioner | Uses selected record field values | Organizing data by customer, region, or category |
TimeBasedPartitioner | Uses timestamps to create time-based directories | Event archives, analytics, and historical data |
DefaultPartitioner is useful when the Kafka partition structure is sufficient for downstream processing. It creates a directory for each Kafka topic partition.
FieldPartitioner is useful when the directory structure should reflect record attributes. For example, records can be grouped by region or department.
TimeBasedPartitioner is different because it groups records according to time intervals. Developers can choose daily, hourly, or custom intervals.
For this article, the focus is on TimeBasedPartitioner and its custom interval configuration.
How Custom Time-Based Partitioning Works
The TimeBasedPartitioner uses a timestamp to determine the time bucket into which a Kafka record belongs.
The connector then creates an S3 directory based on the configured path format.
For example, consider a custom interval of 15 minutes. Records with timestamps between 10:00 and 10:14:59 belong to one time bucket, while records between 10:15 and 10:29:59 belong to another.
The resulting directory structure could look like this:
s3://company-data/
customer-events/
dt=2026-12-03/
hr=10/
min=00/
event-files
min=15/
event-files
min=30/
event-files
min=45/
event-files
The exact directory layout depends on the configured path format.
It is important to understand that partition duration and file rotation are related but different settings.
Partition duration determines the time bucket used to organize records. File rotation determines when the connector closes and uploads an S3 object.
A single time-based directory can contain multiple files. The connector does not necessarily create exactly one S3 object for each time interval.
Configuring a Custom Time Interval in Confluent Cloud
Before configuring the connector, prepare the following resources:
An active Confluent Cloud Kafka cluster.
A Kafka topic containing the records to export.
An Amazon S3 bucket in the same AWS region as the Confluent Cloud cluster.
An AWS IAM configuration that allows the connector to write to the bucket.
Kafka credentials or a service account with the required topic permissions.
Schema Registry, if the input records use Avro, JSON Schema, or Protobuf.
For production deployments, use a dedicated Confluent Cloud service account rather than broad personal account credentials.
Create the S3 Sink connector
Open the Confluent Cloud console and follow these steps:
Select the Kafka cluster that contains your source topic.
Open Connectors from the navigation menu.
Select Add connector.
Search for Amazon S3 Sink.
Select the Kafka topic that contains the records.
Configure Kafka authentication.
Select the AWS region and configure S3 authentication.
Enter the destination S3 bucket name.
Continue to the connector configuration section.
The connector supports AWS access keys and IAM role-based authentication through Confluent Provider Integration. Use the authentication method that matches your organization's security requirements.
Select the partitioner
In the connector configuration section, find Partitioner Class and select:
TimeBasedPartitioner
This tells the connector to organize records according to timestamps instead of Kafka partition numbers or record field values.
The connector then exposes time-related configuration options, including Time interval, Path format, Timezone, and Partition duration.
Select a custom time interval
Choose CUSTOM for the Time interval setting.
The Partition duration (ms) field specifies the length of each time bucket in milliseconds.
For a 15-minute interval, calculate the duration as follows:
[
15 \times 60 \times 1000 = 900000
]
Enter:
900000
The supported custom duration must meet these requirements:
Setting | Requirement |
|---|
Minimum duration | 60,000 milliseconds |
Maximum duration | 86,400,000 milliseconds |
Required increment | Multiple of 30,000 milliseconds |
Example | 900,000 milliseconds for 15 minutes |
This means the connector supports custom intervals starting at one minute and extending up to 24 hours, subject to the 30-second increment requirement.
A few examples are shown below.
Interval | Duration in milliseconds |
|---|
1 minute | 60000 |
5 minutes | 300000 |
10 minutes | 600000 |
15 minutes | 900000 |
30 minutes | 1800000 |
45 minutes | 2700000 |
1 hour | 3600000 |
2 hours | 7200000 |
6 hours | 21600000 |
12 hours | 43200000 |
24 hours | 86400000 |
The connector rejects values outside the supported range or values that do not satisfy the required increment.
Configuring the S3 Directory Structure
The Path format setting controls how time-based directories are named.
For example, the following path format creates directories based on date, hour, and minute:
'dt'=YYYY-MM-dd/'hr'=HH/'min'=mm
With a 15-minute interval, the resulting S3 structure can look like this:
s3://company-data/
customer-events/
dt=2026-12-03/
hr=10/
min=00/
min=15/
min=30/
min=45/
The directory names are generated from the timestamp used by the partitioner.
You can also use a simpler structure if the application only needs hourly organization:
'year'=YYYY/'month'=MM/'day'=dd/'hour'=HH
For custom intervals that are not whole hours, include the minute pattern in the path format. If the duration is not a whole number of minutes, include a seconds pattern as well.
For example, a 90-second interval can use:
'dt'=YYYY-MM-dd/'hr'=HH/'min'=mm/'sec'=ss
The format should provide enough detail to distinguish the time buckets. Otherwise, different intervals may map to directory names that do not represent the intended granularity.
Configure the timezone
The Timezone setting determines how timestamps are interpreted and formatted in the S3 directory structure.
For example:
UTC
or:
Asia/Kolkata
Using UTC is often a good choice for systems that process events from multiple regions. It avoids differences caused by local time zones and daylight-saving changes.
If the business requires reports based on a particular regional timezone, configure that timezone consistently and verify the resulting directory names.
Do not assume that changing the timezone changes the original timestamp stored in the Kafka record. It affects how the time-based partitioner interprets and formats the timestamp for partitioning.
Choosing the Timestamp Used for Partitioning
Selecting a custom duration is only part of the configuration. The connector must also know which timestamp to use.
The Timestamp source setting determines how the connector obtains the timestamp.
The main choices are:
Timestamp source | Description | Suitable scenario |
|---|
Record | Uses the Kafka record timestamp by default, or the configured timestamp field when provided | Event-time processing |
Wallclock | Uses the system time when the connector processes the record | Ingestion-time organization |
Using the Kafka record timestamp
When Timestamp source is set to Record and no timestamp field name is provided, the connector uses the timestamp associated with the Kafka record.
This is useful when Kafka producer timestamps accurately represent the event time required by downstream applications.
For example, a producer may publish an event at 10:15 UTC. The connector uses that timestamp to determine the corresponding time bucket.
Using a timestamp field from the record
Some applications include their own event timestamp in the record value.
For example:
{
"eventId": "evt-1002",
"customerId": "C1025",
"eventType": "payment",
"eventTimestamp": 1796292930000
}
If this field contains a valid timestamp in the expected format, configure Timestamp source as Record and set Timestamp field name to:
eventTimestamp
The connector then uses the configured record field to determine the time partition.
Make sure the field exists in the incoming records and that its values are consistent. A missing or incorrectly formatted timestamp can prevent the connector from processing the affected record correctly.
Using ingestion time
If the application does not have a reliable event timestamp, Wallclock can be useful.
For example, a record may be created at 10:00 but reach the connector at 10:20 because of a processing delay.
With Wallclock, the record is assigned according to the time it is processed by the connector rather than the original event time.
This is useful when the storage requirement is based on ingestion time instead of when the business event actually occurred.
The choice matters when records arrive late or are replayed from Kafka.
Understanding File Rotation and Flush Size
One of the most common configuration mistakes is assuming that a custom time interval controls the exact time at which every S3 file is uploaded.
It does not.
The connector uses several conditions to determine when files should be closed and uploaded.
Flush size
The flush.size setting controls the number of records written before the connector flushes data to storage.
For Confluent Cloud, the default flush size is 1000 records. The minimum is 1000 for non-dedicated clusters, while dedicated clusters support a lower minimum.
For example, if a Kafka partition receives 1000 records within a time bucket, the connector can upload the file when the configured flush threshold is reached.
Rotation interval
The rotate.interval.ms setting controls the maximum time span of records in an open file.
It is useful when the application needs to limit how long a file remains open as records arrive.
Scheduled rotation
The rotate.schedule.interval.ms setting controls scheduled file rotation.
For example, a value of 600000 represents a 10-minute rotation schedule.
The connector uses the configured flush and rotation conditions together. When one of the applicable conditions is met, the file can be closed and uploaded.
Consider this example:
Setting | Value |
|---|
Time interval | CUSTOM |
Partition duration | 900000 ms |
Flush size | 1000 |
Scheduled rotation | 600000 ms |
Suppose 500 records arrive during a 10-minute period. The scheduled rotation condition can cause the connector to upload the file before the flush size reaches 1000.
This can produce multiple smaller files inside the same time-based directory.
Why this distinction matters
Partitioning controls where records are stored. Rotation controls when files are uploaded.
If a team wants 15-minute directories but also needs files to become available every five minutes, it can configure the time partition duration and rotation interval separately.
However, frequent rotation can increase the number of small files. Choose settings based on the expected event volume and downstream query requirements.
Example: Exporting Customer Events Every 15 Minutes
Consider an application that produces customer activity events continuously.
The requirement is to store these records in Amazon S3 using 15-minute time buckets so that analytics jobs can process recent data without scanning an entire day's worth of events.
A suitable starting configuration is:
Configuration | Value |
|---|
Connector | Amazon S3 Sink |
Topic | customer-events |
Output format | PARQUET |
Partitioner Class | TimeBasedPartitioner |
Time interval | CUSTOM |
Partition duration | 900000 |
Path format | 'dt'=YYYY-MM-dd/'hr'=HH/'min'=mm |
Timezone | UTC |
Timestamp source | Record |
Timestamp field name | eventTimestamp |
Flush size | 1000 |
The timestamp field must contain a valid value that the connector can use for time-based partitioning.
With this configuration, records are organized into directories representing 15-minute periods.
For example:
s3://company-data/
customer-events/
dt=2026-12-03/
hr=10/
min=00/
files
min=15/
files
min=30/
files
min=45/
files
hr=11/
min=00/
min=15/
The actual number of files depends on the number of Kafka topic partitions, flush size, rotation settings, and incoming record volume.
The layout is also useful for downstream analytics engines that can filter data using date and time partition columns.
Handling Late-Arriving Kafka Records
Late-arriving records are an important consideration when using event-time partitioning.
Suppose an application creates an event at 10:05, but the connector does not receive it until 10:40.
If the connector uses the event timestamp, the record belongs to the 10:00 time bucket, even though it arrives later.
This is expected behavior when event time is the source of truth.
However, late records can cause the connector to write data into an earlier time-based directory after files for that period have already been uploaded.
Downstream systems must therefore avoid assuming that a time-based directory is permanently complete as soon as its time window ends.
For applications with frequent late events, consider the following:
Use a consistent event timestamp generated by the producer.
Monitor Kafka consumer lag and connector processing delays.
Allow downstream jobs to process recently modified time partitions again.
Use ingestion timestamps when the requirement is based on arrival time.
Define a retention and reprocessing strategy for historical data.
The correct approach depends on whether the application cares more about when an event occurred or when the storage system received it.
Custom Time-Based Partitioning Versus Field Partitioning
Developers sometimes confuse time-based partitioning with FieldPartitioner because both create custom directory structures.
However, they solve different problems.
FieldPartitioner groups records by the values of selected record fields. For example, it can create directories for different regions:
s3://company-data/
customer-events/
region=India/
region=USA/
region=UK/
TimeBasedPartitioner groups records according to time:
s3://company-data/
customer-events/
dt=2026-12-03/
hr=10/
min=15/
If the application needs both time and business-category organization, consider whether the required structure can be achieved through the supported connector configuration. The Confluent Cloud connector exposes different partitioner classes, and its managed configuration should not be treated as an unrestricted custom partitioner implementation.
Choose the partitioner based on the primary access pattern of downstream applications.
Best Practices for Production Workloads
Custom time-based partitioning can improve data organization, but an unsuitable interval can create unnecessary storage objects or make queries less efficient.
Consider these practices before deploying the connector.
Choose the interval based on data volume
A one-minute interval may be appropriate for a high-volume event stream, but it can create too many directories and small files for a low-volume application.
For lower-volume systems, hourly or daily partitioning may be more practical.
Estimate the number of records arriving during each interval before selecting a custom duration.
Avoid creating too many small files
A large number of small S3 objects can increase listing and query overhead. It can also make downstream data processing less efficient.
Use flush size and rotation settings to balance file availability with file size.
Use consistent timestamp formats
The timestamp field should be populated consistently across all records. If different producers use different formats or timezones, records may end up in unexpected directories.
Use a clearly defined timestamp contract and validate it before publishing events to Kafka.
Prefer UTC for multi-region systems
UTC simplifies time-based partitioning when records originate from different countries or regions.
If regional reporting requires local time, document the chosen timezone and consider daylight-saving transitions.
Monitor connector health
Monitor connector status, consumer lag, failed records, and S3 upload errors.
A correctly configured partitioner cannot compensate for a connector that is unable to consume records or write to the destination bucket.
Test late events and reprocessing
Send records with older timestamps and verify where they are stored. Also test connector restarts and replay scenarios to confirm that the resulting S3 objects meet downstream processing requirements.
Common Mistakes and Troubleshooting
Problem | Possible cause | Recommended action |
|---|
Custom interval is rejected | Duration is below one minute, above 24 hours, or not a multiple of 30 seconds | Validate the duration in milliseconds |
All records appear in the wrong time folder | Incorrect timestamp source or timezone | Review Timestamp source, field name, and timezone |
Minute-level folders are missing | Path format does not include minutes | Add the minute pattern to Path format |
Files are smaller than expected | Flush size or rotation condition is reached early | Review flush and rotation settings |
Late events appear in older folders | Event-time partitioning is being used | Decide whether event time or ingestion time is required |
Connector cannot write to S3 | Missing AWS permissions or incorrect authentication | Review IAM permissions and provider integration |
Some records fail during processing | Missing or invalid timestamp values | Validate the timestamp field and inspect connector errors |
When troubleshooting, check the connector configuration and logs before changing multiple settings at once. A small controlled test with records containing known timestamps is often the fastest way to confirm that partitioning works as expected.
Advantages and Disadvantages
Advantages | Disadvantages |
|---|
Organizes records into predictable time-based directories | Small intervals can create many directories and files |
Supports custom intervals from one minute to 24 hours | Requires correct timestamp configuration |
Helps downstream analytics filter data by time | Late-arriving records may update older time partitions |
Does not require a custom partitioner implementation | File rotation must be configured separately |
Supports daily, hourly, and custom time layouts | Poorly chosen intervals can increase query overhead |
The main advantage is that developers can control the S3 directory layout without maintaining custom Kafka Connect code. The main challenge is choosing the right interval and managing file sizes as data volume changes.
Conclusion
The Confluent Cloud Amazon S3 Sink connector provides flexible time-based partitioning for Kafka records. With TimeBasedPartitioner, developers can organize data into daily, hourly, or custom time intervals without building a separate partitioner.
The custom interval setting is particularly useful for event-driven applications that need more control over how records are stored in Amazon S3. A 15-minute interval, for example, can provide a practical balance between data organization and downstream processing requirements.
For production workloads, the important decisions are the timestamp source, partition duration, path format, timezone, flush size, and file rotation settings. These options work together, but they control different parts of the storage process.
A well-designed partition structure makes historical data easier to locate, reduces unnecessary data scanning, and provides a more manageable foundation for analytics and data lake workloads.
Join the conversation! Your thoughts help the community grow.