暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

理解Serverless概念、和传统开发模式区别以及优缺点

小雨青年 2021-06-15
627

前言

Serverless并不是说没有服务,而是作为开发者不需要去管服务器相关的东西,比如配置、带宽、负载。


开发者只需要关注功能实现,把服务托管出去,按使用量支付服务相关费用,做到Serverless。


什么是Serverless

关于最早概念的起源,建议阅读这篇文章


https://martinfowler.com/articles/serverless.html


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. By using these ideas, and related ones like single-page applications, such architectures remove much of the need for a traditional always-on server component. Serverless architectures may benefit from significantly reduced operational cost, complexity, and engineering lead time, at a cost of increased reliance on vendor dependencies and comparatively immature supporting services.


这篇文章详细讲了Serverless的概念和优缺点,我下面通过自己的理解描述下,如果想要更完整地理解,还是推荐阅读原文。


概念

服务器的管理交给第三方平台,开发者不维护服务器。


后端即服务(Baas) + 函数即服务(Faas)


优点

  • 专注业务开发

  • 服务器费用避免闲时浪费

缺点

  • 更加依赖服务提供商

  • 安全问题

  • 迁移到其他服务提供商成本大幅度增加

  • 增加了测试难度

  • 与传统互联网公司开发模式的区别

目前现代互联网公司也在广泛使用Baas模式的服务,比如CDN、防火墙等,所以Serverless的区别还是在Faas的方面。


传统互联网模式

  • 服务器运行项目,比如 nginx 。

  • 代码托管代码库,比如 gitlab 。

  • 使用第三方服务,比如 COS文件存储、CDN 。

Serverless模式

  • 使用第三方服务,比如 COS文件存储、CDN 。

  • 使用Faas服务,托管业务相关代码

  • 使用并依赖网关服务,分发请求

  • 使用并依赖监控服务,监控运行状况和日志


现有的Faas函数即服务

腾讯云 云函数 SCF

腾讯云的SCF就是Faas的核心部分,实现了云函数的运行部署。

再结合腾讯云的其他服务,我们就能构建出一套Serverless的架构。

阿里云 FC

亚马逊 AWS Lambda


openfaas/faas

和上面不同的是,openfaas是开源项目。


总结

本文主要是认识Serverless,理解必要性和重要性,并列出几个现有的Faas服务提供商。


参考资料

  • https://github.com/openfaas/faas

  • https://martinfowler.com/articles/serverless.html

  • https://aws.amazon.com/cn/lambda/

  • https://serverless.cloud.tencent.com/

  • https://github.com/openfaas/faas

  • https://www.openfaas.com/

  • https://www.aliyun.com/product/fc



文章转载自小雨青年,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论