Loading

Proactive Alert Monitoring: Apex CPU Timeout Exceptions

Julkaisupäivä: Aug 31, 2023
Kuvaus

Salesforce imposes a limit on the CPU usage that can be consumed in a given transaction, which is approximately 10 seconds for Synchronous, 60 seconds for Asynchronous Apex. An Apex CPU Timeout Exception effectively means that Apex Code (or process builder/ flows or both) is attempting to execute and is exceeding the cpu time limit. Any DML executions contained within the transaction will be rolled back if the limit is hit.

The Signature Success plan's Proactive Monitoring product will monitor for, and alert you to, high error volumes of this type. This article outlines some scenarios to help you investigate should you receive an alert. In addition, on the Salesforce Help site Designated contacts and above can see your realtime metrics, alerts & more.

If you receive the following error message, your organization may be hitting the timeout limit for transactions based on CPU usage.

Full Message Error Text:

  • Apex CPU time limit exceeded



Causes
When the limit is exceeded, transactions from APEX classes will encounter this exception. This alert provides visibility into when these errors are occurring for a customer so that corrective actions can be taken.

Errors of this nature can often be introduced by:

  • All Apex code
  • Library functions exposed in Apex
  • Workflow executions
Ratkaisu

Here are some common practices & resources that may help to resolve this error.

Process Builder:

Where viable, convert Process Builder processes to Apex Triggers using an asynchronous approach if possible.

Managed Package involvement:

If code from a managed package (i.e. Rollup Helper) is taking part in a transaction such as Posting a Billing you will need to contact the authors of that package.

Custom Code:

If you have custom code (i.e. trigger) you will need to contact your developer or responsible organization to refactor your current custom solutions to ensure you do not exceed the CPU time limit.This article includes suggested approaches to mitigate the CPU time limit exceeded issue.

Batch Processing: 

If you are inserting or updating a large number of records, try reducing the batch size.

Async Apex: 

Use @future calls and asynchronous processing to move non-critical business logic out of triggers and/or Process Builder processes.

Annual Technical Health Review: 

Audit the Apex code you're running to ensure it is efficient. If you have not availed of your annual Signature ATHR, this may help in identifying where best practices are not being followed.

Best Practices:

Consider Salesforce best practices for Triggers and Bulk Requests

 

Additional Resources:

Help and Developer resources:

Trailhead:

Knowledge-artikkelin numero

000389177

 
Ladataan
Salesforce Help | Article