---
schema_version: "1"
id: 612467b272009c890b374c9dbce542624b89e4f35b4931af22497b493fe2c354
title: Handle Multiple Concurrent Requests
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/salesforce-pages-developers-guide/guides/pages/best-practices/best-practices-performance/pages-best-practices-perf-concurrent.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-pages-developers-guide/guide/pages-best-practices-perf-concurrent.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: bcba1bfee5954c18c3ee54a217e1dc135d823f1cbefec149083014bdb0158459
products:
  - Visualforce Developer Guide
  - Platform Developer Content
---

# 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.

**See Also**  


-   [Use Ajax in a Page](https://developer.salesforce.com/docs/platform/quick-start/pages-quick-start-ajax.md)
-   [*Apex Developer Guide*: Make Long-Running Callouts with Continuations](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_continuation_overview.htm)
-   [*Salesforce Developers Blog*: Two Visualforce Pages: ActionFunction and JavaScript Remoting](https://developer.salesforce.com/blogs/developer-relations/2011/05/tale-of-two-visualforce-pages-actionfunction-and-javascript-remoting)
-   [JavaScript Remoting for Apex Controllers](https://developer.salesforce.com/docs/platform/javascript/pages-js-remoting.md)

