Hi everyone,
I’m currently using Anvil on the Business Plan, and I have a couple of questions regarding background tasks:
Time Limit: I have some background tasks that typically run for about 20–25 minutes. Occasionally, they fail and are automatically retried. Is there a maximum time limit for background tasks on the Business Plan?
Concurrency Limit: What is the concurrency limit for background tasks on the Business Plan? In other words, how many background tasks can I run simultaneously?
Would appreciate any clarification on this. Thanks in advance!
I’m not part of the Anvil team, just a user, so I’m not completely sure—but each plan typically sets limits based on the amount of memory or CPU your instance can use.
Memory limits mean you could run multiple (e.g., 10) background tasks at the same time if each one uses only a small amount of memory. However, a single task that consumes a lot of memory might fail to run.
CPU limits mean that if you have several tasks running at once, they might execute more slowly—unless those tasks mostly wait for things like HTTP requests and don’t use much CPU.
The specific limits depend on your plan, but these are the general principles.
There is no timeout limit for background tasks on the Business Plan. However, apps on the Business Plan use our shared infrastructure, so the amount of memory that is available to allocate to your app depends on how much the server is currently being used.
So as @stefano.menci has said, you are probably running into memory limits when your background tasks fail. There are usually ways you can optimize your code to prevent this from happening. Alternatively, you can add Extra Server Resources to the Business Plan which will run your server code on a dedicated server. You can choose how much memory and CPU the server has.