Salesforce Governor Limits: Who Do They Exist?

salesforce-governor-limits

Salesforce is one of the most used CRM tools that people know worldwide. But with a large user base also comes some high usage problems. Since some of its users are large corporations, they need a high level of features and resources, which can affect the low-end user’s experience. So, to keep things fair and under control, we have Salesforce governor limits that restrict the monopoly of large resource consumption. These limitations are:

  1. Per-Transaction
  2. Concurrent Request
  3. Static Apex
  4. Dynamic Apex
  5. Force.Com Streaming API

If you are eager to learn more about them, continue reading the article. Here, you will learn what these limitations are, why they exist, and what will happen if you exceed them. So, let’s get into the details!

What are Salesforce Governor Limits?

Salesforce Governor Limits are a set of rules and restrictions that govern the usage of resources on the Salesforce platform. These limitations ensure that no single organization can monopolize shared resources. It also helps the platform combat the degradation of the performance of Salesforce for other users. Moreover, governor limits apply to various operations, including Apex code execution, data manipulation, API calls, and email sending.

Why These Governor Limits Exist?

Salesforce is a shared, multi-tenant environment where multiple organizations use the same underlying infrastructure. Additionally, these limitations ensure fair resource allocation and prevent any single organization from monopolizing resources. These include CPU, memory, or database storage, which could negatively impact the performance of the entire platform.

Furthermore, limiting the usage of system resources helps prevent abuse, intentional or unintentional, by applications or users. It guards against scenarios where poorly written code or excessive data manipulations could lead to system degradation. Moreover, it ensures that no single entity negatively impacts others sharing the platform.

Governor limits also contribute to the security and governance of the Salesforce platform. By restricting the data volume, they help mitigate potential security risks and vulnerabilities, ensuring compliance with data access. It also helps others to avail of the benefits by allowing them to use the platform as it should be. You can check out these Salesforce benefits in our other blog.

Types of Salesforce Governor Limits

After getting the overview and importance of these limitations, you may want to know about them in detail. So, below we have explained each type and their sub-categories with examples so you can comprehend them well.

1. Per-Transaction Limits

These are a set of restrictions that govern the resources consumed during a single transaction or request. They are crucial in maintaining the stability and fair usage of the platform. It regulates the amount of resources allocated to each transaction within the Salesforce environment.

Also, these limitations dynamically allocate resources to each transaction, ensuring that no single transaction monopolizes an excessive amount of system resources. For instance, limits on the number of database operations, CPU time, or heap size that can be used within a single transaction. Some of its examples are:

  • DML Statements: It restricts the number of database manipulation operations (inserts, updates, deletes, upserts) in a single transaction.
  • SOQL Queries: It governs the number of SOQL queries executed in a transaction.
  • CPU Time: It limits the amount of CPU time consumed by the transaction.
  • Heap Size: It governs the amount of memory allocated to the transaction’s execution.
  • Email Messaging: It controls the number of outbound emails sent from a transaction.
  • Callouts: Restricts the number of callouts (external web service requests) in a transaction.

Developers need to design their code considering these limitations. Hence, strategies like bulkifying operations, optimizing queries, and using asynchronous processing help in working efficiently within these boundaries.

2. Concurrent Request Limits

They refer to the constraints placed on the number of simultaneous operations or requests that can be executed at the same time. Unlike Per-Transaction Limits, which apply to individual transactions, Concurrent Request focuses on the overall load and concurrency across the entire Salesforce instance.

They ensure that the platform remains stable by preventing excessive simultaneous operations that could overwhelm resources. In this way, it ensures fair resource allocation among different users and applications sharing the Salesforce environment. It has the following types:

  • API Requests: Limits the number of API calls made simultaneously to Salesforce.
  • Apex Flex Queue: Governs the number of asynchronous Apex jobs that can be queued for execution simultaneously.
  • Platform Events: Restricts the number of platform events processed concurrently.

Developers need to design their applications with these restrictions in mind. They can use techniques like queueing asynchronous jobs, optimizing API usage, and controlling event processing to avoid hitting these boundaries.

3. Static Apex Limits

Static Apex Limits in Salesforce are predefined limitations on the resources or operations that can be performed by Apex code within the platform. Moreover, these limitations are fixed and apply universally across all transactions, ensuring a balanced usage of resources and preventing excessive consumption by any individual process or code segment.

