0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-25 11:17:50 +01:00
Commit Graph

16 Commits

Author SHA1 Message Date
Brett Hoerner
30bafdd382
chore(plugin-server): kafka ack cleanup and metric (#21111)
* cleanup: remove unused team arg from registerLastStep

* cleanup: rename promises to ackPromises to make it more clear thats what they are

* cleanup(plugin-server): make waitForAck explicit/required

* add Kafka produce/ack metrics

* Clarify Kafka produce metric/labels
2024-03-25 13:01:15 +00:00
Tiina Turban
8f81c31d21
chore: Nuke promiseManager (#19094) 2023-12-05 16:47:41 +01:00
Brett Hoerner
f470984976
chore(plugin-server): add prometheus metrics to match statsd ones, remove unused metrics (#19000) 2023-12-01 08:01:45 -07:00
Harry Waye
2f9e2928fe
chore(plugin-server): use librdkafka producer everywhere (#15314)
* chore(plugin-server): use librdkafka producer everywhere

We say some 10x improvements in the throughput for session recordings.
Hopefully there will be more improvements here as well, although it's a
little less clear cut.

I don't try to provide any improvements in guarantees around message
production here.

* we still need to enable snappy for kafkajs
2023-05-04 13:02:44 +00:00
Harry Waye
1e6c062095
feat(plugin-server): distribute scheduled tasks i.e. runEveryX (#13124)
* chore(plugin-server): disrtibute scheduled tasks

Changes I've made here from the original PR:

 1. add some logging of task run times
 2. add concurrency, except only one task of a plugin will run at a time
 3. add a timeout to task run times

This reverts commit 23db43a0dc.

* chore: add timings for scheduled tasks runtime

* chore: add timeouts for scheduled tasks

* chore: clarify duration unit

* chore: deduplicate tasks in a batch, add partition concurrency

* chore: add flag to switch between old and new behaviour

This defaults to new, but can be set to old by setting environment
variable `USE_KAFKA_FOR_SCHEDULED_TASKS=false`

* fix tests

* enable USE_KAFKA_FOR_SCHEDULED_TASKS in tests
2022-12-05 12:30:52 +00:00
Harry Waye
23db43a0dc
Revert "Revert "Revert "fix(plugin-server): ignore old cron tasks from graphile-worker """ (#13107)
Revert "Revert "Revert "fix(plugin-server): ignore old cron tasks from graphile-worker "" (#13100)"

This reverts commit 8eec4c9346.
2022-12-03 00:13:27 +00:00
Harry Waye
8eec4c9346
Revert "Revert "fix(plugin-server): ignore old cron tasks from graphile-worker "" (#13100)
Revert "Revert "fix(plugin-server): ignore old cron tasks from graphile-worker " (#13095)"

This reverts commit 5634ab4d7f.
2022-12-02 18:11:17 +00:00
Harry Waye
5634ab4d7f
Revert "fix(plugin-server): ignore old cron tasks from graphile-worker " (#13095)
Revert "fix(plugin-server): ignore old cron tasks from graphile-worker  (#13094)"

This reverts commit b079a8cc8e.
2022-12-02 16:28:30 +00:00
Harry Waye
b079a8cc8e
fix(plugin-server): ignore old cron tasks from graphile-worker (#13094)
* Revert "Revert "feat(plugin-server): distribute scheduled tasks i.e. runEveryX" (#13087)"

This reverts commit 78e6f48660.

* fix(plugin-server): ignore old cron tasks from graphile-worker

When we are backed up on jobs, we end up still creating tasks in the
graphile-worker job table, i.e. there is no backpressure. This change
makes us skip over old tasks, so that we don't get backed up.

* fix tests
2022-12-02 15:20:16 +00:00
Harry Waye
78e6f48660
Revert "feat(plugin-server): distribute scheduled tasks i.e. runEveryX" (#13087)
Revert "feat(plugin-server): distribute scheduled tasks i.e. runEveryX (#13037)"

This reverts commit 45912e839c.
2022-12-02 10:40:58 +00:00
Harry Waye
45912e839c
feat(plugin-server): distribute scheduled tasks i.e. runEveryX (#13037)
* feat(plugin-server): distribute scheduled tasks i.e. runEveryX

At the moment we only run on which ever Graphile worker node picks up
the scheduled tasks. Tasks are run in sequence, running through each of
the associated pluginConfigIds.

We tried to spread the workload by creating a Graphile Worker job for
each pluginConfigId, but this caused a lot of load on the Graphile
Worker database.

One thing this PR doesn't tackle is what happens if we end up having the
jobs back up. There is probably some logic we should add to avoid really
old scheduled tasks from running.

* wip

* wip

* fix tests

* fix tests

* types

* update unit test

* add key

* fix order

* Update plugin-server/src/main/ingestion-queues/scheduled-tasks-consumer.ts

* chore: skip stale scheduled tasks

* update comments

* add statsd counter
2022-12-02 09:42:55 +00:00
Yakko Majuri
1c2713a7b9
Revert "feat(scheduler): allow spreading scheduled tasks load across the fleet" (#12482)
Revert "feat(scheduler): allow spreading scheduled tasks load across the fleet (#12477)"

This reverts commit 98a14fc7c8.
2022-10-27 15:34:16 -03:00
Yakko Majuri
98a14fc7c8
feat(scheduler): allow spreading scheduled tasks load across the fleet (#12477)
* feat(scheduler): allow spreading scheduled tasks load across the fleet

* update test

* Update plugin-server/src/main/graphile-worker/worker-setup.ts

Co-authored-by: Harry Waye <harry@posthog.com>

* tweaks

Co-authored-by: Harry Waye <harry@posthog.com>
2022-10-27 17:35:45 +00:00
Yakko Majuri
c47a73165a
feat(plugin-server): use graphile-worker crontab (#12242)
* yeet references to redlock

* rename jobs/ to graphile-worker/

* feat(plugin-server): use graphile-worker crontab

* remove debugging

* yeet redlock dependency

* remove legacy test

* Update comment

* Update plugin-server/src/main/pluginsServer.ts

Co-authored-by: Harry Waye <harry@posthog.com>

* address review, update tests

* fix old tests

* testing, testing

* maybe fix sigterm

Co-authored-by: Harry Waye <harry@posthog.com>
2022-10-18 11:44:41 -03:00
Yakko Majuri
53b527dbbe
refactor(graphile-worker): update terminology, clearer capabilities approach for setup (#12203)
* rename legacy references to queue to more appropriate worker terminology

* rename startJobsConsumer -> startGraphileWorker, no-op refactor

* add back enqueue success and failure metrics

* fix mock import

* fix test for good
2022-10-12 10:24:22 -03:00
Yakko Majuri
a34228c49f
refactor: yeet job queues scaffolding in favor of only graphile worker (#12178)
* refactor: rename graphile queue to graphile worker

* refactor: rename job-queues/ to jobs/

* refactor: move graphile-worker to top level jobs/ dir

* refactor: remove references to jobQueueManager

* remove promise from startJobQueueConsumer

* remove job-queue-manager.ts

* remove non-test references to JobQueueBase

* make fs-queue independent from JobQueueBase

* rename FsQueue to MockGraphileWorker

* add missing pauseConsumer method to MockGraphileWorker

* rename fs-queue.ts --> mock-graphile-worker.ts

* delete job-queue-base.ts

* get rid of JobQueue type

* rename graphileQueue --> graphileWorker

* rename JobQueueConsumerControl --> JobsConsumerControl

* remove unused jobs test

* rename startJobQueueConsumer --> startJobsConsumer

* fix tests job imports

* rename jobQueueManager --> graphileWorker in tests

* remove JobQueueManager tests

* fix import

* handle metrics and retries on graphileWorker.enqueue

* minor fix

* Delete buffer.ts

* Revert "Delete buffer.ts"

This reverts commit 40f1761d31.

* add initial test scaffolding

* bring back relevant worker control promises

* fix existing tests

* add tests for graphile worker

* fix exportEvents retries test

* update e2e buffer test
2022-10-11 15:40:34 -03:00