function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sfdeveloper9sfdeveloper9 

Callout governor limits

Is there a easy way to test the following governor limits

 

A callout request to a given URL is limited to a maximum of 20 simultaneous requests.

 

Each organization is allowed 10 synchronous concurrent events, each not lasting longer than 5 seconds. If additional requests are made while 10 requests are running, it is denied.

 

I want to hit this governor limits with a small piece of code or by calling a sample service..

 

Thanks in advance.

Navatar_DbSupNavatar_DbSup

Hi,

 

Total number of callouts in a request is 10 not 20. So you cannot send more that 10 requests at a time. Here is the code to hit this limit easily:

 

for(integer i=0;i<11;i++)

{

    HttpRequest req = new HttpRequest();

    HttpResponse res = new HttpResponse();

    Http http = new Http();

    req.setEndpoint('http://api.linkedin.com/v1/people/%7E');

    req.setMethod('POST');

    req.setBody('');

    req.setCompressed(true); // otherwise we hit a limit of 32000

    try

    {

        res = http.send(req);

    }

    catch(System.CalloutException e)

    {

        System.debug('@@@Callout error: '+ e);

        System.debug(res.toString());

    }

    system.debug('@@@____successfull');

}

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

sfdeveloper9sfdeveloper9

Thanks for you reply Ankit,

 

I am aware of that limit and that is not what I am looking for..

 

I am not able to understand the below two governor limits that are posted on salesforce limits page http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_gov_limits.htm

 

  1. A callout request to a given URL is limited to a maximum of 20 simultaneous requests.
  2. Each organization is allowed 10 synchronous concurrent events, each not lasting longer than 5 seconds. If additional requests are made while 10 requests are running, it is denied.
skausskaus

I have the similar curiosity. What is exactly meant by simultaneous requests. I also want to understand how is it mapped to users.

For e.g. by having more users in an org who lead to issuing more no. of callout requests ( code is optimized in the sense for a user, we are never sending more than 10 callouts at once.) how wil lit hit that limit. I haven't been able to understand if 20 different users causing callouts call at the sametime can cause this limit to be hit.

Srinath R 9Srinath R 9
I am trying to replicate the same error and trying to understand what concurrent synchronous requests actually mean. I have used the below code snippet which delays the API response by 9 seconds. I issued multiple calls outs at the same time using the 2 users in my developer org but the governor limit of "Number of synchronous concurrent transactions for long-running transactions that last longer than 5 seconds for each org" was never hit. 

I even checked the debug logs for all the API request and response timestamp. I could see at one point where 14 calls outs are actually waiting for the response from the API but still the governor limit is not hit. Any help here would be appreciated.
 
VF Page:
<apex:page controller="ContinuationController" showChat="false" showHeader="false">
   <apex:form >
      <!-- Invokes the action method when the user clicks this button. -->
      <apex:commandButton action="{!startRequest}" 
              value="Start Request" reRender="result"/> 
   </apex:form>

   <!-- This output text component displays the callout response body. -->
   <apex:outputText id="result" value="{!result}" />
</apex:page>

Controller Code:
public with sharing class ContinuationController {
    // Unique label corresponding to the continuation
    public String requestLabel;
    // Result of callout
    public String result {get;set;}
    // Callout endpoint as a named credential URL 
    // or, as shown here, as the long-running service URL
    private static final String LONG_RUNNING_SERVICE_URL = 
        'http://1.cuzillion.com/bin/resource.cgi?sleep=9';
   
   // Action method
    public Object startRequest() {
      
      // Create callout request
      HttpRequest req = new HttpRequest();
      req.setMethod('GET');
      req.setEndpoint(LONG_RUNNING_SERVICE_URL);
      try{
      HttpResponse res = new Http().send(req);
      String response = res.getBody();
      this.result = response;
      return null;}
       catch(System.CalloutException e)

    {

        System.debug('@@@Callout error: '+ e);
        return null;

    }
      
    }
}