Have you already heard about Salesforce Evergreen and Evergreen functions? In this post, we explain what they are, their pros and cons, and when it is a good idea to use them to build serverless Functions and Services. And Eduard Panin, a Senior Salesforce Solution Engineer at Ascendix, shared his first-hand experience with Salesforce Evergreen and why it is a good choice for Salesforce app development.
Before we dive into the Salesforce Evergreen Functions topic, it’s worth mentioning Eduard’s role and experience in delivering Salesforce solutions.
Eduard is one of our leading experts with experience in Salesforce, React, Node.js, and Java. He combines his key responsibilities with being a Salesforce master mentor at Ascendix Technologies.
During these years, he delivered multiple small- and large- scale solutions being a strong follower of clean code practice.
Now, Eduard will tell about the Evergreen function from the Salesforce developer’s standpoint. Namely:
- What Salesforce Function and Salesforce Evergreen is in particular
- Salesforce Function equivalents on other platforms and their pros & cons
- Features of Evergreen Function: where you can call them from and how they work
- Function use cases and best practices
- Salesforce Evergreen current limitations
What is Salesforce Function?
Salesforce Function is a service of a platform that lets Salesforce developers create the code that connects data and events. It can run on-demand with an elastic scale in a serverless environment and can be integrated with low-code and pro-code services to deliver an agile and unified Salesforce experience.
So, What is Salesforce Evergreen Then?
Evergreen function is a new serverless environment powered by Kubernetes for the Customer 360 platform that integrates Heroku’s decade-long experience in creating extensible container runtimes and highly efficient data stores with Lighting functionality.
For those who are unsure of what Kubernetes and Salesforce Customer 360 are, I’ll say a couple of words about both of these platforms.
Kubernetes is an open-source container-orchestration system originally developed by Google in 2014. It was designed to automate computer application deployment, scaling, and management and works with a scope of container tools. Kubernetes runs containers in a cluster, often with images built using Docker (a set of platform as a service (PaaS) products that use OS-level virtualization).
Salesforce Customer 360 is a platform aimed to help companies connect with customers through cohesive internal operations. It encourages internal collaboration by integrating sales, marketing, service, commerce, and analytics activities in one CRM platform. Customer 360 helps create a universal customer profile and customer journey to deliver a seamless customer experience.
Salesforce Evergreen Function is a fairly new addition that first became available in a pilot version as a limited access developer preview with Spring, 21 Salesforce release in February. However, the first use cases were already discussed at the Dreamforce 2019 Developer Keynote.
Features of Evergreen cloud service ensure seamless access to Customer 360 data and support open programming languages, commonly used high-performance data stores, and architectural patterns. Due to them, your development teams can become more productive.
Moreover, serverlessness means that solutions built with this function consume no resources when idle and it can significantly reduce costs on hosting another platform for service processing.
It is possible due to a Serverless Execution Model that represents a fully secured and stateless data container within which codes run dynamically.
A wide scope of actions like an HTTP request, alert monitoring or uploading of a data file can set these codes in action.
Then the code is sent to the cloud provider as function and the user will be charged for only what he consumes.
On top of it, Evergreen is an inseparable Salesforce part that means that you don’t need to set up extra authentication or networking.
What’s Hiding Behind a Salesforce Evergreen?
There are multiple features that are involved in this environment, among which are:
It allows building business logic and event processing in programming languages like Apex, Node.js, and Java. Functions can be triggered directly from Apex or using Platform Events with many more invocation types and event sources to come.
Microservice patterns are used to build serverless HTTP apps and APIs that can be quickly transformed by developer teams of any size into complex solutions.
Managed Data Stores
These data stores include Postgres, Apache Kafka, and Redis that empower Salesforce Data APIs for real-time eventing and high-performance persistence.
All these features depend on the industries they are used for and come with built-in customer context powered by the Salesforce data model and low-code components.
A distinctive feature of Salesforce Evergreen function is that it is Kubernetes-based. It helps to equalize control and access to extensible container technology via managed serverless service run by Salesforce. It enables you to switch your focus from infrastructure operations to development innovation.
As you can see, Salesforce Evergreen Function is an exceptional blend of serverless, elastic container technology, providing continuous availability of data and low-code business logic designed to simplify the system infrastructuring and improve customer experience.
Salesforce Evergreen Functions Equivalents
Salesforce Evergreen Functions Equivalents
Before I move to a detailed review of Salesforce Evergreen Functions, I would like to compare it with other serverless alternatives, Azure Functions by Microsoft and AWS Lambda by Amazon, and explain why the Salesforce function can be a good choice.
#1 One Infrastructure with Services and a Container
All these functions are a part of one infrastructure with a service and a container, where the whole business logic takes place.
Thanks to this, all functions work with services and data directly, without authorization and additional implementation.
#2 Support of Common Programming Languages
All functions support rather popular programming languages so you can create custom software solutions quite easily.
Azure Functions support:
AWS Lambda supports:
Evergreen Functions support:
#3 Serverless Functions
Next, all three functions belong to serverless functions.
What does it mean for you?
It means that you don’t have to think about resources where these functions take place, you don’t have to think about their scalability.
The cloud platform is responsible for this.
I wouldn’t say that they are completely serverless, they are serverless just for users.
And it means that with these solutions you don’t have to spend time on server support.
Our task, as Salesforce developers, is just to write the code for these functions.
What’s the most interesting is that Salesforce function is a part of a Salesforce infrastructure and it enables us to work with database or any other logic directly, without authorization.
Our task, as Salesforce developers, is just to write the code for these functions. What’s the most interesting is that Salesforce function is a part of a Salesforce infrastructure and it enables us to work with database or any other logic directly, without authorization. ❞
Let’s move to the differences.
Unlike Salesforce, Azure Functions and Amazon Functions enable data analysis.
It means that you can analyze data, function loading, and improve performance.
Basically, you can even apply certain best practices to reduce function loading.
Also, the Azure function offers a declarative programming option. Similar to one that we have in Process Builder and in Salesforce Flow.
Both Azure and Amazon offer flexible pricing.
In other words, if function or service loading changes, the price changes as well.
That’s why pricing in the morning can differ from the pricing in the evening depending on the function logic.
What’s interesting is that Amazon offers out-of-the-box patterns for resolving simple business tasks with the help of their ready-to-use toolset, for example, for document generation.
Features of Evergreen Function
Evergreen Function Features
What makes Evergreen Function unique is that it:
- Is a completely new platform and paradigm and is a part of the Salesforce family
- Is the best way to build the deep and engaging solution
- Doesn’t require extra authentication
- Handles situations where you get Salesforce Limits
- Is a fully serverless platform
With the help of Salesforce function, you can build complex custom and, at the same time, scalable solutions that require a huge amount of resources.
In other words, if you increase the load on functions and the code, it can be scaled. You can roll out two or three functions at a time and distribute queries among them.
Also, they support several programming languages that enable working with already created solutions, frameworks, and libraries. It means that you can take an existing library in Node.js, or Java and do anything with them, for example, work with files.
❝ What can be interesting for a Salesforce developer is that Evergreen function helps deal with Salesforce limits, especially, based on my experience, when we work with files. ❞
Apex doesn’t stream files by bits, that’s why everything is directed to the memory that has its limits.
But we can manage these limits.
As I have already mentioned, since it’s a serverless function, Salesforce is held to be responsible for the server, you should only rollout the function in the organization.
Where Can You Call These Functions from?
Salesforce Functions Invocation Methods
Let’s imagine we created the function, rolled it out, it works, what’s next?
Salesforce offers 5+ 1 invocation methods:
- Change Data Capture Event
- Platform Event
But, the Salesforce function is still in pilot now, and invoking the Function from the command line is the only available option.
A bit later you’ll be able to call functions from Lightning Web Component (custom UI components), from Apex, or via the subscription to Platform Event or Change Data Capture Event.
You can call it from REST API as well.
How it Works and Where to Find Salesforce Evergreen Function?
How Salesforce Evergreen Works in Org
Kubernetes is an orchestrator of Docker containers.
I’ll explain what happens under the bonnet of the organization when you set up a Salesforce function.
A pod is the smallest part of the code in Kubernetes.
For us it is just a service, rolled out somewhere in the cloud.
When you deploy the code, Salesforce org never stops and the server doesn’t stop.
And it happens thanks to Kubernetes.
When you make any changes to the organization and start deploying them, the same service that works the same way appears next to your organization.
But Kubernetes doesn’t deploy any changes at once.
It should approve that all rollouts in the organization are made successfully and they are working.
So, the whole organization stays on the previous version.
Once everything is ready, Kubernetes starts to redirect queries from an old version to a new one.
For some time the old version is still in effect and guarantees uninterrupted work. After this, the service switches off.
This is how Salesforce organization works. The Salesforce function is also Kubernetes-based.
In its essence, the function is an accompanying service that we deploy and rollout the same way.
Both the function and the organization are on the same Node (a Pod is a Docker container, and a Node combines several containers and enables them to interconnect without authorization due to the same internal IP address).
You can send queries to the database, create any logic, and work with the organization without authorization because the function runs next to the Salesforce organization.
❝What’s more, Salesforce functions are secure and data will never go outside the Node. That is guaranteed by Salesforce. That is a big advantage comparing to custom solutions.❞
Scalability is one more advantage of the Evergreen function.
Let me explain how it is achieved in terms of horizontal scalability.
Kubernetes understands when the loading on the function is critical thanks to certain metrics. When it happens, Kubernetes rolls out an additional service and services start receiving services one-by-one.
As a result, end-users can get responses to their queries faster.
Moreover, if the loading is too critical, Kubernetes offers a Load Balancer logic that helps to distribute loading among all the services.
All of these ensure stability and easy restart.
How Evergreen Function Works
Your functions in Salesforce org. can be created with the help of any chosen programming language: Node.js, Java, or Apex.
They can be taken from different places like Change Data Capture Events, Platform Events, Lightning Web Components, Flow Builder, Apex, or even HTTP.
And Salesforce Org runs next to the function. You can use data stores or event queues as a part of the function.
Salesforce Evergreen Function Use Cases
Generally, If you need to build a custom solution, the Salesforce function is the best choice.
Salesforce Evergreen Function Use Cases
Here are areas where you can apply the Evergreen function instead of basic Salesforce functionality:
#1 Database Operation
This function can be applied to execute financial calculations and work-order generation.
#2 Elastic & Event-Driven Computing
Evergreen can help with image and file processing and demanding queries.
#3 Creating Reusable Backend Logic
You can perform data validation cleansing and building web APIs over your data.
What is more, Salesforce Evergreen functions can manage quite big financial calculations and custom analytics.
#4 Salesforce Backup of Large Data Sets
There are quite a few third-party solutions and services that can help with Salesforce data backup.
But all third-party services work with queries and might reach the limits quite fast. Especially, if the license doesn’t allow a big number of queries.
The key advantage of the Salesforce function is that you won’t reach your limits on system queries.
So if you need to deal with big data volumes for backup, the function is a good option.
#5 Files Migration and Parsing
Salesforce function is a great helper in work with files.
First, you can easily migrate files from Lightning Web Component to Google Drive or to Salesforce.
Next, you can leverage the Salesforce function for parsing files.
For example, you can parse CVs and fill in field values in your Salesforce org automatically.
Based on my experience, the Salesforce function is the best for such tasks. You can do it from UI or call it from Apex.
#6 Custom Development of Artificial Intelligence Solutions
Using Salesforce Function, you can even develop custom AI solutions.
For example, one of our clients works in the agricultural industry.
His request was to process data collected by satellites.
And, based on this data, AI should make a decision.
And in this case, the Salesforce function would work the best.
You can also create small microservices that can be re-used from different places to perform different business tasks.
Start Working With Salesforce Function
Now when you know what Salesforce Evergreen and Functions are and how they can be used, I also want to explain how you can start working with them.
How to Start Working with Salesforce Functions
Prior to playing with Salesforce functions, you need to install:
Docker (since Salesforce Evergreen Function is powered by Kubernetes) for Windows or Mac
SLDS Evergreen Plugin: sfdx plugins: install evergreen
And run npm install
After that, you need to:
- Create your first function. Once you give your function the name, the new folder will appear in your Salesforce project. The more functions you create, the more folders you’ll have.
- Start your function. It should be launched from the function directory.
- Invoke your new function. To invoke the function you should include the host where the function operates. It can be found in logs.
- Login into your environment.
- Deploy your function.
Salesforce Evergreen Limitations
Despite their obvious versatility and benefits, there are still some issues with Salesforce Evergreen functions because they are still in the pilot version.
Salesforce Evergreen Limitations
For example, it’s not possible to enable Evergreen Functions in the developer’s preview mode till the Spring, 21 release in February.
Also, we ran into some problems with authorization in Heroku.
Currently Supported Languages in Salesforce Evergreen
Also, CLI (Command Line) is the only invocation method available to try out Salesforce functions.
Salesforce Evergreen Function is a new member of the Salesforce family that enables developers to build custom solutions using popular open-source languages without leaving the platform.
Besides this ability, functions allow to cut down costs and time on server support due to its serverless nature.
But, probably, the most eye-opening feature is that it helps to avoid query limits dealing with big volumes of data and guarantees security of your data because they won’t leave the Salesforce platform and won’t involve any third-party tools.