DEV Community

Demo
Demo

Posted on • Originally published at orgdoc.dev

The Salesforce admin's guide to governor limit monitoring

Let's cut to the chase: governor limits aren't just Salesforce's annoying rulebook—they're the difference between a smooth-running org and a production outage at 3 a.m. I've seen enterprise orgs (financial services, healthcare, retail) blow through limits during peak hours because they ignored the signs. This isn't theory; it's what happens when you don't monitor.

Where Limits Actually Break You

Most admins focus on the obvious (like 200 SOQL queries), but the real killers are often hidden in plain sight. For example:

  • Queueable Apex limits: A healthcare client ran 500+ queueable jobs during a patient portal launch, hitting the 50 job limit. Their entire appointment scheduling process stalled for 2 hours. The fix? Monitoring job counts via SELECT COUNT() FROM AsyncApexJob WHERE JobType = 'Queueable'.

  • Heap size during batch processing: A retail org processed 50k orders in one batch, blowing heap limits. They had no visibility into memory usage per batch step. Now they track heap with System.Memory.getHeapSize() in a debug log.

  • SOQL limit accumulation: A financial services client used nested loops (100 queries in a loop) without realizing they'd hit the 100 SOQL limit. Their reporting dashboard failed at 10 AM daily. The fix: rewrite to bulkify, but first, catch the pattern with SELECT COUNT() FROM ApexLog WHERE DurationInMS > 1000.

Practical Monitoring Tactics (No Fluff)

Don't wait for alerts. Build these into your routine:

Weekly SOQL query audit: Run this daily in Dev Console to spot offenders:

SELECT Id, Query, DurationInMS, RowsProcessed 
     FROM ApexLog 
     WHERE DurationInMS > 500 
     ORDER BY DurationInMS DESC 
     LIMIT 10
Enter fullscreen mode Exit fullscreen mode
This exposes slow, inefficient queries before they cause outages.
Enter fullscreen mode Exit fullscreen mode

Track governor limit usage by user: Admins often blame "the system," but it's usually one user's custom Apex. Use:

SELECT UserId, COUNT(Id) 
     FROM ApexLog 
     WHERE LimitException = true 
     GROUP BY UserId
Enter fullscreen mode Exit fullscreen mode
Pinpoint the culprits—then coach or refactor.
Enter fullscreen mode Exit fullscreen mode

Monitor asynchronous job queues: Set up a dashboard with:

SELECT JobType, Status, CreatedDate, TotalJobs 
     FROM AsyncApexJob 
     WHERE JobType IN ('Queueable', 'BatchApex')
Enter fullscreen mode Exit fullscreen mode
If TotalJobs > 40, you're headed for a limit hit.
Enter fullscreen mode Exit fullscreen mode




The One Tool I Recommend (Not the Obvious One)

Yes, Salesforce Developer Console is fine for spot checks, but for enterprise orgs, you need proactive, historical data. I stopped using the "limit monitor" in Setup after seeing it miss cumulative hits across multiple deployments. Instead, I rely on OrgScanner for continuous, free health scans. It flags hidden limit risks (like unoptimized triggers or nested loops) and gives actionable fixes—no coding required. I've used it to prevent 3 critical outages in the last 6 months.

Don't wait for the error log. Governor limits don't care about your business hours. Monitor them like you monitor your database index usage—proactively, not reactively. Your users (and your sanity) will thank you.

Get Your Free Org Health Scan Now

📚 Recommended Resource: Salesforce for Dummies — great for anyone learning Salesforce.

📚 Recommended Resource: NIST Cybersecurity Framework Guide — great for anyone security frameworks.


Need a second opinion on your Salesforce org? Request a diagnostic.

Top comments (0)