[KongchangAI]
· 1 min read· 954 words

Coalescing Small Writes on Object Storage: Optimization Strategies and Practices

Coalescing Small Writes on Object Storage: Optimization Strategies and Practices

Coalescing small writes on object storage reduces request overhead and metadata bottlenecks, but requires balancing latency and consistency.

Object storage is billed per object and each PUT request incurs overhead. Frequent small writes increase request costs, make metadata operations a bottleneck, and reduce storage efficiency. Based on a Hacker News discussion, this article analyzes the necessity and common strategies for coalescing small writes: client-side or middle-layer buffered batch uploads, and using multipart upload to merge small fragments. Although coalescing can improve throughput and reduce costs, it also brings issues such as write path complexity, buffer persistence and failure recovery, and the need to filter redundant data during reads, and may not be suitable for strong-consistency or low-latency scenarios. Practical recommendations suggest customizing coalescing strategies based on write patterns, latency requirements, cost models, and tool support to balance request overhead and consistency latency.

Object storage has become the go-to choice for storing unstructured data in cloud-native applications, but it was originally designed for high-throughput access to large blocks of data. When applications frequently produce small writes, performance bottlenecks and cost issues become prominent. Based on the Hacker News discussion on "Coalescing small writes on object storage," this article provides an in-depth analysis of the necessity, implementation strategies, and trade-offs of coalescing small writes.

Hacker News discussion screenshot

Why Do Small Writes Become a Problem?

Object storage (such as S3, GCS, OSS) is typically billed per object, and each PUT request incurs overhead. Small writes mean many small objects and frequent API calls, which not only increases request costs but may also make metadata operations a bottleneck. In addition, small objects reduce storage efficiency and affect the performance of subsequent data analysis or backups.

From a system perspective, the underlying architecture of object storage is optimized for large contiguous reads and writes, and small writes amplify network latency and disk seek overhead. Therefore, coalescing small writes into larger objects is a common means of improving throughput and reducing costs.

The billing model of object storage typically consists of three parts: storage capacity fees, request fees (billed by the number of operations such as PUT/GET), and data transfer fees. In small-write scenarios, request fees can far exceed storage fees—for example, writing a 1KB object and writing a 1MB object consume the same PUT request, but the former's storage cost is only one-thousandth of the latter's while the request cost is the same. In addition, the metadata service of object storage (such as S3's index layer) needs to maintain information such as keys, sizes, and timestamps for each object, and high-frequency small-object writes amplify the load of metadata operations, becoming a throughput bottleneck. From the perspective of the underlying architecture, object storage is optimized for large contiguous I/O, and small writes increase the number of network round trips and frequent disk seeks, further reducing effective throughput.

Coalescing Strategies: Buffering and Batch Processing

A direct approach is to introduce a buffer at the client or middle layer, accumulating multiple small writes to a certain size or time window before uploading them as a single large object. This is similar to log-structured merging in traditional file systems. When implementing this, latency and throughput must be balanced: the larger the buffer, the better the coalescing effect, but the higher the data visibility latency.

Another strategy is to leverage the multipart upload feature of object storage, first writing small fragments to temporary storage and finally merging them. However, multipart upload itself has a minimum part size limit, and the merge operation may incur additional costs.

Multipart Upload is a sharded upload mechanism provided by object storage: the client splits a large object into multiple parts and uploads them in parallel, finally merging them into a single object through a complete request. This mechanism was originally intended for efficient transfer of large files, but it can also be used in reverse for coalescing small writes—uploading multiple small fragments as parts to temporary storage first, then merging them into a single object. It should be noted that cloud providers impose minimum limits on part size (for example, S3 requires each part except the last to be at least 5MB), and multipart upload itself incurs additional request fees, while incomplete parts may also incur storage fees. Therefore, when using multipart upload for coalescing small writes, the balance between part granularity and cost must be evaluated.

Trade-offs and Challenges

Coalescing small writes is not without cost. First, it increases the complexity of the write path, requiring handling of buffer persistence and failure recovery. Second, the coalesced object may contain data that is no longer needed, requiring additional filtering during reads. In addition, if the application requires strong consistency or low-latency reads, coalescing may not be applicable.

In the Hacker News discussion, some viewpoints pointed out that coalescing strategies should be customized according to workload characteristics. For example, log-type applications can tolerate higher latency and are suitable for batch coalescing, while interactive applications may prefer to write small objects directly.

Practical Recommendations

For scenarios that need to handle small writes, it is recommended to evaluate the following aspects:

  • Write pattern: Is it predictable? Can it be aggregated at the application layer?
  • Latency requirements: How much write latency can the business tolerate?
  • Cost model: The balance point between request fees and storage fees.
  • Tool support: Are there mature coalescing libraries or middleware available?

In summary, coalescing small writes on object storage is an optimization problem that needs to be designed in conjunction with specific scenarios. Through reasonable buffering and batching strategies, request overhead can be significantly reduced, but the trade-off between consistency and latency must be handled carefully.

One-line Summary

Coalescing small writes on object storage can reduce request overhead and metadata bottlenecks, but latency and consistency must be traded off.

Paragraph Summary

Object storage is billed per object and each PUT request incurs overhead. Frequent small writes increase request costs, make metadata operations a bottleneck, and reduce storage efficiency. Based on a Hacker News discussion, this article analyzes the necessity and common strategies for coalescing small writes: client-side or middle-layer buffered batch uploads, and using multipart upload to merge small fragments. Although coalescing can improve throughput and reduce costs, it also brings problems such as write path complexity, buffer persistence and failure recovery, and the need to filter redundant data during reads, and may not be suitable for strong-consistency or low-latency scenarios. Practical recommendations suggest customizing coalescing strategies based on write patterns, latency requirements, cost models, and tool support to strike a balance between request overhead and consistency latency.

#object storage#small write coalescing#multipart upload#buffered batch processing#cloud storage optimization
Share:

Related articles