It’s important once you have you application up and running that you also ensure it is performant – but what does performant mean? Fast? Scalable? Within Governor Limits? How about all of these and then some! In this session we will go through what is meant by performance, how to measure the performance of your code and understand where time is being used within a transaction as well as the actions to take and some best practices to keep things running nicely.
What do we mean by performance?
Resource usage/code performance
Using the minimum amount of resources possible
Queries
CPU Statements/Time
Heap Size
Using the most efficient mechanism
Theoretically should make us more performant
Governor Limits vs Performance
Governor Limits
Performance
Stop us from monopolising resources
How to improve the way in which our code runs and uses resources
Hard limits
No limit but rather an optimization goal
Avoidance rather than a target•55 SOQL Queries vs 90 SOQL Queries
User Perceived Performance
What does the user actually experience?
CPU Time vs Heap Size
Perception vs reality
UX vs Technical Improvements
This is what the user will care about but may not align with Governor Limits etc.
Scaling Performance
Handling a greater volume of data and users
Integrations
Reporting
Searching
How do we measure performance?
Observe
Orient
Decide
Act
Measuring Performance
Using Governor Limits
Governors ≠ Performance
Act a very useful guide for what we should be focusing on
Should measure against limits during testing
A Limit Exceptionis the worst exception to get
Limit Methods
Salesforce provides a Limit sclass to allow us to take measurements on how resources are being used
Measure both usage and against total available limit
Schrodinger’s Cat issues -taking a measurement can impact the measurement
Order Analysis
Loop Performance
A primary source of CPU time consumption
Nested loops can quickly consume resources
Ensure you follow best practices
No DML in loops
No SOQL in loops
Avoid expensive operations in loops
Different loop options have impacts
Heap Size Results
SOQL Performance
How to Improve SOQL Performance
Run fewer queries
Cache results in memory to reuse them wherever possible
Ensure that your queries are selective
Indexed filters
Implement strict sharing
Limits on queries
Caching and the Platform Cache
Platform Cache
What is the Platform Cache?
A temporary data store for frequently accessed but seldom written data
May 17, 2021 at 06:30PM Click here for more details...
=============================
The original post is available in Apex Hours by Amit Chaudhary
this post has been published as it is through automation. Automation script brings all the top bloggers post under a single umbrella.
The purpose of this blog, Follow the top Salesforce bloggers and collect all blogs in a single place through automation.
============================
Post a Comment