September 5, 2019

AWS Lambda’s free tier is the best way to host your websites for free — isn’t it?

AWS Lambda’s free tier is the best way to host your websites for free — isn’t it?

When it comes to a serverless approach, everyone talks about its main benefit: the cost savings. In this blog post, I will compare AWS Lambda’s free plan to the free plans of other app hosting providers. I’m going to provide real numbers to see how much a user can get from the most popular serverless hosting platform and its competitors without even paying for it.

Comparing the free plans

The average size of a typical HTML page with media assets is about 3MB. I’m going to calculate how many requests for a typical HTML page that AWS Lambda, Heroku and Netlify can serve while still on their free plans.

Important note: The typical HTML page with all its media assets and CSS/JS scripts must be bundled into a single file. Otherwise, there will be a lot of additional requests that will make the calculations much more complicated and lower the overall effectiveness of using the free plan.

A single-file bundle is easily achievable with simple websites like landing pages or blogs. CSS and JS can be injected directly into HTML and images can be converted into SVG, which can then be injected into HTML or CSS as well. There are also effective tools like https://github.com/remy/inliner that allow seamless bundling of the entire contents of a web page into a single HTML file.

Straight to the numbers

Netlify

Netlify does a great job making the deployment pipeline as simple and smooth as possible. With a couple of mouse clicks, a website can be published online right out of a Github or Bitbucket code repository. But they don’t stop with just hosting services; they also offer a set of configurable integrations for your website, like user identity management systems and forms.

Now let’s see how many requests to your website Netlify’s free plan can serve. Their starter plan has a bandwidth limit of 100GB per month, and as we already mentioned, the typical HTML page is 3MB.

100GB bandwidth means more than 34k requests monthly
100GB bandwidth means more than 34k requests monthly

More than 34k requests per month translates into 1,000 daily visitors on average. If your landing page converts at 1%, you can generate 10 leads monthly without even paying for hosting.

Heroku

This is another big player in the field of cloud hosting. Heroku appeared on the market a long time ago as an app-hosting solution. They done merely host websites, though. They also provide solutions for deploying and serving apps for platforms such as node.js or python. Like Netlify, they allow for Github/Bitbucket integrations for seamless deployment right out of the repo.

When it comes to limitations, Heroku’s limits are more about computation. But I can assure you that the limitations of the free plan are more than suitable for single-page website.

512mb worker is more than enough for a simple HTML-page
512mb worker is more than enough for a simple HTML-page

All of their plans have the same bandwidth limit of 2TB, which equals almost 700,000 requests per month.

Much better than Netlify
Much better than Netlify

This is 20x times higher than Netlify! I think almost any landing page you can imagine could be hosted on the Heroku. The big question now is whether or not AWS Lambda can beat these limitations.

AWS Lambda

Amazon released its service called Lambda in 2014. Back then, it was the first of its kind — namely, application hosting that didn’t require a server setup. A user can simply write some code in the form of a regular function in a supported language (like Java, JavaScript, Python, or many others supported to date) and host it on AWS Lambda “as is.” AWS Lambda does the rest, calling the function and autoscaling its resources when the number of requests goes up or down.

The function can do anything, including perform calculations, call other AWS services, or return an HTTP response object. Lambda calls are event-based, which means that the hosted function will be called when a particular event occurs (like an HTTP request or an upload to S3).

Now let’s estimate how many requests Lambda can serve. Surprisingly, this is very simple — 1,000,000 requests per month, according to the official website. One million! If that is not enough for you, then here is another thing — the Lambda free tier is permanent, which means it doesn’t expire in 12 months like some of the other AWS services!

AWS Lambda allows for 1,000,000 requests monthly!
AWS Lambda allows for 1,000,000 requests monthly!

One million requests without an expiration period make the Lambda the absolute champion of free hosting. Within these limits, you can easily host a few of your single page websites for free — forever. As a bonus, you get seamless integration with many other AWS services, which is really great and opens limitless possibilities for scaling a project!

Are there any caveats when using AWS Lambda?

Even though there is no server setup, deploying on AWS Lambda can be a bit tricky compared to Netlify or Heroku, which merely pull a code from a repository. In order to deploy on Lambda, you need to upload your code onto AWS S3 and do some configuration of the Lambda service to point it to the uploaded code. There are several approaches to automate the process, but they are trickier than just pulling a code from a repository. With tools like https://serverless.com, you will need the help of a developer or devops specialist in order to put your website online.

What are serverless functions best used for?

As mentioned previously, serverless functions perfectly suit static websites. They can serve your blog, or a landing page, or a simple company website with a few pages and a couple of forms for lead generation. Any sort of HTML/CSS/JS can be served by AWS Lambda or similar implementations of serverless functions.

Lambda can also serve the other side of a website: the API. It can perform DB requests, call 3rd parties, process uploaded files, and more. It can scale resources up and down on-demand automatically, so you don’t need to set up and maintain a resource-and-money-consuming computational cluster.

But why are we just talking about static websites and API when lambdas can do so much more? Lambdas are computational primitives, which means they can do almost anything you want. There are some platform restrictions, but generally, you are only limited by the programming language that the serverless functions are coded in. Don’t forget that serverless functions are deeply integrated into the infrastructure of a cloud hosting provider (e.g., within AWS Lambda you can access all the available AWS services). You can create a lambda that takes your photos, finds persons in the images, and saves this information in the DB. It works in the following way:

  • Take an image uploaded onto AWS S3 cloud storage.
  • Perform face recognition over the uploaded image with AWS Rekognition.
  • Put results into PostgreSQL DB hosted on AWS RDS.

All the operations are performed within AWS cloud, with a seamless vendor SDK for every piece of the puzzle.

Conclusion

It sounds unbelievable, but with some extra configuration, a few tweaks to the deployment process, and a few simple tools, you can host some of your websites or web apps for free — forever! Free tiers of cloud hosting providers fit the needs of any web app or small website (and sometimes medium websites).

The most mind-blowing thing is that this is true not only for simple bare-bones websites but also for apps that use databases for storing data or facility services like emailing. If you’ve never done it before, then have a look at the free tiers of AWS or Google Cloud. It is truly amazing how much computing power you can get for free nowadays!

Artem Rudenko
Artem Rudenko
Software engineer, founder of ottofeller.com

Let's build a thing together!