Serverless computing is a cloud computing execution model where the cloud provider dynamically manages the allocation and provisioning of servers. A serverless application runs in stateless compute containers that are event-triggered, ephemeral (may last for one invocation), and fully managed by the cloud provider. The serverless provider automatically scales container instances out and in to match demand. The core value proposition of serverless architectures is that the business logic code is focused on the problem to be solved and nothing else.
With serverless computing, the key advantage is that developers don’t have to think about the underlying infrastructure or operations required to run the code. The cloud vendor takes care of provisioning, load balancing, networking, autoscaling to match workload, etc. Serverless helps teams increase their development velocity. It enables a pay-per-execution model that can be more cost-effective than continually running containers, virtual machines, or physical servers.
Benefits of Serverless Computing
There are several benefits to using serverless architectures:
- Scalability – Serverless computing removes the need for developers to worry about scaling. The infrastructure dynamically scales up and down based on usage, so resources are never sitting idle.
- Cost savings – With serverless, you are charged for execution time rather than uptime. This can significantly reduce costs compared to always-on servers.
- Faster development – Serverless removes the need for complex infrastructure setup and configuration. Developers can focus on writing code.
- Flexibility – Serverless functions can be triggered by various events, like HTTP requests, database changes, queuing services, monitoring alerts or on a schedule. This makes applications more flexible.
- Operational efficiency – Serverless offloads server management, capacity planning and maintenance to the cloud provider. There is minimal administrative overhead.
Serverless Computing Services
The major cloud platforms offer various serverless computing services:
- AWS Lambda – Run code in response to AWS events and services, like S3, DynamoDB, Kinesis etc. Lambda manages compute resources.
- Azure Functions – Event-driven serverless functions that can be triggered by Azure services, like blob storage, queues etc.
- Google Cloud Functions – Functions executed in managed environments in response to events from Google Cloud services.
- Netlify Functions – Write code that responds to events like HTTP requests, scheduled jobs etc on Netlify’s platform.
- Vercel Serverless Functions – Functions deployed on Vercel’s edge network that can be invoked via API routes and triggered by a variety of events.
Serverless Use Cases
Some common use cases well suited for serverless architectures:
- Web applications – Serverless is great for REST APIs, dynamic sites using JAMstack and backends for mobile/web apps. It removes load balancing, scaling concerns.
- Stream processing – Serverless integrates natively with managed services like Kafka, Kinesis etc. Useful for data pipelines.
- Scheduled tasks – Cron jobs, backups, cleanups etc can be run via scheduled triggers without managing servers.
- Image/video processing – Event-driven processing of uploaded images, videos e.g. thumbnail generation, transcoding.
- Real-time file processing – Trigger serverless functions in response to file uploads to process and store them.
- IoT backends – Serverless functions can easily scale to handle high volumes of events/data from connected devices.
- Chatbots/NLP – Serverless natural language and chatbot APIs make good use of elastic scaling.
- Webhook triggers – Serverless functions invoked by webhooks from SaaS platforms, payment systems etc.
While cloud providers offer serverless platforms, there are also open source frameworks that make building serverless apps easier:
- Serverless Framework – Supports multiple clouds. Helps organize and deploy functions, resources, plugins.
- Apex Up – Open source framework for building production-ready serverless apps on AWS Lambda.
- Claudia.js – Deploy Node.js microservices to AWS easily. Handles packaging and API configuration.
- Zappa – Build and deploy Python serverless apps on AWS Lambda and API Gateway. Adds features like rollbacks.
- Chalice – Python microframework from AWS to quickly create and deploy serverless apps.
- OpenFaaS – Kubernetes-native open source serverless framework with Docker/K8s underpinnings.
- Kubeless – Kubernetes-native serverless framework to deploy functions and auto-scale them.
- OpenWhisk – IBM’s open source distributed serverless platform built on top of Kubernetes.
Serverless vs Containers
Both serverless computing and containerization approaches like Docker have become popular for deploying cloud-native applications. Some key differences between the two:
- Serverless automatically scales individual functions whereas containers scale by running multiple copies of the same image. Serverless autoscaling is more granular.
- Containers are always running while serverless functions only run when triggered. Serverless can be more cost-effective for sporadic workloads.
- Serverless abstracts away infrastructure management. In container approach, developer handles deployment, networking, scaling etc.
- Containers are better suited for long-running stateful applications while serverless excels for event-driven stateless workloads.
- Serverless functions can provide faster cold start times than containers which have to boot up their runtime environment.
- Serverless simplifies development while containers offer operational consistency across development, testing and production.
Many real-world applications use both serverless functions for specific tasks and containerized microservices for others based on their strengths. The two approaches complement each other in cloud-native app architecture.
Drawbacks of Serverless Computing
There are some downsides to the serverless model that need to be considered:
- Vendor lock-in – There is typically significant vendor lock-in when using proprietary serverless platforms like AWS Lambda or Azure Functions.
- Cold starts – When functions invoke after being idle, there can be significant cold start latencies as the runtime initializes.
- Debugging difficulties – Distributed tracing and monitoring can be harder with serverless functions spread across environments.
- No long-running processes – Serverless functions meant for short tasks. Not ideal for long-running apps.
- Architectural complexities – Complex integration required across events, triggers, functions and services in large serverless architectures.
- Resource limits – Compute memory/disk resources per function are capped by providers to manage scaling.
- Testing challenges – Broad range of testing scenarios needed covering provisioning, triggers, integrations, timeouts.
- Monitoring overhead – Fine-grained monitoring required given ephemeral nature of serverless functions.
Impact of Serverless on Web Hosting
The rise of serverless computing has had significant impacts on the web hosting industry:
- Reduced importance of servers – Serverless shifts focus away from servers to code. Hosts have to adjust offerings.
- New hosting options – Some hosts now offer serverless specific plans or platforms to support these workloads.
- Pressure on pricing – Hosting costs can appear relatively high compared to serverless pricing models. Forces hosts to compete.
- Declining traditional hosting demand – As sites move to serverless, demand for traditional hosted servers drops.
- Focus on automation – Hosts adopting more automated server management to compete with serverless convenience.
- Kubernetes adoption – Container orchestration framework Kubernetes has become popular with hosts to support microservices.
- Edge computing focus – Hosts leverage edge locations to counter cloud provider network effects.
- Multi-cloud support – Support for multiple clouds rather than a single platform to prevent lock-in.
- Function-level metrics – Hosts provide deeper function-level performance monitoring rather than just servers.
- Partnerships with cloud providers – Some traditional hosts now partner with major cloud players to attract hybrid cloud users.
The Serverless Revolution
Serverless represents a huge shift in cloud architectures, development workflows and operations. It enables developers to focus on writing code rather than managing infrastructure.
The on-demand resource model is attractive from agility, efficiency and cost standpoints. Serverless adoption is growing rapidly as its benefits become clearer.
It is also driving a major evolution in web hosting, pushing providers to adjust their offerings, pricing and support services. Traditional hosts now have to compete on automating infrastructure management.
Going forward, serverless will likely become a standard part of modern application deployment alongside containers and microservices. It provides a compelling abstraction layer for cloud-native development.