The Wayback Machine - https://web.archive.org/web/20231220065035/https://github.com/laravel/framework/pull/49169
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.x] Enable DynamoDB as a backend for Job Batches #49169

Merged
merged 29 commits into from Dec 9, 2023

Conversation

khepin
Copy link
Contributor

@khepin khepin commented Nov 29, 2023

Context

Similar to how it's already possible to use DynamoDB to store failed jobs, this would enable DynamoDB as a store for job batches.

Key Proposed Differences with DB version

Make use of TTLs

The configuration makes it possible to (optionally) use TTLs on the created batches.
This way batches can be set to be fully removed after, for example, 30 days since last update to the batch.
The TTL for a batch gets reset on every update to the batch itself.
There is a monetary benefit to this because deletes based on TTLs do not cost anything in DynamoDB (as of today at least).

No pruning

Pruning in the DB version is done based on finished_at which isn't part of the key for the data we're storing here.
It would therefore require a secondary index in DynamoDB which incurs cost on AWS.
Since the TTL mechanism is available for a store like Dynamo, this seemed like a better option in this specific case.

@driesvints driesvints changed the title Enable DynamoDB as a backend for Job Batches [10.x] Enable DynamoDB as a backend for Job Batches Dec 5, 2023
'application' => ['S' => $this->applicationName],
'id' => ['S' => $batchId],
],
'ConsistentRead' => true,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be safer to use ConsistentRead in the first place for find() and get()? What's the impact of returning potentially stale data here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updates are where it actually matters and those are done atomically where AWS guarantees it updates the right data.
The updates are also independent from the read data because they use update expressions SET count = count + 1.
Because of this a ConsistentRead isn't required in general.

ConsistentRead is also 2x the cost of a read on AWS so I don't think it should be imposed as a default.

@taylorotwell taylorotwell merged commit d6ecd07 into laravel:10.x Dec 9, 2023
20 checks passed
@bretto36
Copy link
Contributor

@khepin Will this allow the batches to be displayed in the Horizon UI still?

@khepin
Copy link
Contributor Author

khepin commented Dec 12, 2023

I have no idea. Horizon is a part of the Laravel ecosystem I am really not familiar with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
6 participants