Handle Multiple Concurrent Requests

Concurrent requests are long-running tasks that can block other pending tasks. To reduce delays, move code to asynchronous code blocks when possible and make sure action methods that use the <apex:actionPoller> component are lightweight.

Write Asynchronous Code

To offload expensive processing, use Asynchronous JavaScript and XML (Ajax) to move non-essential logic to an asynchronous code block. For example, for a page built with only synchronous code, a user clicks a button and waits for a long-running task to complete before they see a confirmation message. In contrast, if the page queues the long-running task for asynchronous processing, then the control immediately returns to the user. You can configure the page to notify the user when the task completes.

Keep <apex:actionPoller> Lightweight

The <apex:actionPoller> component is a timer that makes Ajax requests. Pages that use the <apex:actionPoller> component make continuous requests on the server. If a user leaves the page open for long periods of time or opens multiple windows on the same page—for example, to get details for multiple accounts—performance decreases.

To avoid performance degradation, avoid performing DML, external service calls, and other resource-intensive operations in action methods that <apex:actionPoller> calls. Carefully consider the effects of <apex:actionPoller> action methods called at repeated intervals. Tasks are likely to be blocked when the method is used on a widely distributed or continuously active page.

To avoid hitting governor limits, increase the time interval between Ajax requests. The <apex:actionPoller> component’s interval attribute measures the time interval between Ajax update requests in seconds. This value must be 5 seconds or greater, and if not specified, defaults to 60 seconds.

The <apex:actionPoller> component is appropriate on pages that don’t require expensive processing, but for pages where the calculations require more server time, consider using the <apex:actionFunction> component with JavaScript remoting instead. This alternative requires more code but offers greater flexibility and efficiency.