Event streams work with object storage by using the storage as a durable, long-term archive (a "data lake") for the high-velocity data flowing through the stream. While the event stream handles real-time ingestion and immediate processing, object storage provides a cost-effective way to store every single event permanently for later analysis, auditing, or recovery. Produce latency refers to the time delay between when an event is generated by a source and when it is successfully acknowledged as written to the stream's broker.

What You'll Need

  • An event streaming platform (such as Apache Kafka, Amazon Kinesis, or Azure Event Hubs).
  • An object storage bucket (such as Amazon S3, Google Cloud Storage, or Azure Blob Storage).
  • A connector or sink agent (such as Kafka Connect or a custom producer application) to bridge the stream and the storage.
  • Proper IAM permissions or access keys allowing the streaming service to write objects to the storage bucket.

Step-by-Step

  1. Define Your Event Schema: Before sending data, establish a consistent format (like JSON or Avro). This ensures that when the data eventually lands in object storage, it is structured in a way that analytical tools can read without needing to guess the data types for every single file.
  2. Configure the Event Stream Broker: Set up your topics or shards. The broker acts as the temporary holding area. At this stage, you must decide on your retention policy. Since you are using object storage for long-term keeping, you can set a short retention period on the broker (e.g., 24 to 72 hours) to save on expensive high-speed disk costs.
  3. Set Up the Object Storage Bucket: Create a bucket in your cloud provider. Organize the bucket using a folder hierarchy based on time (e.g., /year=2026/month=12/day=05/hour=14/). This "partitioning" is critical because object storage is not a database; partitioning allows you to query specific time ranges without scanning the entire dataset.
  4. Deploy a Sink Connector: Install and configure a sink connector. This is the piece of software that "subscribes" to the event stream and writes the data to the object storage. You will need to provide the connector with the bucket name, the desired file format (Parquet is recommended for performance), and the batching criteria.
  5. Configure Batching and Flushing: You cannot write every single event as a separate file to object storage, as this would create millions of tiny files and crash the system's performance (the "small file problem"). Configure the connector to flush data to the bucket only when a certain size is reached (e.g., 128MB) or a certain time interval has passed (e.g., every 5 minutes).
  6. Validate the Data Pipeline: Produce a set of test events into the stream. Monitor the sink connector logs to ensure there are no permission errors. Check the object storage bucket to verify that files are appearing in the correct time-based folders and that the content matches the original events.
  7. Implement a Compaction Strategy: Over time, your object storage will fill with many small files from the flushing process. Set up a background process to "compact" these files—merging many small files into fewer, larger files—to optimize read speeds for your analytical tools.

Common Mistakes

One of the most frequent errors is failing to partition data by time. If you dump all events into a single root folder, any attempt to retrieve data from a specific day will require the system to list every single object in the bucket, which is slow and expensive. Always use a year/month/day/hour structure.

Another common mistake is ignoring the "small file problem." Developers often set the flush interval too low (e.g., every 10 seconds), resulting in thousands of tiny files. Object storage is optimized for large objects; too many small files increase the overhead of metadata requests and significantly slow down downstream data processing tasks like Spark or Presto queries.

Finally, many users forget to handle schema evolution. If you change the format of your event in the stream but don't update the way the object storage reads that data, your historical archives may become unreadable or cause your analysis scripts to crash when they encounter a field that didn't exist in older files.

Tips

Use a columnar storage format like Apache Parquet or ORC instead of raw JSON or CSV. Columnar formats compress data much more efficiently and allow analytical engines to read only the columns they need, which drastically reduces the amount of data transferred from object storage to the compute engine.

To manage costs, implement Object Lifecycle Management policies. For example, move data from "Standard" storage to "Infrequent Access" after 30 days, and then to "Archive/Glacier" after 90 days. This ensures you keep your data for compliance without paying top-tier storage prices for old events.

To reduce produce latency, tune your producer's batching settings. While larger batches improve throughput, they increase the time a single event spends waiting in the producer's buffer before being sent to the broker. Balance batch.size and linger.ms based on whether your application prioritizes immediate delivery or maximum efficiency.

Troubleshooting

If events are appearing in the stream but not in the object storage, first check the sink connector's health status. The most common cause is a "Permission Denied" error, meaning the service account used by the connector lacks s3:PutObject or equivalent permissions for the target bucket. Verify the IAM policy associated with the connector.

If you notice a massive lag between the event occurring and it appearing in storage, check your flush settings. If your batch size is set to 1GB but your data volume is low, the connector will wait until that 1GB is reached before writing the file. Lower the time-based flush interval (e.g., to 5 minutes) to ensure data is written regularly regardless of volume.

If the system is slowing down over time, check the number of files in your buckets. If you see millions of files under a single prefix, your compaction process has likely failed or was never implemented. You will need to run a manual merge job to combine those files into larger chunks to restore performance.

Frequently Asked Questions

What exactly is produce latency?

Produce latency is the time it takes for a producer to send a message to the event broker and receive an acknowledgment that the message was successfully received and persisted. It includes network transit time, broker processing time, and the time spent waiting for replicas to acknowledge the write.

Why not write directly from the producer to object storage?

Object storage is not designed for high-frequency, small writes; it would be prohibitively slow and expensive. An event stream acts as a high-speed buffer that collects these small writes and allows a connector to group them into large, efficient batches before saving them to storage.

Does object storage support real-time querying?

No, object storage is fundamentally for "at-rest" data. While you can query it using tools like Amazon Athena or Google BigQuery, these are not real-time. For real-time needs, you query the event stream itself; for historical trends, you query the object storage.

How does produce latency affect the end-user?

High produce latency can cause the source application to slow down or "backpressure" if the producer's internal buffer fills up. This means the app may freeze or drop events because it cannot hand them off to the streaming broker fast enough.

Can I change the data in object storage after it is written?

Object storage is generally immutable. You cannot edit a specific line in a file. To change data, you must read the object, modify it locally, and overwrite the entire object in the bucket, which is why careful initial partitioning is so important.