Skip to content

use recomended hash prefix for task name #138

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

Closed
wants to merge 4 commits into from

Conversation

ted-selig-five9
Copy link
Contributor

In google/cloud-tasks/src/V2/Gapic/CloudTasksGapicClient.php the createTask docs say

Explicitly specifying a task ID enables task de-duplication. If a task's ID is identical to that of an existing task or a task that
was deleted or executed recently then the call will fail with [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS]. If the
task's queue was created using Cloud Tasks, then another task with the same name can't be created for ~1hour after the
original task was deleted or executed. If the task's queue was created using queue.yaml or queue.xml, then another task with
the same name can't be created for ~9days after the original task was deleted or executed. Because there is an extra lookup
cost to identify duplicate task names, these [CreateTask][google.cloud.tasks.v2.CloudTasks.CreateTask] calls have
significantly increased latency. Using hashed strings for the task id or for the prefix of the task id is recommended. Choosing
task ids that are sequential or have sequential prefixes, for example using a timestamp, causes an increase in latency and
error rates in all task commands. The infrastructure relies on an approximately uniform distribution of task ids to store and
serve tasks efficiently.

I'm interpreting this as meaning that making the md5(timestamp) as the prefix will be a performance increase because google can search for duplicate task names quicker.

@ted-selig-five9
Copy link
Contributor Author

hey @marickvantuil can I please have feedback on this?

@marickvantuil
Copy link
Member

Thanks for the PR! Great idea, which has got me thinking...

Initially, a custom task name was added in this pull request to make it more clear which task is in the queue. While I like that, I value the performance of inserting tasks more. I'm currently inclined to remove the $task->setName(...) (and thereby lose the task deduplication feature in Cloud Tasks) because Laravel also has task deduplication and it's more powerful.

The downside is that the task names are less readable. But to be honest, this is not very readable either 😛 :

5f4dcc3b5aa765d61d8327deb882cf99-Tests-Support-SimpleJob-f47ac10b-58cc-4372-a567-0e02b2c3d479

What do you think? @ted-selig-five9

@ted-selig-five9
Copy link
Contributor Author

I think it would be worth it to do it like that too, I can try to implement that.

@ted-selig-five9
Copy link
Contributor Author

closing this and will try to work on #141 instead

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