Basics
SuiteScript Governance
Understanding Governance
SuiteScript governance limits API usage to prevent performance issues.
What is SuiteScript Governance?
SuiteScript governance is a set of rules and limits imposed by NetSuite to manage and control the usage of API requests in SuiteScript. These limits ensure that scripts do not consume excessive resources, which could lead to performance degradation for other users on the platform.
Each type of SuiteScript script, such as User Event, Scheduled, and Map/Reduce, has different governance limits. These limits are measured in governance units, and every API call consumes a certain number of these units.
Why is Governance Important?
Governance is crucial to maintain the balance between resource consumption and performance. Without these limits, a poorly written script could potentially monopolize system resources, leading to slower performance for all users. By adhering to governance limits, developers can ensure that their scripts run efficiently and coexist with other scripts and processes in the NetSuite environment.
Additionally, managing governance effectively can help avoid unexpected script terminations due to exceeding script execution limits.
Common Governance Limits
Here are some common governance limits you might encounter when working with SuiteScript:
- User Event Scripts: Typically have a limit of 1,000 governance units.
- Scheduled Scripts: Generally have 10,000 governance units, allowing for more extensive processing.
- Map/Reduce Scripts: Each stage in a Map/Reduce process can have its own limits, usually about 10,000 units per stage.
These limits are subject to change, so it's essential to consult the latest NetSuite documentation when developing scripts.
How to Monitor Governance Units
NetSuite provides tools to help developers monitor the governance units consumed by their scripts. The nlapiGetContext()
function is commonly used to access the script context, which can be utilized to check remaining governance units.
Best Practices for Managing Governance
To effectively manage governance limits, developers should consider the following best practices:
- Optimize API Calls: Minimize the number of API calls by batching operations and reducing redundant calls.
- Use Appropriate Script Types: Choose the right type of SuiteScript for your needs. For instance, use Scheduled Scripts for tasks involving heavy data processing.
- Monitor Regularly: Regularly check the consumption of governance units to avoid reaching the limit unexpectedly.
- Implement Error Handling: Include logic to handle scenarios where the script might run out of governance units, such as logging warnings or splitting tasks.
Basics
- Previous
- Modules
- Next
- Introduction