Insights | Development

A Serverless Website? Can Do!

20 April 2020

At Dodgems & Floss we like to experiment with the latest technology and techniques so we can provide the best service for you. Our latest experiment is serverless web hosting.

Serverless web hosting?! Not possible we hear you cry! Websites are hosted on web servers, you can’t host a website without a server?!  And you’d be right to a degree,  but please allow us to explain what we mean by serverless vs traditional hosting.

When you run a serverless environment, web requests are received initially by a load balancer, which sounds complicated but you can think of it as a digital receptionist.  Every time a request is received it starts a temporary lightweight stripped-down web server instance, the instance fulfills the request, and then it stops existing.

This server instance only exists for the period needed to service the request, the rest of the time your servers aren’t running. This has a number of advantages over a traditional server-hosted environment:

Scalability

You can scale from one visitor to thousands of simultaneous visitors and back again automatically, as many instances as are needed can be started almost instantaneously and you’ll only run the instances that you need to handle those requests for as long as they’re needed.

By comparison in a traditional hosting environment, you’d need to upgrade your server regularly to keep up with demand or keep multiple servers running 24/7 and balance the load between them, but this can work out to be very expensive.

Cost

You are only charged for the time that your instances are running, so no more paying for an idle server wasting electricity to wait for a user to request a page.

Reliability

Normally with a website you have to constantly monitor for memory leaks, remaining hard drive space, general server health, etc.  serverless instances are different.  Every instance only runs for a very short period of time, and media and database storage are delegated to fault-tolerant cloud systems with multiple redundancies most of these traditional issues are automatically addressed.

The load balancer itself is a distributed cloud-based fault-tolerant system to avoid being a single point of failure. If you need additional protection against a data centre outage you can even spread your serverless instances over multiple areas of the world.

Serverless is a powerful tool, but it’s not perfect.  There are some cons too.

Complexity

For performance reasons the server instances have to be very efficient and streamlined, It takes time and planning to ensure that external dependencies are kept to a minimum, this complicates the set configuration up and design process.  

Separation of media and database storage 

On a traditional web server you’ll often find that the database and media are served by the same server as the webserver, this is not advisable when using a serverless environment for efficiency reasons.

External media storage and a cloud-based database should be provided. Media can then be accessed in parallel without having to start more serverless instances, and having a single external database permits all the instances to retrieve the same information no matter which instance deals with your request.

Due to the above reasons serverless isn’t for everyone, but for many the scalability and reliability it offers will be worth the additional layer of complexity.

If you’d like a serverless based solution for your business, get in touch!

Published by

Michael East

Full stack developer