Serverless Overview

concept

  We Serverless dismantling two words for the server and less, to infer word meaning literally as "little servers, also, or no server." Of course, this does not mean there is no application architecture server resources, but through Serverless this form of service, users in the use of the corresponding service, do not care or care less server hardware resources, software resources, stability and so on, these are usually already provided by cloud computing facilities, services and SLA guarantee companies, fully managed to cloud computing vendors. The user only needs to focus on their application code itself, upload function to perform the corresponding cloud computing platform, in accordance with the long run as a function of the amount to pay.

Evolution

  Before the birth of cloud computing, most of the computing resources in the physical machine "bare metal" status, operation and maintenance personnel to select the corresponding specifications of the hardware, IDC room building network, providing complete services, infrastructure investment in hardware and maintenance costs are high .
  After the birth of cloud computing, users can buy cloud host (VM), the underlying physical hardware and network management are handed over to supplier management, multi-user rent a single physical machine, but every cloud hosting for users like a single physical machine, mutual isolation between users. This mode reduces the cost of the user hardware management, platform standing on the angle, we usually call IaaS (Infrastructure-as-a- Service).
  With the rise and development of software CONTAINER calculated by the VM environment to the development of a smaller particle size of the vessel, the vessel can run different software services, PaaS (Platform-as-a -Service) and CaaS (Container-as- a-Service) began to come into view. User platform infrastructure software such as Database, messages, etc. to develop their own applications using the container mirroring build and deploy applications to the platform hosting the final. At this time, the operation and maintenance of infrastructure more sinking, developers only need to focus on infrastructure software and containers.
  Continue to move forward, evolve to run the application to run more fine-grained function, users develop a specific service handler to a function hosted platform, on-demand-related back-end services, developers completed trigger business logic functions by specific conditions calculations. Users do not need to pay for the continued application, pay only the cost of resource consumption resulting function is running, and this is the model Serverless services.
Here Insert Picture Description

Serverless history

Here Insert Picture Description
[Beginning] Beginning
  in 2012, vice president of cloud infrastructure service provider Iron.io of Ken made the future of software, first proposed Serverless concept, the following is an excerpt of the original:

Even with the rise of cloud computing, the world still revolves around servers. 
That won’t last, though. Cloud apps are moving into a serverless world, and 
that will bring big implications for the creation and distribution of software 
and applications.

[Fledgling]
  AWS of Lambda product launches, Serverless officially took to the stage of cloud computing

[Emerge]
  many manufacturers have laaS and Paas admission

【未来已来】
  随着容器技术,IoT,5G,区块链等技术的快速发展, 技术上对去中心化,轻量虚拟化,细粒度计算等技术需求愈发强烈,而Serverless必将借势迅速发展。

业界产品

架构

  如上文的描述,Serverless 架构由两部分组成,即 Faas 和 BaaS。

Faas

  FaaS(Function-as-a-Service)即为函数运行平台,用户无需搭建庞大的服务系统,只需要上传自己的逻辑函数如一些定时任务、数据处理任务等到云函数平台,配置执行条件触发器、路由等等,完成基础函数的注册。

BaaS

  BaaS(Backend-as-a-Service)包含了后端服务组件,它是基于 API 的第三方服务,用于实现应用程序中的核心功能,包含常用的数据库、对象存储、消息队列、日志服务等等。
Here Insert Picture Description

Baas和Paas的区别

  PaaS需要参与应用的生命周期管理,BaaS则仅仅提供应用依赖的第三方服务。典型的PaaS平台需要提供手段让开发者部署和配置应用,例如自动将应用部署到Tomcat容器中,并管理应用的生命周期。BaaS不包含这些内容,BaaS只以API的方式提供应用依赖的后端服务,例如数据库和对象存储。BaaS可以是公共云服务商提供的,也可以是第三方厂商提供的。其次从功能上讲,BaaS可以看作PaaS的一个子集,即提供第三方依赖组件的部分。
  BaaS服务还允许我们依赖其他人已经实现的应用逻辑。对于这点,认证就是一个很好的例子。很多应用都要自己编写实现注册、登录、密码管理等逻辑的代码,而对于不同的应用这些代码往往大同小异。完全可以把这些重复性的工作提取出来,再做成外部服务,而这正是Auth0和Amazon Cognito等产品的目标。它们能实现全面的认证和用户管理,开发团队再也不用自己编写或者管理实现这些功能的代码。

