Is Serverless Commerce a Viable Trend in B2B eCommerce?
Before we dive into the serverless B2B ecommerce platform theme, let's say an important point first: the term “serverless computing” is deceiving. It can be attributed more to marketing rather than technical terminology in the market of cloud hosting. The word “serverless” is deceitful, in the fact that all serverless applications, including B2B eCommerce platforms, run on servers anyway.
The whole idea of serverless is that a company does not rent any specific configuration of server hardware resources for their project (the number of CPU cores, memory, disk space) from the cloud hosting provider (aka “hoster”). The data center provides the appropriate server configuration automatically, depending on the load created by the ecommerce application.
Initially, the idea of serverless computing, which was already about 10 years old, was to launch short applications in a way that performs some function (calculation) and then is no longer needed to store output data. For example, the function of calculating the amount in one type of currency relative to dollars. The function takes the code of the second currency, loads the current exchange rate, and displays the equivalent amount in dollars. Since 2018, there have been ideas to use serverless computing for more complex applications, including B2B ecommerce.
3 Ways That Serverless Commerce Reduces Costs
Serverless computing, regardless of an application’s scope and where to use it, is based on the Feature-as-a-Service (FaaS) hosting model provided by data centers. FaaS eliminates the need to configure the server side for a backend, allowing developers to describe server-side functions performed via HTTP and API calls.
The principal advantage of going serverless is associated with the possibility of reducing infrastructure costs, which is especially important for the ecommerce industry, both B2B and B2C niches. To be more precise, the costs could be reduced in three ways:
- For ecommerce, as perhaps nowhere else, the main advantage of serverless computing will be the ability to quickly and almost unlimitedly scale the webstore load, from complete rest to a bursting high. In this case, scaling occurs automatically and does not require any action from the owner of the ecommerce store.
- The second advantage is the pay-for-value model, i.e. according to the IT load and without any minimum level, which is also very favorable for ecommerce. No need to guess the future load on the store's server; hosting will provide any computing power needed (some limits will still be mentioned in the hoster’s tariff plan).
- The third area of savings includes significant cost reductions on a highly paid staff of system engineers and admins. In the case of cloud or on-premise hosting, these employees would be involved in setting up servers and installing operating systems and middleware. For serverless computing, such operations and personnel are not required.
Serverless Commerce as Experimental Stage Technology
While serverless computing has become a hot topic, none of the commercially available B2C and B2B ecommerce platforms in 2021 are offered to run in this mode yet. This is because such complex applications require that many prerequisites be met in order to run in serverless mode.
Serverless computing uses container-level virtualization. At the programmatic level, each function call runs in a separate container, which is destroyed as soon as the function ends. If a function needs to be run many times or multiple function calls come in parallel, it starts and then destroys the corresponding number of containers.
This containerized structure of serverless computing creates a set of constraints on the application architecture, including the ecommerce platform. Let's name a few of them:
- Ability to split an ecommerce workflow into multiple microservices, each of which can be launched as a function or as an external service from the hoster's serverless services.
- Execution of the function code within a very short time allocated by the subscription plan. It is about milliseconds; otherwise, the function will timeout abnormally.
- Low size of the occupied RAM. This parameter is usually limited in serverless subscription plans.
In the Architecting a Highly Available Serverless, Microservices-Based Ecommerce Site article posted on AWS, authors provide an example of an experimental ecommerce platform built on serverless AWS Lambda hosting. At the same time, in addition to AWS Lambda as an FaaS platform for serverless computing, it is supposed to use about a dozen internal AWS services. These additional services are needed for the content layer, authentication, and database.
While this AWS experimental ecommerce architecture could run in serverless mode, there are two big drawbacks. First, it is tightly coupled to the AWS brand and unable to migrate to another provider. Moreover, AWS will charge a fee for each used service, and it is likely that the benefit of serverless cost savings will be lost.
Rebuilding B2B eCommerce Platforms from Dedicated Servers to Serverless
The debatable question remains of how to rebuild an existing B2B eCommerce platform to serverless computing and what is better — trying to run the platform on serverless hosting “as is,” or start a software development project to rewrite the application code, and optimize the code to a specific serverless hosting provider.
Since development work is very expensive, the first step will always be to assess whether your eCommerce application could work as serverless without any code changes. That would be the best solution for the pilot phase, when a company can evaluate the pros and cons of serverless computing for its business.
In most cases, you have to be prepared for a project like building a completely new B2B ecommerce platform as a serverless one. Many of today's commercially available ecommerce platforms that are on the market have been developed as monolithic applications. Their monolithic architecture prevents serverless launch. Otherwise, you should investigate the possibility of running your ecommerce application hosted by serverless computing providers such as Azure Functions, AWS Lambda, and Google Cloud Functions. There are local hosting providers that also offer serverless hosting these days.
In our blog article “How We Launched Virto Commerce B2B eCommerce Platform in Serverless Mode on Azure Functions”, we describe the full way for preparing our B2B platform backend for running in serverless mode. This experiment was successful, but many developments are required to make Virto Commerce Serverless platform available as a commercial product.
One of the Virto Commerce Serverless drawbacks was a significant delay during a cold start, and below we list some of the most significant serverless drawbacks for B2B ecommerce.
Serverless Computing Drawbacks for eCommerce
There is no technology without drawbacks, and serverless computing has some as well. Below we give a list of such drawbacks or, more correctly to say, challenges, since with the technology progress, they will be fixed in some way.
In practice, the cold start latency depends on many parameters. This includes the language in which the function is written, the number of libraries to be used, the size of the code, and the time and complexity of the access to additional resources (database, authentication server, CMS, etc.). Developers are aware of such parameters and can shorten the cold start delay by manipulating them. On the other hand, the developer cannot control the launch time of the container with the function to run, and here everything depends on the servers and virtualization software working in the data center of the serverless hosting provider.
The next disadvantage of serverless computing is the short lifetime of the function (the timeout in which the function must be executed). If you have to work with long-lived tasks, you can use a hybrid architecture which combines serverless applications with virtual machines or dedicated server technology.
How can this work? For ecommerce, it is possible to use serverless computing as a load balancer. Let's say there is an online store that has visits from 50 users per hour. A low-end virtual machine with suitable hardware characteristics can be sufficient for this load. From time to time, though, the load on the store increases significantly. Then the virtual machine will be overloaded and can deny access to the store.
In such a situation, we can optimize the system through a hybrid approach: we leave one virtual machine behind the load balancer and put a link to a serverless endpoint with functions. If the load exceeds the threshold, the balancer launches instances of serverless functions that take over part of the request processing.
Thus, serverless computing can be used when, not too often, you intensively process a large number of requests. In such a case, running serverless functions is more profitable for a short time than constantly keeping and paying for a powerful virtual machine or server all the time.
Serverless technology is undoubtedly a technology with a bright future. With all the advantages of serverless computing, the first step before implementation is to evaluate the application logic and understand what tasks can be executed in serverless mode in a particular case.
New serverless hosters such as Azure Functions remove barriers between code and execution, so developers can quickly jump to fast coding and deployment without burdening their infrastructure. The shift in responsibility for managing the IT environment from the development team to the cloud provider is poised to define a new trajectory for every market niche in today’s digital age.