Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ export interface AddJobsJobSpec<

/**
* The queue to run this task under (only specify if you want jobs in this
* queue to run serially). (Default: null)
* queue to run serially). Avoid using high cardinality values (e.g., random
* strings, UUIDs, timestamps) as this degrades performance and requires
* periodic database cleanup. (Default: null)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Feedback is welcome on the phrasing here - I don't feel strongly!

*/
queueName?: string;

Expand Down Expand Up @@ -336,7 +338,9 @@ export interface CronItemOptions {
/** Optionally override the default job max_attempts */
maxAttempts?: number;

/** Optionally set the job queue_name to enforce that the jobs run serially */
/** Optionally set the job queue_name to enforce that the jobs run serially.
* Avoid using high cardinality values (e.g., random strings, UUIDs, timestamps)
* as this degrades performance and requires periodic database cleanup. */
queueName?: string;

/** Optionally set the job priority */
Expand Down Expand Up @@ -586,7 +590,9 @@ export interface Cron {
export interface TaskSpec {
/**
* The queue to run this task under (only specify if you want jobs in this
* queue to run serially). (Default: null)
* queue to run serially). Avoid using high cardinality values (e.g., random
* strings, UUIDs, timestamps) as this degrades performance and requires
* periodic database cleanup. (Default: null)
*/
queueName?: string;

Expand Down
10 changes: 10 additions & 0 deletions website/docs/library/add-job.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ The `addJob` arguments are as follows:
(see [Replacing and updating jobs](../job-key.md#replacingupdating-jobs) and
[removing jobs](../job-key.md#removing-jobs))

:::warning Avoid high cardinality in queue names

Avoid using high cardinality values (e.g., random strings, UUIDs, timestamps)
for queue names as this will create many dead queues that degrade performance
and require [periodic database cleanup](../admin-functions.md#gc_job_queues). If
you find yourself needing to run the `GC_JOB_QUEUES` cleanup task regularly,
you're likely using queue names incorrectly.

:::

Example:

```js
Expand Down
4 changes: 3 additions & 1 deletion website/docs/library/add-jobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ export interface AddJobsJobSpec {

/**
* The queue to run this task under (only specify if you want jobs in this
* queue to run serially). (Default: null)
* queue to run serially). Avoid using high cardinality values (e.g., random
* strings, UUIDs, timestamps) as this degrades performance and requires
* periodic database cleanup. (Default: null)
*/
queueName?: string;

Expand Down
4 changes: 3 additions & 1 deletion website/docs/sql-add-job.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ this underlying `add_job` SQL function.
what to do, or an array of one or more of these objects for &ldquo;batch
jobs&rdquo; (defaults to an empty object).
- `queue_name` &mdash; if you want certain tasks to run one at a time, add them
to the same named queue (defaults to `null`).
to the same named queue. Avoid using high cardinality values (e.g., random
strings, UUIDs, timestamps) as this degrades performance and requires periodic
database cleanup (defaults to `null`).
- `run_at` &mdash; a timestamp after which to run the job; defaults to now.
- `max_attempts` &mdash; if this task fails, how many times should we retry it?
(defaults to `25`. Must be castable to `smallint`).
Expand Down