What to do when you get an “Apex CPU time limit exceeded” error
Once you encounter the dreaded “Apex CPU time limit exceeded” error in Salesforce, it’s up to you to deal with it. This error means that the functions in your system are now exceeding its ability to process actions. It’s a canary in the coal mine, likely a sign of much bigger issues.
You have two options once you’ve encountered this error. Firstly, you can try reducing the number of records that you’re updating at one time. But this isn’t possible for most organizations, because tools like Marketo will always want to make updates in large batches.
A better route is to do a CPU audit. Even if you’re not getting this error, an audit is always a good idea if you’re trying to scale. Especially if you’re concerned that Salesforce is “messed up” after years of user turnover, added tools, and changing processes.
Whatever the case, CPU audits are a part of maintaining overall good organizational performance.
Getting to the Source of the Problem
A typical approach to CPU audits is to take a systematic look at everything going on in Salesforce to see what might be slowing it down. But this can take weeks or months to complete, and we need to fix things fast for our clients. So instead, we get straight to the source of the problem by prioritizing the non-performant parts of the application.
We start by looking at what’s happening on the creation of a lead, contact, or account. This allows us to test exactly how long, on average, it’s taking the system to run Apex code, validation rules, workflow rules, process builders, and database queries.
In doing this, we can easily pinpoint the process or code that is slowing Salesforce down, and determine exactly what to fix.
Even Small Processes Can Slow Down Your System
Recently, in running our assessment with a SaaS startup client, we discovered that a legacy process that determined Lead Source was grinding their system to a halt. It turned out that this process, which they didn’t even know was running, was largely responsible for their issues.
When we replaced the old, complicated function with a single process builder, their Salesforce performance improved by a whopping 50%.
This situation is not at all unusual. Small, under-the-radar processes often cause havoc to much of the system. And with our approach to auditing Salesforce performance, we’re able to identify and fix these culprits quickly and easily.