s3fs is significantly slower than boto3 for large file uploads

Open
#900 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
python
Domain
cloud, performance

Research direction

Start by running the standalone benchmark in the issue with the stated MinIO setup, comparing s3fs.write() against boto3.upload_file() for the 4GB file. Then trace the s3fs upload path and available configuration; done means explaining the performance difference and identifying a verified optimization or documenting that the behavior is expected.

Written by the indexing model from the issue text.

Description

I've noticed that while uploading large files (greater than 1GB), s3fs.write() performs around three times slower than the boto3.upload_file() API.

Is this slower performance expected when using s3fs, and are there any configurations or optimizations that could improve its upload speed?

import boto3
import time

# MinIO server setup
endpoint_url = 'http://localhost:9000'
access_key = ''
secret_key = ''
bucket_name = 'test-bucket'
file_path = 'large_file.bin'
key = 'uploaded_file.bin'

file_size_mb = 4096
with open(file_path, 'wb') as f:
    f.write(os.urandom(file_size_mb * 1024 * 1024))
print(f"Created a {file_size_mb}MB test file.")

fs = s3fs.S3FileSystem(client_kwargs={'endpoint_url': endpoint_url}, key=access_key, secret=secret_key)

s3 = boto3.client('s3', endpoint_url=endpoint_url, aws_access_key_id=access_key, aws_secret_access_key=secret_key)

start_time = time.time()
with fs.open(f'{bucket_name}/{key}', 'wb') as f:
    f.write(open(file_path, 'rb').read())
print(f"s3fs upload time: {time.time() - start_time} seconds")

start_time = time.time()
s3.upload_file(Filename=file_path, Bucket=bucket_name, Key=key)
print(f"boto3 upload time: {time.time() - start_time} seconds")
Dominant language
Python
Stars
1k
Forks
305
Avg merge
22h 37m
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from fsspec/s3fs

All issues in fsspec/s3fs

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.