{"componentChunkName":"component---src-templates-blog-detail-tsx","path":"/blog/2019-08-01-serverless-basic-concept","result":{"data":{"currentBlog":{"id":"e8e2574a-3de9-5b3c-bb8a-75e26713caa6","frontmatter":{"thumbnail":"https://img.serverlesscloud.cn/20191227/1577408769674-v2-3635e3b55ee1fda578ea953ba927da13_1200x500.jpg","authors":["Alfred Huang"],"categories":["guides-and-tutorials"],"date":"2019-08-01T00:00:00.000Z","title":"Serverless 基本概念入门","description":"从行业趋势看，Serverless 是云计算必经的一场革命","authorslink":["https://zhuanlan.zhihu.com/ServerlessGo"],"translators":null,"translatorslink":null,"tags":["云计算","Serverless"],"keywords":"Serverless 基本概念,Serverless 入门,Serverless 基础","outdated":null},"wordCount":{"words":407,"sentences":75,"paragraphs":75},"fileAbsolutePath":"/opt/build/repo/content/blog/2019-08-01-serverless-basic-concept.md","fields":{"slug":"/blog/2019-08-01-serverless-basic-concept/","keywords":["serverless","无服务器","云函数","云原生","Serverless","架构","函数","应用","产品","业务","无需","服务器","运维"]},"html":"<blockquote>\n<p>从行业趋势看，Serverless 是云计算必经的一场革命</p>\n</blockquote>\n<p>2019 年，Serverless 被 Gartner 称为最有潜力的云计算技术发展方向，并被赋予是必然性的发展趋势。Serverless 从底层开始变革计算资源的形态，为软件架构设计与应用服务部署带来了新的设计思路。</p>\n<p>为此，我们策划了 <strong><a href=\"https://zhuanlan.zhihu.com/ServerlessGo\">Serverless 技术专栏</a></strong>，从基础概念入门，到前后台架构设计、应用拓展、最佳实践等多维度，揭开 Serverless 的面纱，带你走进无服务器的世界。</p>\n<hr>\n<h2 id=\"什么是-serverless？\"><a href=\"#%E4%BB%80%E4%B9%88%E6%98%AF-serverless%EF%BC%9F\" aria-label=\"什么是 serverless？ permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>什么是 Serverless？</h2>\n<p>Serverless ，按中文翻译，称为「无服务器」。</p>\n<p>这究竟是一种什么样的形态或产品呢？无服务器，就是真的没有服务器吗？</p>\n<p>其实，在行业内，目前对于 Serverless 有几种解读方法：</p>\n<ul>\n<li><strong>在某些场景可以解读为一种软件系统架构方法，通常称为 Serverless 架构</strong></li>\n<li><strong>而在另一些情况下，又可以代表一种产品形态，称为 Serverless 产品</strong></li>\n</ul>\n<p>在说起 Serverless 架构时，Serverless 代表的是利用 Serverless 形态的产品实现的应用架构，这种架构完全依托于云厂商或云平台提供产品完成系统的组织及构建。在这种架构中，用户无需关注支撑应用服务运行的主机，而将关注点投入在系统架构，业务开发，业务支撑运维上。</p>\n<p>而说起 Serverless 产品时，代表的是无需理解、管理服务器，按需使用，按使用付费的产品。Serverless 产品中，其实也可以包含存储、计算等多种类型的产品。而典型的计算产品，就是云函数这种形态。</p>\n<p>云函数，或者称为函数即服务 (Function as a Service)，它和后端即服务 (Backend as a Service) 一起，都可以称为 Serverless 产品。通过组合使用这些产品，开发者可以构建自身的业务 Serverless 架构。</p>\n<h2 id=\"serverless-的价值\"><a href=\"#serverless-%E7%9A%84%E4%BB%B7%E5%80%BC\" aria-label=\"serverless 的价值 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Serverless 的价值</h2>\n<p>Serverless 技术为什么会获得越来越多的关注？我们可以从几个角度来看。</p>\n<p>首先，从开发者使用的来说，不用更多地去考虑服务器的相关内容，无需再去考虑服务器的规格大小、存储类型、网络带宽、自动扩缩容问题。同时，也无需再对服务器进行运维，无需不断打系统补丁、应用补丁，无需进行数据备份、软件配置等工作。</p>\n<p>其次，Serverless 产品是完全自动化的弹性扩缩容的。在业务高峰时，产品的计算能力、容量自动扩容，承载更多的用户请求，而在业务下降时，所使用的资源也会同时收缩，避免资源浪费。</p>\n<p>再次，跟随着完全自动化的弹性所带来的，是全新的计量计费模式。开发者仅需根据使用量来付费，而在深夜无业务量的情况下，不会有空闲资源占用，因此也不会有费用产生。</p>\n<p>随着如上提到的特性，Serverless 给开发者或用户带来了具体的商业价值：</p>\n<h4 id=\"1-降低运维需求\"><a href=\"#1-%E9%99%8D%E4%BD%8E%E8%BF%90%E7%BB%B4%E9%9C%80%E6%B1%82\" aria-label=\"1 降低运维需求 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>1. 降低运维需求</h4>\n<ul>\n<li>Serverless 使得应用与服务器解耦，业务上线前无需预估资源，无需进行服务器购买、配置</li>\n<li>Serverless 也使得底层运维工作量进一步降低，业务上线后，也无需担忧服务器运维，而是全部交给了云平台或云厂商</li>\n</ul>\n<h4 id=\"2-降低运营成本\"><a href=\"#2-%E9%99%8D%E4%BD%8E%E8%BF%90%E8%90%A5%E6%88%90%E6%9C%AC\" aria-label=\"2 降低运营成本 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>2. 降低运营成本</h4>\n<ul>\n<li>Serverless 的应用是按需执行的。应用只在有请求需要处理或者事件触发时才会被加载运行，在空闲状态下 Serverless 架构的应用本身并不占用计算资源</li>\n<li>在使用 Serverless 产品时，用户只需要为处理请求的计算资源付费，而无须为应用空闲时段的资源占用付费</li>\n</ul>\n<h4 id=\"3-缩短迭代周期、上线时间\"><a href=\"#3-%E7%BC%A9%E7%9F%AD%E8%BF%AD%E4%BB%A3%E5%91%A8%E6%9C%9F%E3%80%81%E4%B8%8A%E7%BA%BF%E6%97%B6%E9%97%B4\" aria-label=\"3 缩短迭代周期、上线时间 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>3. 缩短迭代周期、上线时间</h4>\n<ul>\n<li>Serverless 架构带来的是进一步的业务解耦，应用功能被解构成若干个细颗粒度的无状态函数，开发可以聚焦在单功能的快速开发和上线</li>\n<li>同时拆解后的云函数，也都可以进行独立的迭代升级，更快速的实现业务迭代，缩减功能的上市时间</li>\n</ul>\n<h4 id=\"4-快速试错\"><a href=\"#4-%E5%BF%AB%E9%80%9F%E8%AF%95%E9%94%99\" aria-label=\"4 快速试错 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>4. 快速试错</h4>\n<ul>\n<li>利用 Serverless 架构的简单运维、低成本及快速上线能力，可以来快速尝试业务的新形态、新功能</li>\n<li>利用 Serverless 产品的强弹性扩容能力，在业务获得成功时，也无需为资源扩容而担心</li>\n</ul>\n<h2 id=\"serverless-的技术特点\"><a href=\"#serverless-%E7%9A%84%E6%8A%80%E6%9C%AF%E7%89%B9%E7%82%B9\" aria-label=\"serverless 的技术特点 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Serverless 的技术特点</h2>\n<p>这里提到的技术特点的对象，特指 Serverless 产品中的计算产品，也就是云函数。云函数包含了如下的技术特性：</p>\n<h4 id=\"1-事件驱动\"><a href=\"#1-%E4%BA%8B%E4%BB%B6%E9%A9%B1%E5%8A%A8\" aria-label=\"1 事件驱动 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>1. 事件驱动</strong></h4>\n<ul>\n<li>云函数的运行，是由事件驱动起来的，在有事件到来时，云函数会启动运行</li>\n<li>Serverless 应用不会类似于原有的「监听 - 处理」类型的应用一直在线，而是按需启动</li>\n<li>事件的定义可以很丰富，一次 http 请求，一个文件上传，一次数据库条目修改，一条消息发送，都可以定义为事件</li>\n</ul>\n<p><img src=\"https://img.serverlesscloud.cn/20191227/1577408850935-v2-8cd561fecece72eb5aa7bf9f92f9ce7d_hd.jpg\" alt=\"事件驱动\"></p>\n<h4 id=\"2-单事件处理\"><a href=\"#2-%E5%8D%95%E4%BA%8B%E4%BB%B6%E5%A4%84%E7%90%86\" aria-label=\"2 单事件处理 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>2. 单事件处理</strong></h4>\n<ul>\n<li>云函数由事件触发，而触发启动的一个云函数实例，一次仅处理一个事件</li>\n<li>无需在代码内考虑高并发高可靠性，代码可以专注于业务，开发更简单</li>\n<li>通过云函数实例的高并发能力，实现业务高并发</li>\n</ul>\n<p><img src=\"https://img.serverlesscloud.cn/20191227/1577408851111-v2-8cd561fecece72eb5aa7bf9f92f9ce7d_hd.jpg\" alt=\"单事件处理\"></p>\n<h4 id=\"3-自动弹性伸缩\"><a href=\"#3-%E8%87%AA%E5%8A%A8%E5%BC%B9%E6%80%A7%E4%BC%B8%E7%BC%A9\" aria-label=\"3 自动弹性伸缩 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>3. 自动弹性伸缩</strong></h4>\n<ul>\n<li>由于云函数事件驱动及单事件处理的特性，云函数通过自动的伸缩来支持业务的高并发</li>\n<li>针对业务的实际事件或请求数，云函数自动弹性合适的处理实例来承载实际业务量</li>\n<li>在没有事件或请求时，无实例运行，不占用资源</li>\n</ul>\n<p><img src=\"https://img.serverlesscloud.cn/20191227/1577408851125-v2-8cd561fecece72eb5aa7bf9f92f9ce7d_hd.jpg\" alt=\"自动弹性伸缩\"></p>\n<h4 id=\"4-无状态开发\"><a href=\"#4-%E6%97%A0%E7%8A%B6%E6%80%81%E5%BC%80%E5%8F%91\" aria-label=\"4 无状态开发 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>4. 无状态开发</strong></h4>\n<ul>\n<li>云函数运行时根据业务弹性，可能伸缩到 0，无法在运行环境中保存状态数据</li>\n<li>分布式应用开发中，均需要保持应用的无状态，以便于水平伸缩</li>\n<li>可以利用外部服务、产品，例如数据库或缓存，实现状态数据的保存</li>\n</ul>\n<p><img src=\"https://img.serverlesscloud.cn/20191227/1577408850212-v2-8cd561fecece72eb5aa7bf9f92f9ce7d_hd.jpg\" alt=\"无状态开发\"></p>\n<h2 id=\"▎serverless-的应用场景\"><a href=\"#%E2%96%8Eserverless-%E7%9A%84%E5%BA%94%E7%94%A8%E5%9C%BA%E6%99%AF\" aria-label=\"▎serverless 的应用场景 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>▎<strong>Serverless 的应用场景</strong></h2>\n<p>Serverless 架构或者技术，可以用在什么样的场景下，来充分发挥它的优势呢？如下的场景，都适合使用 Serverless 架构或产品，来实现所需的业务逻辑。</p>\n<h4 id=\"1-web-及移动后端\"><a href=\"#1-web-%E5%8F%8A%E7%A7%BB%E5%8A%A8%E5%90%8E%E7%AB%AF\" aria-label=\"1 web 及移动后端 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>1. WEB 及移动后端</h4>\n<p>通过结合使用云函数和 API 网关或 HTTP 触发器，可以对外提供 URL 访问地址，成为 Web、小程序、或移动应用等的后端服务。Serverless 架构既可以直接用于构建后台来服务应用，也可以通过类似 BFF 模式，构建中台和应用间的桥梁。</p>\n<p>Serverless 架构提供的强弹性能力，使得可以支撑业务或应用的暴涨；而提供的低运维需求，使得开发者可以专注于业务实现和优化；同时，按实际使用量的付费方式，使得开发者无需预配置资源，无需担心预配置资源的浪费。</p>\n<h4 id=\"2-消息处理\"><a href=\"#2-%E6%B6%88%E6%81%AF%E5%A4%84%E7%90%86\" aria-label=\"2 消息处理 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>2. 消息处理</h4>\n<p>Serverles 架构的应用本身是由事件触发的，因此极其适合于进行消息处理。无论是消息队列中传递的业务消息，还是 Kafka 中采集应用日志，均可以对接到云函数上，进行实时的消息处理、分析。</p>\n<h4 id=\"3-对象存储文件处理\"><a href=\"#3-%E5%AF%B9%E8%B1%A1%E5%AD%98%E5%82%A8%E6%96%87%E4%BB%B6%E5%A4%84%E7%90%86\" aria-label=\"3 对象存储文件处理 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>3. 对象存储文件处理</h4>\n<p>在 Serverless 应用场景中，由对象存储中的文件上传事件，来触发云函数的运行，也是一种常见场景。</p>\n<p>针对图片文件的上传，可以借助云函数完成图片的缩略图生成、二维码或水印标记、图片优化处理；而针对数据文件的上传，可以启动数据的自动化分析</p>\n<h4 id=\"4-物联网\"><a href=\"#4-%E7%89%A9%E8%81%94%E7%BD%91\" aria-label=\"4 物联网 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>4. 物联网</h4>\n<p>物联网意味着成千上万的设备会连入网络，时刻在不断的产生数据，这对数据的分析、处理的及时性提出了很高的挑战。通过使用 Serverless 架构，物联网设备所采集的数据将可以作为云函数的触发事件，而实现数据的实时处理、分析和应用。</p>\n<p>随着物联网设备计算能力的进一步提升，云函数作为最小粒度的计算单元，有机会被调度到设备端运行，实现边缘计算，达到「端 - 云」联合的 Serverless 架构。</p>\n<h4 id=\"5-运维及集成\"><a href=\"#5-%E8%BF%90%E7%BB%B4%E5%8F%8A%E9%9B%86%E6%88%90\" aria-label=\"5 运维及集成 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>5. 运维及集成</h4>\n<p>通过对接云函数以及云上的各个产品、日志服务、监控告警系统，云时代的运维也都可以用云函数来构建。定时触发的云函数，将可以方便地替代需要在主机上来运行的定时任务；而日志或告警触发的云函数，将可以对云中的事件作出立刻回应及处理。</p>\n<h2 id=\"▎serverless--云原生时代的应用\"><a href=\"#%E2%96%8Eserverless--%E4%BA%91%E5%8E%9F%E7%94%9F%E6%97%B6%E4%BB%A3%E7%9A%84%E5%BA%94%E7%94%A8\" aria-label=\"▎serverless  云原生时代的应用 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>▎<strong>Serverless — 云原生时代的应用</strong></h2>\n<p>云计算已经进入了新的时期，目前上云已经不是应不应该，而是如何上云的问题。在这种情况下，云原生的概念也随之而生。云原生的架构或应用，是基于云而设计的，充分利用现代云计算平台所具备的弹性和分布式特性来实现应用架构。</p>\n<p>而 Serverless 架构、产品、以及应用，均是完全依托于云而构建的，是典型且完全的云原生的架构、产品或应用。Serverless 产品所具备的产品特性、技术、费用等优势，将成为新一代云产品的发展方向；而基于 Serverless 架构推进完成开发的应用或架构，将充分享受到云时代带来的强大助力，使得云计算能真正成为业务的助推器。</p>\n<p><strong>Serverless 的计算产品 —— 云函数，作为云虚拟机、容器技术之后的下一代计算形态，将引来云计算中新的热潮。</strong>围绕着云函数而建设的产品能力、工具、生态、以及应用开发，也将引来新的一轮发展。随着无服务器的产品和生态走向成熟，将逐步承载起企业核心业务。在这个持续向前高速发展的过程中，腾讯云的云函数，将作为腾讯云云原生的重点发力领域，跟随客户需求、行业发展、技术发展，为用户提供完整的 Serverless 解决方案。</p>\n<blockquote>\n<p><strong>传送门：</strong></p>\n<ul>\n<li>GitHub: <a href=\"https://github.com/serverless/serverless/blob/master/README_CN.md\">github.com/serverless</a> </li>\n<li>官网：<a href=\"https://serverless.com/\">serverless.com</a></li>\n</ul>\n</blockquote>\n<p>欢迎访问：<a href=\"https://serverlesscloud.cn/\">Serverless 中文网</a>，您可以在 <a href=\"https://serverlesscloud.cn/best-practice\">最佳实践</a> 里体验更多关于 Serverless 应用的开发！</p>","tableOfContents":"<ul>\n<li><a href=\"/blog/2019-08-01-serverless-basic-concept/#%E4%BB%80%E4%B9%88%E6%98%AF-serverless%EF%BC%9F\">什么是 Serverless？</a></li>\n<li>\n<p><a href=\"/blog/2019-08-01-serverless-basic-concept/#serverless-%E7%9A%84%E4%BB%B7%E5%80%BC\">Serverless 的价值</a></p>\n<ul>\n<li>\n<ul>\n<li><a href=\"/blog/2019-08-01-serverless-basic-concept/#1-%E9%99%8D%E4%BD%8E%E8%BF%90%E7%BB%B4%E9%9C%80%E6%B1%82\">1. 降低运维需求</a></li>\n<li><a href=\"/blog/2019-08-01-serverless-basic-concept/#2-%E9%99%8D%E4%BD%8E%E8%BF%90%E8%90%A5%E6%88%90%E6%9C%AC\">2. 降低运营成本</a></li>\n<li><a href=\"/blog/2019-08-01-serverless-basic-concept/#3-%E7%BC%A9%E7%9F%AD%E8%BF%AD%E4%BB%A3%E5%91%A8%E6%9C%9F%E3%80%81%E4%B8%8A%E7%BA%BF%E6%97%B6%E9%97%B4\">3. 缩短迭代周期、上线时间</a></li>\n<li><a href=\"/blog/2019-08-01-serverless-basic-concept/#4-%E5%BF%AB%E9%80%9F%E8%AF%95%E9%94%99\">4. 快速试错</a></li>\n</ul>\n</li>\n</ul>\n</li>\n<li>\n<p><a href=\"/blog/2019-08-01-serverless-basic-concept/#serverless-%E7%9A%84%E6%8A%80%E6%9C%AF%E7%89%B9%E7%82%B9\">Serverless 的技术特点</a></p>\n<ul>\n<li>\n<ul>\n<li><a href=\"/blog/2019-08-01-serverless-basic-concept/#1-%E4%BA%8B%E4%BB%B6%E9%A9%B1%E5%8A%A8\">1. 事件驱动</a></li>\n<li><a href=\"/blog/2019-08-01-serverless-basic-concept/#2-%E5%8D%95%E4%BA%8B%E4%BB%B6%E5%A4%84%E7%90%86\">2. 单事件处理</a></li>\n<li><a href=\"/blog/2019-08-01-serverless-basic-concept/#3-%E8%87%AA%E5%8A%A8%E5%BC%B9%E6%80%A7%E4%BC%B8%E7%BC%A9\">3. 自动弹性伸缩</a></li>\n<li><a href=\"/blog/2019-08-01-serverless-basic-concept/#4-%E6%97%A0%E7%8A%B6%E6%80%81%E5%BC%80%E5%8F%91\">4. 无状态开发</a></li>\n</ul>\n</li>\n</ul>\n</li>\n<li>\n<p><a href=\"/blog/2019-08-01-serverless-basic-concept/#%E2%96%8Eserverless-%E7%9A%84%E5%BA%94%E7%94%A8%E5%9C%BA%E6%99%AF\">▎Serverless 的应用场景</a></p>\n<ul>\n<li>\n<ul>\n<li><a href=\"/blog/2019-08-01-serverless-basic-concept/#1-web-%E5%8F%8A%E7%A7%BB%E5%8A%A8%E5%90%8E%E7%AB%AF\">1. WEB 及移动后端</a></li>\n<li><a href=\"/blog/2019-08-01-serverless-basic-concept/#2-%E6%B6%88%E6%81%AF%E5%A4%84%E7%90%86\">2. 消息处理</a></li>\n<li><a href=\"/blog/2019-08-01-serverless-basic-concept/#3-%E5%AF%B9%E8%B1%A1%E5%AD%98%E5%82%A8%E6%96%87%E4%BB%B6%E5%A4%84%E7%90%86\">3. 对象存储文件处理</a></li>\n<li><a href=\"/blog/2019-08-01-serverless-basic-concept/#4-%E7%89%A9%E8%81%94%E7%BD%91\">4. 物联网</a></li>\n<li><a href=\"/blog/2019-08-01-serverless-basic-concept/#5-%E8%BF%90%E7%BB%B4%E5%8F%8A%E9%9B%86%E6%88%90\">5. 运维及集成</a></li>\n</ul>\n</li>\n</ul>\n</li>\n<li><a href=\"/blog/2019-08-01-serverless-basic-concept/#%E2%96%8Eserverless--%E4%BA%91%E5%8E%9F%E7%94%9F%E6%97%B6%E4%BB%A3%E7%9A%84%E5%BA%94%E7%94%A8\">▎Serverless — 云原生时代的应用</a></li>\n</ul>"},"previousBlog":{"id":"d84cec7e-e95f-522f-9b23-00f162dd10ff","frontmatter":{"thumbnail":"https://img.serverlesscloud.cn/2020414/1586851591718-v.jpg","authors":["Anycodes"],"categories":["user-stories"],"date":"2019-08-07T00:00:00.000Z","title":"腾讯云云函数 + API，你也可以做个天气信息系统","description":"为什么要把云函数 SCF 与 API 网关进行结合？本文告诉你答案！","authorslink":["https://zhuanlan.zhihu.com/ServerlessGo"],"translators":null,"translatorslink":null,"tags":["云函数","Serverless"],"keywords":"Serverless","outdated":null},"wordCount":{"words":200,"sentences":54,"paragraphs":53},"fileAbsolutePath":"/opt/build/repo/content/blog/2019-08-07-weather.md","fields":{"slug":"/blog/2019-08-07-weather/","keywords":["java","php","serverless","云函数","serverlesscloud"]}},"nextBlog":{"id":"5e1c5104-bbcb-5059-8f38-36b6503f66f8","frontmatter":{"thumbnail":"https://img.serverlesscloud.cn/2020414/1586878208210-search.jpg","authors":["Anycodes"],"categories":["user-stories"],"date":"2019-07-23T00:00:00.000Z","title":"如何优雅地给搜索引擎去广告！","description":"这真的不是针对友商……","authorslink":["https://www.zhihu.com/people/liuyu-43-97"],"translators":null,"translatorslink":null,"tags":["SEO","Serverless"],"keywords":"Serverless 应用服务端,Serverless 应用,Serverless Web 后端","outdated":null},"wordCount":{"words":238,"sentences":54,"paragraphs":54},"fileAbsolutePath":"/opt/build/repo/content/blog/2019-07-23-search-engine.md","fields":{"slug":"/blog/2019-07-23-search-engine/","keywords":["go","python","serverless","云函数","title","http","在线","serverlesscloud"]}},"recommendBlogs":{"edges":[{"node":{"id":"665f9ce2-4451-59fd-bf98-1861789d3b3b","frontmatter":{"thumbnail":"https://s3-us-west-2.amazonaws.com/assets.blog.serverless.com/Serverless_logo.png","authors":["AndreaPasswater"],"categories":["guides-and-tutorials","engineering-culture"],"date":"2018-03-19T00:00:00.000Z","title":"如何为无服务器开放源代码项目做贡献","description":"想要为无服务器开放源代码项目做贡献？您可以遵循下面的指南。","authorslink":null,"translators":null,"translatorslink":null,"tags":null,"keywords":null,"outdated":null},"wordCount":{"words":96,"sentences":36,"paragraphs":36},"fileAbsolutePath":"/opt/build/repo/content/blog/2018-03-19-how-contribute-to-serverless-open-source.md","fields":{"slug":"/blog/2018-03-19-how-contribute-to-serverless-open-source/","keywords":["serverless","无服务器","serverless","github","插件","服务器","贡献","示例","blog","contribute"]}}},{"node":{"id":"a3e92579-65c3-5159-937c-32d18c5df7d7","frontmatter":{"thumbnail":"https://s3-us-west-2.amazonaws.com/assets.blog.serverless.com/why-not/why-not-header.png","authors":["AndreaPasswater"],"categories":["guides-and-tutorials","operations-and-observability","engineering-culture"],"date":"2018-03-21T00:00:00.000Z","title":"不适合选择无服务器的情境及原因","description":"无服务器既有优点也有缺点。那么，哪些情境下不适合选择无服务器？原因又是什么呢？","authorslink":null,"translators":null,"translatorslink":null,"tags":null,"keywords":null,"outdated":null},"wordCount":{"words":163,"sentences":43,"paragraphs":43},"fileAbsolutePath":"/opt/build/repo/content/blog/2018-03-21-when-why-not-use-serverless.md","fields":{"slug":"/blog/2018-03-21-when-why-not-use-serverless/","keywords":["faas","react","serverless","spa","无服务器","无服务器函数","无服务器架构","无服务器开发","服务器","twitter","serverless","blockquote","lang","script","en"]}}},{"node":{"id":"6a16520b-7886-582e-9182-64e50712d486","frontmatter":{"thumbnail":"https://s3-us-west-2.amazonaws.com/assets.blog.serverless.com/vendor+choice/serverless-data-portability.jpg","authors":["NickGottlieb"],"categories":["engineering-culture","guides-and-tutorials"],"date":"2018-06-20T00:00:00.000Z","title":"浅谈无服务器、数据锁定和供应商选择","description":"供应商选择是如今 IT 领导者需要考虑的最重要事项，而这一点可利用数据可移植性来实现。","authorslink":null,"translators":null,"translatorslink":null,"tags":null,"keywords":null,"outdated":null},"wordCount":{"words":205,"sentences":33,"paragraphs":33},"fileAbsolutePath":"/opt/build/repo/content/blog/2018-06-20-data-lockin-vendor-choice-portability.md","fields":{"slug":"/blog/2018-06-20-data-lockin-vendor-choice-portability/","keywords":["go","serverless","无服务器","无服务器架构","供应商","serverless","开发人员","数据","锁定","选择","服务"]}}},{"node":{"id":"94741abb-10ba-5db1-9756-cd1d573473fa","frontmatter":{"thumbnail":"https://s3-us-west-2.amazonaws.com/assets.blog.serverless.com/webstorm-ide/streamline-webstorm-serverless2.jpg","authors":["EslamHefnawy"],"categories":["guides-and-tutorials","engineering-culture"],"date":"2018-08-15T00:00:00.000Z","title":"如何使用 WebStorm 简化无服务器工作流程","description":"在本文中，我将和您分享如何使用 WebStorm 进行无服务器特定的 IDE 设置以及如何利用它来极大地加快无服务器工作流程。","authorslink":null,"translators":null,"translatorslink":null,"tags":null,"keywords":null,"outdated":null},"wordCount":{"words":234,"sentences":54,"paragraphs":54},"fileAbsolutePath":"/opt/build/repo/content/blog/2018-08-15-streamline-serverless-workflow-webstorm.md","fields":{"slug":"/blog/2018-08-15-streamline-serverless-workflow-webstorm/","keywords":["nodejs","serverless","无服务器","无服务器开发","serverless","WebStorm","webstorm","服务器","blog","assets"]}}},{"node":{"id":"713a0563-4bf9-5721-bacb-3b4ef609fe4a","frontmatter":{"thumbnail":"https://s3-us-west-2.amazonaws.com/assets.blog.serverless.com/camp-fire/camp-fire-housing-thumb.jpg","authors":["EricWyne"],"categories":["guides-and-tutorials","user-stories"],"date":"2018-12-05T00:00:00.000Z","title":"Serverless Twitter 机器人帮助为坎普山火受灾者安置住房","description":"加利福尼亚州的坎普山火致使数千人流离失所，为此，我构建了一个简单的 Serverless Twitter 机器人来帮助将受灾者安置在临时住房！","authorslink":["https://serverless.com/author/ericwyne/"],"translators":["Aceyclee"],"translatorslink":["zhihu.com/people/Aceyclee"],"tags":null,"keywords":null,"outdated":null},"wordCount":{"words":157,"sentences":26,"paragraphs":26},"fileAbsolutePath":"/opt/build/repo/content/blog/2018-12-05-serverless-twitter-camp-fire.md","fields":{"slug":"/blog/2018-12-05-serverless-twitter-camp-fire/","keywords":["serverless","无服务器","云函数","Serverless","org","住房","Twitter","函数","受灾","机器人","山火"]}}},{"node":{"id":"17c972d9-0583-51f6-9d5d-c2ba5f21b6a3","frontmatter":{"thumbnail":"https://img.serverlesscloud.cn/20191227/1577409288454-v2-577c2b21d600e3ea07f156f3e9d2d6b8_1200x500.jpg","authors":["Alfred Huang"],"categories":["guides-and-tutorials"],"date":"2019-08-21T00:00:00.000Z","title":"Serverless 的运行原理与组件架构","description":"本文重点探讨下开发者使用 Serverless 时经常遇到的一些问题，以及如何解决","authorslink":["https://zhuanlan.zhihu.com/ServerlessGo"],"translators":null,"translatorslink":null,"tags":["运行原理","serverless"],"keywords":"Serverless 运行原理,Serverless 组件架构","outdated":null},"wordCount":{"words":236,"sentences":33,"paragraphs":33},"fileAbsolutePath":"/opt/build/repo/content/blog/2019-08-21-serverless-operation-architecture.md","fields":{"slug":"/blog/2019-08-21-serverless-operation-architecture/","keywords":["koa","serverless","云函数","Serverless","用户","函数","请求","实例","形态","业务","serverlesscloud"]}}},{"node":{"id":"ae4fd2f8-515c-5aec-b584-38427ef33f7e","frontmatter":{"thumbnail":"https://img.serverlesscloud.cn/2020114/1578989800047-part-00492-780.jpg","authors":["Anycodes"],"categories":["guides-and-tutorials","user-stories"],"date":"2019-09-16T00:00:00.000Z","title":"突破传统 OJ 瓶颈，「判题姬」接入云函数","description":"通过 Serverless 实现在线编程","authorslink":["https://www.zhihu.com/people/liuyu-43-97"],"translators":null,"translatorslink":null,"tags":["在线编程","云函数"],"keywords":"Serverless 在线编程,Serverless OJ","outdated":null},"wordCount":{"words":169,"sentences":30,"paragraphs":30},"fileAbsolutePath":"/opt/build/repo/content/blog/2019-09-16-online-Judge.md","fields":{"slug":"/blog/2019-09-16-online-Judge/","keywords":["python","serverless","云函数","代码","函数","serverless"]}}},{"node":{"id":"545ab3d2-e14e-5cc2-8548-0e863eac942b","frontmatter":{"thumbnail":"https://s3-us-west-2.amazonaws.com/assets.blog.serverless.com/2019-10-deployment-best-practices/safeguard-header.png","authors":["FernandoMedinaCorey"],"categories":["guides-and-tutorials"],"date":"2019-10-14T00:00:00.000Z","title":"无服务器部署最佳实践","description":"了解部署无服务器应用时的一些最佳实践。","authorslink":null,"translators":null,"translatorslink":null,"tags":null,"keywords":null,"outdated":null},"wordCount":{"words":221,"sentences":46,"paragraphs":46},"fileAbsolutePath":"/opt/build/repo/content/blog/2019-10-14-serverless-deployment-best-practices.md","fields":{"slug":"/blog/2019-10-14-serverless-deployment-best-practices/","keywords":["serverless","无服务器","serverless","部署","服务器","开发人员","应用","安全措施","使用","函数"]}}}],"totalCount":31}},"pageContext":{"isCreatedByStatefulCreatePages":false,"blogId":"e8e2574a-3de9-5b3c-bb8a-75e26713caa6","previousBlogId":"d84cec7e-e95f-522f-9b23-00f162dd10ff","nextBlogId":"5e1c5104-bbcb-5059-8f38-36b6503f66f8","categories":["guides-and-tutorials"]}}}