These limits have specific, predetermined values that Salesforce sets and the developers cannot alter or modify them. They are intended to maintain system stability and prevent any single execution from monopolizing resources. They have different categories, like:

  • Number of DML Statements: Limits the number of insert, update, delete, and upsert operations.
  • Number of SOQL Queries: Restricts the total number of SOQL queries issued.
  • CPU Time: Limits the total CPU time consumed by Apex code execution.
  • Heap Size: Governs the total amount of memory allocated for variables and objects during code execution.
  • Email Limits: Controls the number of emails that can be sent using Apex code.
  • Future and Queueable Jobs: Restricts on the number of asynchronous Apex jobs enqueued for execution.
  • Callouts: Restricts the number of external service callouts made by Apex code.

Developers need to be mindful of these limitations while writing and executing Apex code. Strategies like bulk processing, efficient querying, and asynchronous processing are essential to optimize code and work within these boundaries.

4. Dynamic Apex Limits

They refer to the limitations imposed on an Apex code execution that depend on specific conditions or data processing. Unlike Static Apex Limits, which have fixed, predetermined values, Dynamic Apex can change based on factors such as data volume, code complexity, or runtime conditions.

These are flexible and can fluctuate based on runtime conditions and the complexity of the code. Certain limitations, such as the number of rows processed in DML operations or the number of records retrieved in queries, can vary based on the amount of data involved. Furthermore, these limitations ensure that resource consumption remains within acceptable bounds during code execution. Some of its examples are:

  • Query Rows Limits: Restricts on the number of rows returned by a query based on whether it’s in a trigger context or executed elsewhere.
  • CPU Time and Heap Size: Limits that might dynamically adjust based on the complexity and execution context of the code.
  • DML Operations: Limits on the number of records that can be inserted, updated, deleted, or undeleted based on the context.

Developers need to anticipate these varying limitations during development and design their code to handle potential variations. Handling these exceptions gracefully is essential for managing resource constraints dynamically during code execution.

5. Force.Com Streaming API Limits

The Force.com Streaming API in Salesforce enables real-time communication between Salesforce servers and clients through the use of PushTopics, platform events, or generic events. This API allows clients to receive notifications about data changes or events occurring in Salesforce.

On the other hand, limits are set on the number of client connections to the Streaming API at any given time. These limits ensure that excessive connections or subscriptions do not impact the overall system performance. Some of its common conditions are:

  • PushTopic Events: Limits are imposed on the number of PushTopic-based events that can be published per 24-hour period.
  • Platform Events: Constraints exist on the total number of platform events published and consumed by all subscribers within specific time frames.
  • Generic Events: Similar limitations apply to generic events published and received by subscribing clients.

Developers need to consider and manage these limits while implementing and subscribing to events using the Streaming API. Strategies to efficiently handle event processing, limit subscriptions, and optimize event publishing are essential to stay within the boundaries.

What Happens if You Exceed Salesforce Governor Limits?

Exceeding Salesforce Governor limits can lead to various consequences, depending on the specific limit breached and the context in which the breach occurs. Exceeding certain limitations might cause the associated code block or transaction to terminate abruptly. This abrupt termination can impact user experience or system functionality if not handled properly.

In some cases, Salesforce might apply temporary restrictions or throttling measures when users exceed limits. Also, this throttling could involve delaying or queuing operations, slowing down the execution speed, or temporarily blocking further actions until resources become available.

Additionally, it can also display error messages to users. This can affect the usability and functionality of the application if not managed correctly. Salesforce administrators or designated users might receive email notifications when they breach certain limits, providing alerts to monitor and optimize system performance.

On the other hand, exceeding limitations in integrations or APIs can disrupt data synchronization or impact external services. Consistent breaches of  Salesforce governor limits might lead to Salesforce taking more stringent actions. It may include reaching out to the organization to address the issues.

Summary

The platform has set Salesforce governor limits to limit users to not overload the platform and keep things fair for its users. Abiding by these rules is necessary for everyone to follow, whether it is a small-scale business or a large-scale corporation. If you remain within these limitations, you won’t feel any bump in the user experience. So, play fair, spare resources for others, and enjoy great CRM software at its best.

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Posts