Not long ago, we moved our applications to cloud architecture. Our servers have become more like lightweight virtual machines (VMs) inside large data centers. Now we’re on the brink of a new approach – getting rid of the server completely and running just the business logic in the cloud. In this blog post, we share what we learned in this space recently. It should enable you to decide if serverless infrastructure is your cup of tea.
What is Serverless?
The term “serverless” is a bit exaggerated. There’s no app on the market that will run in a void. The intention behind serverless is to avoid infrastructure overhead and responsibility for the whole server maintenance, when in fact only the business logic is of interest to you.
A better name for this kind of solution would be Function as a Service (FaaS). Instead of building an app as a huge artifact deployed in the cloud (or bare metal), you release separate functions and hook them up with the universe with protocol connectors (HTTP, MQ, etc). The whole solution gravitates towards the “convention over configuration” approach on the level of the whole project
Serverless (or FaaS) significantly reduces the burden usually put on designing and implementing the infrastructure architecture since it’s the service provider who takes full responsibility. In theory, you should be able to focus solely on business goals. Your custom functions are supposed to reflect the features of your product instead of all the juggling with boring and repetitive technical tasks.
Our Experiences with Serverless
More and more public cloud providers offer FaaS services, with main players including Google Firebase, AWS Lambda, Azure Functions, Alibaba Function Compute. Instead of diving into detailed comparisons of these providers, I would like to share a few takeaways from our recent projects done using the serverless approach. To make it as easy as possible, I gathered the key points to consider in favour and against serverless.
Pros of Serverless
No servers to manage (obviously!)
Limited fixed costs – you pay only for used time
Automated scaling and balancing
Automatic failover (or, at this level of abstraction, no failover problem at all)
Security easier to provide and audit
Low overhead at the start (with the certain level of knowledge)
Short time to market
Easy handover - deployment coupled with code
Perfect choice for lean startups with fast-paced iterations
Augmentation for the classic cloud, server(full) approach
To sum up, serverless can provide a fast and easy way to deploy your business logic in the cloud. Scaling is taken care of, the cost is correlated with the consumption and you managing authentication and infrastructure doesn’t give you a headache (or you get it less often). However, there are no perfect solutions…
Cons of Serverless
Not much know-how and best practices available about structuring the code and projects on the market
Not suitable for complex business logic due to the risk of producing highly coupled code
Cost difficult to estimate (helpful tools: serverlesscalc.com)
Difficulty in migration to other platforms (Vendor lock⚠️)
Little engineers with experience in serverless on the job market
Steep learning curve for engineers without any cloud experience
Recommendations
After a few projects involving serverless, we’ve gathered a few insights:
First of all, don’t be afraid of the serverless approach – it’s just a different application architecture with nothing scary about it.
When you’re taking your first steps in serverless, don’t bite off more than you can chew. It’s safer to pick a small, individual and well-defined problem to minimize the learning curve.
Give your engineers some time to play with it and get familiar with the concept of serverless apps.
Wrapping up
Now that you know the pros and cons of serverless, it should be easier for you to decide if this approach right for your project. Even if you’re not sure about it right now, it’s a good thing to stay up to date with further development and new use cases, which might show unforeseen benefits for your product.
In the future, we will write some tutorials how to avoid highly coupled code for serverless, so stay tuned!