Hosting without a server? Meet Serverless, and see how you can take advantage of it
26 Nov 2020Software Architecture
When you want to host your application, you need a server. It’s a given, right? Or IS IT? Serverless is a different approach that might be the most cost- and performance-effective for your project.
Serverless is a somewhat mysterious solution on the surface, which actually turns out approachable and worth checking out. In this article, we will explain how it works, how it compares to other hosting solutions, and when you can gain the most by choosing it for your project.
“But hey,” you might say, “if it’s so good, why haven’t I heard of it before?”
The answer is quite simple: because it’s just started to enter the mainstream. Even though the technology itself has circulated in the industry for around 4 years, the hype is still building. More and more software houses are adopting Serverless every day. And you know how it is with early adopters. When the tech is good, they’re the ones to profit the most.
What is Serverless all about?
By definition, Serverless is an approach to programming that makes it unnecessary to maintain servers. The application runs in the cloud, where the code gets executed directly.
Of course, making anything 100% server-free is impossible, since the cloud itself is a server. Still, Serverless makes it 100% server-free for you. The cloud administration takes care of configuration and maintenance.
Serverless is the next natural step in the evolution of apps. From having to buy a physical server to IaaS (Infrastructure as a Service), where you just configure the OS and app on a server that someone provided, to Serverless, where you forget even about this part.
The Serverless architecture requires you to do only the work that counts. You create the application functions, and that’s it. Your Serverless provider makes sure the data exchange and scaling work as intended. Many SaaS (Software as a Service) products are based on Serverless. Take something like streaming platforms as an example. Do you watch The Mandalorian on Disney Plus? Then you get the software from the cloud. However, do not confuse SaaS with Serverless services, since the former is a product and the latter is a way to build it.
How does Serverless fare when compared with other models?
By “other models” we mean IaaS, which we already mentioned, and PaaS—Platform as a Service; basically a cloud-based virtual environment for app development.
An example of an IaaS solution is AWS EC2 (or Amazon Web Services). AWS has the services to help you build sophisticated applications with increased flexibility, scalability, and reliability. It has been recognized by Gartner as the recommended approach for running enterprise applications that require high availability.
Other IaaS examples: Cisco Metapod, Microsoft Azure, Google Compute Engine (GCE), Digital Ocean.
Alternatively, a popular example of PaaS includes Google App Engine, where we can build highly scalable applications quickly using popular languages, libraries, and frameworks. It’s an environment that manages infrastructure concerns. App Engine automatically scales depending on your app traffic and consumes resources only when your code is running.
Other PaaS examples: Salesforce, Heroku, Force.com, Apache Stratos.
The main difference is that Serverless lets you focus on the code without worrying about how it’s going to act once you upload it to the server. You don’t have to configure your app for the expected load. All the while, PaaS and IaaS require you to have a DevOps team to make sure everything scales properly.
Why don’t we visualize it? PaaS and IaaS let you build a Lego block structure. You create a full application with all the functions you need to be combined. Using Serverless, you just send separate Legos to the provider and they combine it into an app. The provider can scale it at the level of any single function—which is helpful when one of them is significantly more popular than the rest.
“I outsource development. Why should I care about Serverless?”
That’s a great question. The answer is: Yes. Oh, yes. Even double so!
It might seem that since you hired an external software house to handle development, you shouldn’t care what methods they use. You expect it to be done and work well, period. Understandable. However, consider this: since Serverless doesn’t require having a DevOps team, shouldn’t using it lower the cost of your project? And also: are you sure you’re going to want to outsource your app forever?
If one day you need to handle it directly from your company, you can transfer the duties easily—without creating an additional DevOps team. This makes Serverless a more feasible solution, especially if your app doesn’t boast a huge number of users.
How Much Money Can You Save By Going Serverless?
One of the biggest arguments for going serverless is the substantial cost reduction you can experience. Since the whole essence of serverless is that you only pay for the time your code is executed, it will result in a noteworthy lower AWS bill (in most cases). Sounds too good to be true? Let’s see:
The reason to consider Serverless is its flexible pricing model.
In IaaS/PaaS, you pay for the time when your app is working and available to users. If you own Uber Eats and want it to be available 24/7, then you pay for each hour when it’s online and standing by for a connection from users. Essentially, you keep paying regardless if the app is in use or not. To scale, you need to add new virtual machines (IaaS) or create new app instances (PaaS). For Uber Eats, that is ok; the site is probably used by someone every minute, every day.
But what if your app isn’t so popular and global yet?
In Serverless, if it ever happens that your app isn’t used by anyone for a few hours—you don’t pay for that. For such cases, Serverless is ideal because you only pay for how much your app is actually used. It means that you pay for the amount requests the app gets and for milliseconds of CPU and RAM work.
A typical AWS serverless stack has a few cost components: Lambda, API Gateway, DynamoDB, and often S3 & CloudFront. Lambda is now the most popular Serverless solution, so let’s use it as an example of pricing.
AWS Lambda Pricing
- You are charged for the total number of requests across all your functions. Lambda@Edge counts a request each time it starts executing in response to a CloudFront event globally.
- 0.20 dollars per 1 million requests
- 0.00001667 dollars for every GB-second of computing, with every execution rounded up to the nearest 100 ms
You can read more here AWS Lambda page.
Comparing costs between AWS Lambda and EC2 (IaaS)
Serverless isn’t a solution for every situation. In some circumstances, an IaaS solution like EC2 can serve you better. That depends on the amount of traffic your app is getting.
- For most periodic or very light workloads and low-traffic, Lambda is dramatically less expensive than even the smallest EC2 instances.
- Focus on the memory and execution time that a typical transaction in your app will need to relate a given instance size to the break-even Lambda cost.
In other words, your app needs to be really, really popular for Lambda to be a bad choice. Your app needs over 7 million daily requests for Serverless to be more expensive than IaaS.
We’re not mentioning the cost of ownership here. There is no autoscaling, clustering, or load balancing to build & manage, no containers to create and ship, no security patching. So even if Lambda can be more expensive than EC2, in some cases, there is still a strong reason to use it.
Let’s sum it up
At this very moment, Serverless isn’t the hot new thing just yet. But it keeps gaining popularity in the software development industry. We expect it to truly catch on in the following years. Its main advantage is a sharp focus on functionality, and functionality only. You deliver the functions, the provider takes care of the rest. Even of scaling on the function-to-function basis.
If you aren’t completely convinced just yet, here’s our last surprise. In Serverless, you pay for the actual use of your app. That’s right, no more payments for idle servers. That’s the very definition of cost-effective. For the CIO, the message is that serverless changes the economic model of cloud computing, with the hope of introducing cost savings. Adding to it the performance-effectiveness one should consider it as a practicable architecture for software.
fireup.pro is an official Amazon Web Services Partner in the implementation of cloud computing. We have the necessary knowledge, know-how, and certified experts, providing high-quality services. Read about how we became the AWS Partner.
The presented content was written by our experts and is based on our company's experiences.