Build faster and more reliabile background functions.
Configurable retries and concurrency have always been part of our roadmap.
Many of you expressed the need to have it as soon as possible, so we delivered!
By updating to @defer/client@1.0.0, you can now configure retry and concurrency using defer().
By default, Defer Platform won't retry any failed execution.
However, you might want to enable retries for background functions that, for example, interact with rate-limited 3rd party APIs.
Enabling retries on a background function is straightforward:
import { defer } from "@defer/client"async function importContacts(accountId: string) {// ...}export default defer(importContacts, {retry: 2,}
retry can be configured to 12 maximum, which gives a maximum retry at 12 hours after the first failed execution.
By default, Defer Platform will execute background functions in a FIFO way.
Most background functions use cases do not require to be executed in FIFO, especially for performance reasons.
By having a Pro plan, you'll be able to configure the concurrency of your background functions up to 10.
Here is an importContacts() background function that will be executed in parallel (up to 10):
import { defer } from "@defer/client"async function importContacts(accountId: string) {// ...}export default defer(importContacts, {concurrency: 10,}
Please note that concurrency above 1 is only available on the Pro and Custom plans.
Each account gets a maximum concurrency (Hobby: 1, Pro: 10) that take precedence on the configured background functions concurrency.
For example, on a Pro Plan, if 2 background functions with concurrency: 10 trigger 100 executions each, the Defer Platform will take 5 of each concurrently, matching the account's maximum concurrency (10).
We hope that the retry and concurrency features will empower you to build more advanced background functions and a quick user experience.
We would love to get your feedback in the comment section below!
Stay tuned for the upcoming releases - spoiler: a brand new Dashboard Functions view.