Skip to content

fix: increase default flush interval#672

Merged
marandaneto merged 1 commit into
mainfrom
fix/default-flush-interval-5s
Jun 17, 2026
Merged

fix: increase default flush interval#672
marandaneto merged 1 commit into
mainfrom
fix/default-flush-interval-5s

Conversation

@marandaneto

Copy link
Copy Markdown
Member

💡 Motivation and Context

The Python SDK currently flushes partial background batches after 500ms by default, which is much more aggressive than the other backend SDK defaults. This increases the default background flush interval to 5 seconds while keeping the existing flush_at = 100 count trigger.

Default backend SDK context:

SDK Default flush interval Count trigger
posthog-python before this PR 500 ms flush_at = 100
posthog-python after this PR 5,000 ms flush_at = 100
posthog-dotnet 30,000 ms FlushAt = 20
posthog-go 5,000 ms BatchSize = 250
posthog-elixir 10,000 ms max_batch_events = 100
posthog-js / posthog-node 10,000 ms flushAt = 20
posthog-php No timer batch_size = 100; flushes on batch size/manual/destruct
posthog-ruby No fixed timer batch_size = 100; worker sends queued events immediately
posthog-rs No internal queue timer Captures send immediately; batching is explicit

💚 How did you test it?

  • uv run python .github/scripts/check_public_api.py
  • uv run pytest posthog/test/test_consumer.py posthog/test/test_client.py::TestClient::test_user_defined_flush_at

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran sampo add to generate a changeset file

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

An agent updated the Python client and consumer default flush interval from 0.5s to 5s, aligned the SDK compliance adapter default flush_interval_ms to 5000, regenerated the public API snapshot, and added a Sampo changeset. The default-values table above was gathered from the locally cloned PostHog SDK repositories to give reviewers cross-SDK context for the chosen 5s value.

@greptile-apps

greptile-apps Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix: increase default flush interval" | Re-trigger Greptile

@marandaneto

marandaneto commented Jun 16, 2026

Copy link
Copy Markdown
Member Author

@PostHog/team-client-libraries @cat-ph
i think 0.5s is too low
5s is more reasonable
rust is adding 5s as well
wdyt?

@marandaneto marandaneto marked this pull request as ready for review June 16, 2026 13:35
@marandaneto marandaneto requested a review from a team as a code owner June 16, 2026 13:35
@github-actions

Copy link
Copy Markdown
Contributor

posthog-python Compliance Report

Date: 2026-06-16 13:42:58 UTC
Duration: 540107ms

✅ All Tests Passed!

45/45 tests passed


Capture Tests

29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields 518ms
Format Validation.Event Has Uuid 10007ms
Format Validation.Event Has Lib Properties 10007ms
Format Validation.Distinct Id Is String 10007ms
Format Validation.Token Is Present 10012ms
Format Validation.Custom Properties Preserved 10007ms
Format Validation.Event Has Timestamp 10007ms
Retry Behavior.Retries On 503 18018ms
Retry Behavior.Does Not Retry On 400 12004ms
Retry Behavior.Does Not Retry On 401 10009ms
Retry Behavior.Respects Retry After Header 16013ms
Retry Behavior.Implements Backoff 32028ms
Retry Behavior.Retries On 500 16001ms
Retry Behavior.Retries On 502 16010ms
Retry Behavior.Retries On 504 16013ms
Retry Behavior.Max Retries Respected 32014ms
Deduplication.Generates Unique Uuids 10006ms
Deduplication.Preserves Uuid On Retry 16016ms
Deduplication.Preserves Uuid And Timestamp On Retry 23019ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 16005ms
Deduplication.No Duplicate Events In Batch 10002ms
Deduplication.Different Events Have Different Uuids 10007ms
Compression.Sends Gzip When Enabled 10007ms
Batch Format.Uses Proper Batch Structure 10007ms
Batch Format.Flush With No Events Sends Nothing 5005ms
Batch Format.Multiple Events Batched Together 10005ms
Error Handling.Does Not Retry On 403 12009ms
Error Handling.Does Not Retry On 413 10007ms
Error Handling.Retries On 408 14013ms

Feature_Flags Tests

16/16 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id 9502ms
Request Payload.Flags Request Uses V2 Query Param 10007ms
Request Payload.Flags Request Hits Flags Path Not Decide 10006ms
Request Payload.Flags Request Omits Authorization Header 10007ms
Request Payload.Token In Flags Body Matches Init 10007ms
Request Payload.Groups Round Trip 10007ms
Request Payload.Groups Default To Empty Object 10007ms
Request Payload.Person Properties Distinct Id Auto Populated When Caller Omits It 10007ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False 10006ms
Request Payload.Disable Geoip Omitted Defaults To False 10008ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key 10007ms
Request Lifecycle.No Flags Request On Init Alone 5003ms
Request Lifecycle.No Flags Request On Normal Capture 10507ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests 9511ms
Request Lifecycle.Mock Response Value Is Returned To Caller 10003ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event 10509ms

@marandaneto marandaneto merged commit 98a305a into main Jun 17, 2026
32 checks passed
@marandaneto marandaneto deleted the fix/default-flush-interval-5s branch June 17, 2026 13:54
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.

3 participants