Skip to content

Too many API calls when restoring a backup from a S3 increment chain#1361

Open
Sfaynet wants to merge 2 commits intoAltinity:masterfrom
Sfaynet:fix_list_duration_s3_api_walk_5
Open

Too many API calls when restoring a backup from a S3 increment chain#1361
Sfaynet wants to merge 2 commits intoAltinity:masterfrom
Sfaynet:fix_list_duration_s3_api_walk_5

Conversation

@Sfaynet
Copy link
Copy Markdown

@Sfaynet Sfaynet commented Apr 17, 2026

Hello everyone!
I'd like to share the following issue:

When restoring (restore_remote) a large number of ClickHouse tables from S3, including incremental backups, there are numerous messages (pkg/storage/general.go:222 > , list_duration) in the logs, and it seems like more time is spent processing the logic than downloading the data itself. Restoring 280 GB of data and approximately 3,500 tables from S3 takes 8 hours, while after the backup is downloaded locally, it takes 11 minutes. Linear downloads from S3 (minio) are running at around a gigabyte per second.
I tried tweaking the parameters, but it didn't help:
S3_ALLOW_MULTIPART_DOWNLOAD="true"
DOWNLOAD_BY_PART="true"
DOWNLOAD_CONCURRENCY="255"
S3_CONCURRENCY
After analyzing the AI repo, claude-sonnet identified the cause:
Excessive S3 API calls (Walk) - up to 17,500 calls for each table in the increment chain.
The AI suggested the following as the primary solution:
In-Memory Cache (pkg/storage/general.go)
Added a cache for in-memory backup metadata
Cache key: {storage_type}:{backup_name}
When requesting metadata for the same backup again, the data is retrieved from the cache without calling S3.

I'm not a big Go expert, but the changes suggested by the AI ​​reduced the backup restore time from 8 hours to 30 minutes.

@Slach Slach self-requested a review April 23, 2026 05:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants