Serverless: advantages and disadvantages

House icon

Published June 08, 2017

<p><span style="font-size: 12pt;">The term <em>serverless</em> grew in popularity as Amazon first launched <a href="https://www.google.se/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;cad=rja&amp;uact=8&amp;ved=0ahUKEwjZoZW4urjVAhXHbxQKHfbyBioQFggnMAA&amp;url=https%3A%2F%2Faws.amazon.com%2Flambda%2F&amp;usg=AFQjCNHjO6kLR29M6rle7MjKqum-YKJfhA">AWS Lambda</a> in 2014. Since then it has grown in both usage and reference, as more and more retailers enter the market with their own solutions. </span></p> <p><span style="font-size: 12pt;">The concept itself is easy enough to understand &#8211; you simply run your application without any servers. But what does that really mean? Surely there must be some kind of server running somewhere? The short answer is yes. Let&#8217;s dig a little bit deeper into the concept itself, some related terms and what running serverless can mean for you and your organization.</span></p> <h2><strong>Do you really run completely serverless?</strong></h2> <p><span style="font-size: 12pt;">Running <em>serverless</em> simply means that you and your organization take no responsibility for maintaining the infrastructure around your application. This includes all application logic, processes, the operating system itself as well as the actual servers (or virtual machines). Using such an architectural structure creates a shift in focus. It allows the organization to instead spend time, money and energy on actual development, something much appreciated by most developers.</span></p> <p><span style="font-size: 12pt;">This means that when you run serverless, a third party is responsible for everything from processes to server operating systems. In short, it means that the developers doesn&#8217;t have to handle dedicated servers or virtual machines. At the same time, the service provider is free to determine their internal infrastructure and how to best meet the client&#8217;s needs. The result is that the provider rarely needs to run a permanent workload for a specific customer, but instead spends time efficiently on certain requests from the customers.</span></p> <h2><strong>Serverless with BaaS and FaaS</strong></h2> <p><span style="font-size: 12pt;">Two different variants you often come in contact with regarding servless is <em>Backend as a service </em>(BaaS) and <em>Function as a service </em>(FaaS). Here are some more details about them.</span></p> <h3><strong>BaaS</strong></h3> <p><span style="font-size: 12pt;">Most modern applications require a web connected backend. BaaS allows you to no longer have to develop your own, a task which often proves difficult to scale. As a result, we see an increased number of third party services implementing functionality and provides logic. This in turn leads to an increase of applications missing app specific server logic will increase &#8211; they instead use these third part service providers. </span></p> <p><span style="font-size: 12pt;">Reducing the need for server-side technology together with backend storage and various other features for smooth integration make BaaS an interesting choice. Some other advantages include:</span></p> <ul> <li><span style="font-size: 12pt;"><strong>Time savings: </strong>Many features such as user management, data storage, queries and search end up saving you a lot of time.</span></li> <li><span style="font-size: 12pt;"><strong>Time-to-market reduced: </strong>Since you won&#8217;t need to develop any backend at all, you end up writing a lot less code, shortening your time to market. </span></li> <li><span style="font-size: 12pt;"><strong>Saves hires: </strong>Using BaaS is almost like you hire a bunch of awesome backend developers, without spending any time on recruiting or training. You can save both time and money this way.</span></li> </ul> <p><span style="font-size: 12pt;">However, running serverless with BaaS is not perfect for every application and will come with a few disadvantages as well. Here are some:</span></p> <ul> <li><span style="font-size: 12pt;"><strong>Less control over the backend of your app: </strong>If you want or need to have full control over every single asapect of the backend your app runs on, BaaS is probably not for you.</span></li> <li><span style="font-size: 12pt;"><strong>Less control over hosted code: </strong>You give up a bit of control over the BaaS hosted code. </span></li> </ul> <p><span style="font-size: 12pt;">A few examples of BaaS platforms are Kumolos, Kinvey, Parse and of course, Azure.</span></p> <h3><strong>FaaS</strong></h3> <p><span style="font-size: 12pt;">FaaS refers to the idea of deploying an individual function, action or any other piece of business logic. The function then processes the individual requests before it ends.</span></p> <p><span style="font-size: 12pt;">When an application still needs specific server logic developers can turn to this modern alternative of a serverless architecture. With this approach, the developers focuses on implementing short-lived functions that communicate both with each other and externally. Everything else is handled by the provider. This includes the creation of enough function instances to meet the client needs, terminating no longer needed instances, keep watch of and maintain logs, etc.</span></p> <p><span style="font-size: 12pt;">Some benefits of running serverless this way includes:</span></p> <ul> <li><span style="font-size: 12pt;"><strong>High volume transactions: </strong>You can easily isolate and scale them.</span></li> <li><span style="font-size: 12pt;"><strong>Highly dynamic workload: </strong>You just pay for the server&#8217;s functions the time you actually use them. This means that you won&#8217;t need to pay for a server around the clock, saving you a lot of money.</span></li> <li><span style="font-size: 12pt;"><strong>Scheduled tasks: </strong>FaaS are a perfect way to run certain tasks in a scheduled way. </span></li> </ul> <p><span style="font-size: 12pt;">Some good examples of FaaS implementations are Auth0 Webtask, AWS Lambda, Google Cloud Functions and Azure Functions.</span></p> <h2><strong>PaaS compared to serverless</strong></h2> <p><span style="font-size: 12pt;">The biggest difference between <em>Platform as a service </em>(PaaS) and serverless is that traditional PaaS providers such as Heroku and OpenShift often lack the opportunity for automatic scaling. Instead, users need to specify the amount of resources needed. This means that in order to scale up, the user needs to change that specification to suit their new needs.</span></p> <p><span style="font-size: 12pt;">Another difference is that most PaaS are designed for constantly running applications. If the application goes down, any incoming requests won&#8217;t be processed. With FaaS the function starts as requests come and are processed. Ideally, the function shouldn&#8217;t demand any resources if there are no requests. According to this line of thinking, traditional PaaS implementations are not strictly serverless. </span></p> <h2><strong>Summary</strong></h2> <p><span style="font-size: 12pt;">To summarize, cloud computing and serverless are interesting concepts that can bring a lot to the table. But every business has different needs and it might not actually be advantageous to run serverless for all your applications. You should consider both the pros and cons:</span></p> <h3><strong>Pros:</strong></h3> <ul> <li><span style="font-size: 12pt;">Shorter time to market and faster releases</span></li> <li><span style="font-size: 12pt;">Lower costs for both operatinos and development</span></li> <li><span style="font-size: 12pt;">Cheaper scaling</span></li> <li><span style="font-size: 12pt;">Decreases the complexity of your application</span></li> </ul> <h3><strong>Cons:</strong></h3> <ul> <li><span style="font-size: 12pt;">Inefficient for constantly running applications</span></li> <li><span style="font-size: 12pt;">You will be bound to your provider. It&#8217;s often hard to make changes in the platform or switch providers without making application changes as well.</span></li> <li><span style="font-size: 12pt;">In order to use their resources optimally, the provider could run multiple customers software on the same physical server.</span></li> </ul> <p><span style="font-size: 12pt;">There are of course more advantages and disadvantages to running any version of serverless. The ones mentioned above are some we&#8217;ve seen many run into, but as every situation is different the challenges and benefits will of course also vary.</span></p> <p>&nbsp;</p> <p><span style="font-size: 12pt;"><em>How does your architecture look? Have you started using serverless, or do you think it&#8217;s better to use on-prem? Let us know in the comments!</em></span></p>