Serverless architecture is one of the most cutting edge and advanced approaches to cloud computing today. With a serverless architecture, you can serve your application or workload literally without servers. Learn how a serverless architecture works and when you might use a serverless architecture.
- How can you have no servers?
- When do you use a serverless architecture?
How can you have no servers?
Serverless architecture uses advancements in application design, development tools, and function-as-a-service to build a complete application experience on an entirely on-demand basis.
Of course, there are servers behind the systems, typically part of a cloud based infrastructure like our IaaS. The concept of “serverless” comes from the user’s standpoint and not having to worry about those details.
Serverless application design
Your application must be designed from the beginning for a serverless architecture for the best results. Serverless applications are the most commonly dynamic mobile or web applications that are served from Content Delivery Networks or Static Web Hosting on a cloud storage platform like Ceph.
This is in contrast to more traditional styles of application development where the application’s HTML, CSS, and client-side code is dynamically generated for every single visitor. Dynamically generating the page when a visitor requests the page requires a server to process the request and run the code to generate the page. This is commonly how PHP and Python web applications function.
Function-as-a-Service is one of the most significant innovations in cloud computing. You can use FaaS to service requests for data or processing that would normally be handled by a persistent server application without the server and in an entirely on-demand fashion. To use function-as-a-service, you define cloud functions that each execute a single bit of code for a specific task, and your application sends HTTP requests to the service provider to trigger specific cloud functions instead of sending requests to a persistent HTTP API server.
With function-as-a-service you can literally only use the resources your application uses. There are no idle resources or wasted utilization with function-as-a-service because each cloud function only lasts for as long as it takes to process the request. The CPU and memory (RAM) resources are released as soon as the function completes its job.
With a serverless architecture, cloud functions replace the HTTP API server. Your server-side code has to be engineered to support an extremely strict microservices architecture where every task normally handled by a persistent server is broken down into blocks of code that can be executed as a cloud function.
Other features like authentication, firewalls, and caching are handled by the function-as-a-service platform and are defined and managed separately from your cloud functions.
When do you use a serverless architecture?
IT Departments are often called on to provide all kinds of resources and serverless architectures will fit in this as well. As those services can be tricky to keep track of, you will want a solid governance model. Additionally, you will have a centralized infrastructure, ideally IaaS or object storage on demand, for data storage of your application that is stateful. This is typically very different usage patterns so be ready to do both.
Serverless architecture is a great fit for applications that can run entirely within users’ browsers or on mobile devices. Much of the processing and work for the application can be pushed onto the users’ own devices instead of application servers or databases. Distributing your application’s workload to your users’ devices instead of application servers you run helps make your application or platform much more scalable while still giving your users a responsive, high-performance experience.
Serverless architecture is also excellent for applications that need to be quickly accessible for users in different parts of the world. Serving your application’s code from a Content Delivery Network should mean that users anywhere on the planet can quickly load your application, and many function-as-a-service providers have localized services around the world for providing cloud functions closer to users in different parts of the world.
A serverless architecture can also be significantly cheaper than other architectures that are dependent on persistent servers for serving application code or processing application requests. Content Delivery Networks and Static Web Hosting are usually significantly cheaper for serving your application than running your own servers because serving static files is extremely easy and efficient to do, especially at large scales.
Using function-as-a-service instead of a persistent also ensures that you only pay for the resources that you use to service your users’ requests and nothing else. If you were to use a persistent server instead of function-as-a-service, you would still have to pay for the server during all the times your users are not making requests or using the server’s resources. As products and applications grow, these resource costs can quickly become very expensive.