Loading

Mitigating Salesforce Apex Resource Exhaustion Caused by Org Permission Changes During Peak Business Hours

Publiseringsdato: Jul 1, 2026
Beskrivelse

What Is a Salesforce Apex Resource Exhaustion Event?

An Apex resource exhaustion event is a service protection mechanism that Salesforce triggers when too much competition for server resources occurs during the compilation of Apex code. This can result in degradation or denial of service for affected orgs.
Apex (Salesforce) is the strongly-typed, object-oriented programming language used on the Salesforce platform to write business logic, triggers, and automation. Apex code must be compiled into bytecode before it can be executed. This compiled bytecode is stored in a cache for performance.

When Does Apex Resource Exhaustion Occur?

Apex recompilation is triggered when compiled bytecode is not available in the Apex bytecode cache. Enabling or disabling any org permission during peak business hours may cause the Apex bytecode cache to be invalidated, forcing Salesforce to recompile Apex code for subsequent requests.
As a general rule: any permission change made during peak hours can potentially invalidate the Apex bytecode cache, leading to resource exhaustion as the platform recompiles large volumes of Apex code simultaneously.
Emergency and patch releases also invalidate the Apex bytecode cache.

Løsning

How to Prevent Apex Resource Exhaustion in High-Traffic Salesforce Orgs

Orgs with high traffic and a large number of Apex classes are most at risk of resource exhaustion events. The following best practices reduce this risk.

Avoid These Actions During Peak Business Hours

To prevent Apex bytecode cache invalidation during high-traffic periods, avoid the following actions during peak busy hours:

  • Changing org permissions or preferences, including activating a Salesforce release update
  • Changing custom objects or fields

Manually Compile Apex Code After Off-Peak Changes

After making permission or configuration changes outside of peak hours, manually compile Apex code to ensure the bytecode is pre-cached and available before traffic increases again. This prevents recompilation from occurring on live traffic.

Note on Metadata Deploys, Package Installs, and Upgrades

Changes made via metadata deploys, package installs, or package upgrades are covered by the compile on deploy feature. This ensures that compiled bytecode is available to handle requests immediately after these types of changes — these do not require manual compilation.

Knowledge-artikkelnummer

000927355

 
Laster
Salesforce Help | Article