Serverless工作机制

  Serverless 其实是通过事件驱动的,当一个任务被触发时,比如 HTTP 请求,API Gateway 接受请求、解析和认证,传递对应参数给云函数平台,平台中执行对应回调函数,配合 DB、MQ 等 BaaS 服务在特定容器中完成计算,最终将结果返回给用户。函数执行完成后,一般会被 FaaS 平台销毁,释放对应容器,等待下一个函数运行。
Here Insert Picture Description

优缺点

  讲完 Serverless 的基本架构,我们来谈谈它的优点和缺点。

  根据 Serverless 的特性,我们可以总结出以下优点:
Here Insert Picture Description

  同样,Serverless 是一把双刃剑,它也有一些缺陷需要我们了解,以便取长补短:

  • 云厂商强绑定 当你决定使用公有云的 Serverless产品时,它们常常会和厂商的其他云产品相绑定,如对象存储、消息等等,这意味你需要同时开通其他的服务,将导致你的应用与平台强绑定,迁移成本剧增。

  • 不适合长时间任务 云函数平台会限制函数执行时间,如阿里云 Function Compute 最大执行时长为 10
    min,如果你的任务时间超长,那么你需要拆分编排你的函数执行流程,并在一个函数执行结束时唤起另一个函数执行。这将增加编码的复杂度,而且花费上可能高于购买一个长时间运行的实例。

  • 冷启动时间 函数运行时,执行容器和环境需要一个准备的时间,尤其是第一次启动时时间可能会较长。对一个 HTTP请求来讲,可能会带来响应时延的增加,产生性能毛刺。

  • 调试与测试 由于本地环境和平台运行环境的差异性,开发者需要不断调整代码,打印日志,并提交到函数平台运行测试,会带来一些开发成本和产生一些费用。

应用场景

  结合以上的优缺点,实践中我们可以发掘 Serverless 的落地场景,目前阶段 Serverless 主要适合以下的应用场景:

  • 定时任务 通过时间触发对应的函数任务,完成开发者业务逻辑的处理。

  • 数据加工 通过事件驱动件机制,在特定的条件下触发,对系统的日志进行整合,或者对多媒体文件进行加工等等。

  • 低频请求 用户可以按照频次付费,而无需构建一个应用来应对这些必要的但是量小的请求。

  • IoT 物联网场景下,大部分是用户对设备的操控,用户对时延的容忍度较高,也是典型的事件触发且低频场景。

  • Cognitive calculation applies to certain AI scenarios, such as bot.

Epilogue

  At present, the development of domestic Serverless is still in the early stages, some of the support and services to be improved in stages, and fewer large-scale success stories. But this does not prevent us keen on technological innovation, standing in front-end engineers angle of view, sustainable development Serverless, it can make the front end in the future easier to build a complete application using Node.js and other languages, just focus on the front and rear ends business logic itself, and less concerned about the huge operation and maintenance of hardware and software systems and knowledge of the underlying. The future may also bring some changes to the front and rear end workflow, such as a more unified technology stack, design specifications and data structures; greater development efficiency - reducing application build, the FBI time, prompting Web front-end Web application engineer to engineer evolutionary transformation.
Reference article:
https://www.zoo.team/article/serverless
https://www.jianshu.com/p/85d8bcd6ad81
https://blog.csdn.net/cc18868876837/article/details/90672971

Published 88 original articles · won praise 317 · Views 350,000 +

Guess you like

Origin blog.csdn.net/sunxianghuang/article/details/103146378