3

I like to check if somebody have clear idea of how CPU Governor limit is calculated during times when salesforce server is busy, its kind of black box,

I'm execute 4-5 visualforce remoting call from javascript to summarize complex data for charting, each one of them is async in nature and not buffered hence they are 4 different requests, i get sometime CPU Timeout limit for one of the request.

  • 1
    Some information on How does SF calculate the CPU time?. The best way to avoid hitting the limit would be to identify the bottlenecks in your Apex code and get the execution time well under the 10 second limit so the variability of the application of the limit by the platform becomes a non-issue. – Keith C Jul 17 '14 at 23:41
  • The 10 second limit isn't a hard and fast rule, specifically, but you should try to get as low as you can, as stated here. – sfdcfox Jul 18 '14 at 0:11
  • The questions is about fair 10s allocation per request even during busy times, My calculations are complete under 10s more than 50% time, but during peak hour its not the case, thats strange. – realnumber Jul 18 '14 at 16:26
3

I'm not sure if it's gonna help you with your problem. But since summer 14. You can increase the CPU timeout for a future method :

@future(limits='2xCPU')     CPU timeout is doubled (120,000 milliseconds).
@future(limits='3xCPU')     CPU timeout is tripled (180,000 milliseconds).

Didn't try yet, but very interesting.

  • Salesforce documents saying like they are pilot , so are they available in production? – user7601 Oct 2 '17 at 13:35
2

You can use the below method to know the CPU time at any moment in your apex to check with the governor limits. The Limit Class documentation below have all the details.

This method would give you CPU time.

getLimitCpuTime()

Returns the time limit (in milliseconds) of CPU usage in the current transaction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.