Serverless 详解
Serverless 是什么?
Serverless computing is a cloud computing execution model in which the cloud provider runs the server, and dynamically manages the allocation of machine resources. Pricing is based on the actual amount of resources consumed by an application, rather than on pre-purchased units of capacity. It can be a form of utility computing. — wikipedia.org
Serverless architectures are application designs that incorporate third-party “Backend as a Service” (BaaS) services, and/or that include custom code run in managed, ephemeral containers on a “Functions as a Service” (FaaS) platform. — 《Serverless Architectures》
无服务器架构是基于互联网的系统,其中应用开发不使用常规的服务进程。相反,它们仅依赖于第三方服务(例如 AWS Lambda 服务),客户端逻辑和服务托管远程过程调用的组合。 — 亚马逊 AWS 官方博客
Serverless(无服务器架构)是指服务端逻辑由开发者实现,运行在无状态的计算容器中,由事件触发,完全被第三方管理,其业务层面的状态则存储在数据库或其他介质中。 — 《无服务架构实践手册》
If your PaaS can efficiently start instances in 20ms that run for half a second, then call it serverless. — Adrian Cockroft
优缺点
优势
低成本
运维成本
服务器、中间件、数据库等均托管于 BaaS/FaaS 平台,用户无需再参与基础设施及软件的维护,省去了集群的运维成本
开发成本
对比 IaaS 或者 PaaS 平台的服务器或者操作系统,Serverless 的架构中,用户操作的是服务化的组件,比如存储服务、授权服务等,可以缩短开发周期,节约时间成本
按需计费
Serverless/FaaS 区别于 IaaS/PaaS 预先分配计算资源的计费方式,其计费方式通常是按请求次数及运行时间。如此一来,不仅可以最大程度地利用资源,还能实现真正的按需计费,以降低用户的使用成本
高扩展
自动进行横向扩展(毫秒级部署,秒级生命周期)
高资源利用率
提供细粒度的计算能力,最大限度满足实时需求,使得资源利用率大幅度提升
NoOps
运维的发展经历了,人肉运维、自动化运维、DevOps、AiOps 等。而 Serverless 模式下,用户只需要关心业务编码,真正实现了零运维成本