S3 batch export: Parallelize upload for increased performance

Open
#28,129 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
34/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
aws, clickhouse, python

Research direction

Locate the S3 batch export entry point, the S3 multipart upload manager, and the ClickHouse consumers. Read how upload ordering and progress are currently handled, then verify that consumers can share one manager, uploads can run in parallel, and pending work is cancelled after a failure.

Written by the indexing model from the issue text.

Description

enhancement
Feature request

Is your feature request related to a problem?

Not strictly a problem, but S3 batch exports are leaving performance gains on the table now that they do not track progress. Given that we always restart from the beginning, we can drop ordering constraints and parallelize the consumption of data from ClickHouse.

Describe the solution you'd like

The S3 multi part upload management would have to be separated from the S3 consumers. Now, multiple S3 consumers should share a reference to the same S3 multi part upload manager, which would be in charge of deciding when to start a new upload. This will require the use of some async synchronization primitives.

In the event of a failure, all pending uploads can be cancelled.

Describe alternatives you've considered

N/A

Additional context

Faster performance also helps with avoiding timeouts in the event of instability.

Debug info
- [ ] PostHog Cloud, Debug information: [please copy/paste from https://us.posthog.com/settings/project-details#variables]
- [ ] PostHog Hobby self-hosted with `docker compose`, version/commit: [please provide]
- [ ] PostHog self-hosted with Kubernetes (deprecated, see [`Sunsetting Kubernetes support`](https://posthog.com/blog/sunsetting-helm-support-posthog)), version/commit: [please provide]
Dominant language
Python
Stars
39.9k
Forks
3.4k
Avg merge
7h 27m
Merged PRs (30d)
222

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 PostHog/posthog

All issues in PostHog/posthog

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.