Welcome to 'Back to Basics'.
I'm Boaz Ziniman.
Today we are going to talk about websites.
Something I've been developing for more than two decades now.
In this episode, I'm going to show you a pattern using AWS
to improve your website front-end and to exchange your back-end
with a serverless architecture.
I assume many of you are familiar with the three-tier web application architecture.
This architecture represents a website with a three-tier that many websites follow in some way or another.
We start with the presentation layer.
This is what your site visitors willl see and interact with.
Then, the business logic layer, which has many different roles,
from serving content that will be used by the presentation layer,
interacting with the user using forms, alerts, and more,
and up to managing complex e-commerce operations
like providing a products catalog, managing customers' shopping carts,
providing all the tracking services, and more.
The last layer is the data layer,
used to store the data that is being used by your website.
In many cases this is going to be some sort of a database,
but the data layer can be implemented with other techniques,
such as storing data in memory or in files.
You can run your website on AWS using this three-tier architecture
with virtual servers for your front-end code and business logic
and Amazon RDS for your relation of database service in the cloud.
But, while this is easier comparing to running those servers and services on your own,
this basic set up of one back-end virtual machine and a database service
can scale very fast to a complex set up of multiple virtual machines behind the load balancer
and multiple databases with redundancy and replication
to allow high availability and fast performance.
This is where you can take advantage of the serverless technology
to run your website in a more maintainable, scalable and cost-effective way.
By utilizing the Amazon S3 website hosting feature, you can use S3 as your storage
for all your presentation layers and front-end assets,
such as HTML, file, images, JavaScripts, and media assets.
This will allow you to run static websites with no servers.
But most websites are not static and require some kind of back-end and business logic.
You can build a full scalable serverless website by building REST-based back-end
using Amazon API Gateway and AWS Lambda
and initiate a request this layer from your front-end code using JavaScript.
Connecting API call events to specific Lambda functions will allow you to build
the needed business logic for your application.
For your data layer, you can choose from a variety of databases
and storage services, such as relational databases, NoSQL, in-memory, and more.
Some of them serverless and others fully managed services.
AWS provides a rich AWS JavaScript SDK.
It enables you to access AWS services directly from your front-end code using JavaScript.
Yes, that might save you some of the time and some of the cost associated with
calling API Gateway, but I would really recommend you think about it
before implementing this SDK and calling those services directly.
You might end up DDoS-ing yourself or preventing your application
from doing authentication or authorization,
and you really need this layer of API Gateway between your users
and your back-end architecture.
Why should you implement this pattern?
With this architecture, you will be able to reduce your overhead,
get much more scalable architecture, and you can always scale only parts of it.
Speed is another factor.
This is my personal website, running on WordPress, that I migrated to serverless several months ago.
As you can see, this is running 13 times faster than a traditional three-tier architecture.
And last but not least: cost-effective.
Lambda is built by one millisecond increments
and you pay only for what you use.
That's it.
Serverless websites are my go-to pattern in the last few years
for every new project that needs a website.
Check the links below for more details.
Thanks for watching, and see you next time.