{"componentChunkName":"component---src-templates-best-practice-detail-tsx","path":"/best-practice/2020-05-20-serverless-http-introduction","result":{"data":{"currentBlog":{"id":"1c3ebfaf-a0c0-5d6b-9a27-f4499638e71f","frontmatter":{"thumbnail":"https://img.serverlesscloud.cn/2020520/1589974000735-%E6%9C%8D%E5%8A%A1%E6%8C%87%E5%8D%97%E5%89%AF%E6%9C%AC.jpg","authors":["Tianyun"],"categories":["best-practice"],"date":"2020-05-20T00:00:00.000Z","title":"腾讯云 Serverless HTTP 服务指南","description":"Serverless HTTP 服务是基于腾讯云 API 网关和云函数的能力，为互联网业务提供 0 配置、高可用、弹性扩展的 API 能力","authorslink":["https://zhuanlan.zhihu.com/ServerlessGo"],"translators":null,"translatorslink":null,"tags":["Serverless","Serverless HTTP"],"keywords":"Serverless,Serverless Framework,http,API","outdated":null},"wordCount":{"words":151,"sentences":20,"paragraphs":20},"fileAbsolutePath":"/opt/build/repo/content/best-practice/2020-05-20-serverless-http-introduction.md","fields":{"slug":"/best-practice/2020-05-20-serverless-http-introduction/","keywords":["go","node.js","serverless","无服务器","云函数","serverless","Serverless","serverlesscloud","网关"]},"html":"<p>Serverless 是全球流行的应用架构，Serverless 实现了自动伸缩扩容，稳定性好；不需要运维，按运行时间付费，降低了开发成本；门槛降低，让前端工程师有望成为全栈工程师。诸多优点，吸引了云厂商相继布局。</p>\n<p>云函数 SCF 是腾讯云 serverless 团队为企业和开发者们提供的无服务器执行环境，目前支持 <code class=\"language-text\">Java、node.js、PHP、Python、Golang</code> 等多种语言，同时 Serverless 团队也在不断的丰富其组件库，目前已经支持 Node.js 的 Express、Koa、Egg 框架，以及 Python 的 Django 框架等。</p>\n<blockquote>\n<p>更多参见：<a href=\"https://cloud.tencent.com/document/product/1154/38787\">产品概述</a></p>\n</blockquote>\n<p>当用户使用云函数编写自己的业务逻辑时，以 Web 举例，需要通过网关调用接口，开源网关单节点容易宕机，多节点需要创建集群维护成本较高，所以大多数用户会选择腾讯云 API 网关，只需要几行网络请求的代码甚至不需要代码就可以使用，减少了人力成本。</p>\n<p>Serverless Http 服务是基于腾讯云 API 网关和云函数的能力，支持 <code class=\"language-text\">Swagger/OpenAPI</code> 等协议，不需要用户配置，部署完成后，可通过 Dashboard 去查看 API 监控管理，如下图所示，极大的方便了用户快速上线自己的业务逻辑，通过规范的 API 支持内外系统的集成和连接。</p>\n<p>对于 Web Service，Serverless HTTP 服务提供了标准 API，集成客户内部业务，提供统一、开放、易于管理及配置的 API 服务平台，可以以比较友好的方式呈现给用户使用，也有利于自身业务的安全性。</p>\n<p><img src=\"https://img.serverlesscloud.cn/2020520/1589967378198-1589883039380-2c90ba3c63a4572e.png\"></p>\n<h2 id=\"serverless-http-服务体验\"><a href=\"#serverless-http-%E6%9C%8D%E5%8A%A1%E4%BD%93%E9%AA%8C\" aria-label=\"serverless http 服务体验 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 HTTP 服务体验</h2>\n<p><strong>下面以部署 Express 应用为例，一起体验下接入 Serverless HTTP 服务！</strong></p>\n<p>打开链接：<a href=\"https://serverless.cloud.tencent.com/deploy/express\">cloud.tencent.com/deploy/express</a>，扫码/点击一键部署，登录腾讯云账号授权，部署完成会看到如下页面：</p>\n<p><img src=\"https://img.serverlesscloud.cn/2020520/1589978702447-%E7%94%BB%E6%9D%BF.png\"></p>\n<h3 id=\"修改-api-配置\"><a href=\"#%E4%BF%AE%E6%94%B9-api-%E9%85%8D%E7%BD%AE\" aria-label=\"修改 api 配置 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>修改 API 配置</h3>\n<p>用户可以通过右上方的<code class=\"language-text\">【下载项目代码】</code>按钮，打开 <code class=\"language-text\">serverless.yml</code> 文件，修改 API 配置，例如修改 environment。\n提示：<code class=\"language-text\">serverless.yml</code> 文件里的 <code class=\"language-text\">name:expressDemo</code> 可以修改为和上图 Dashboard 上的 <code class=\"language-text\">name:express-ipgze</code> 一致。</p>\n<p><img src=\"https://img.serverlesscloud.cn/2020520/1589967477373-1589892886268-5af7f1fb0288b078.png\"></p>\n<p>如果您修改为其他，例如下图修改为：<code class=\"language-text\">express-test</code>，跟云端的不一致</p>\n<p><img src=\"https://img.serverlesscloud.cn/2020520/1589967478668-1589892886268-5af7f1fb0288b078.png\"></p>\n<p>通过 <code class=\"language-text\">sls deploy</code> 部署后，会重新创建一个 express 应用，如下图所示</p>\n<p><img src=\"https://img.serverlesscloud.cn/2020520/1589967477376-1589892886268-5af7f1fb0288b078.png\"></p>\n<h3 id=\"移除部署的-api-网关\"><a href=\"#%E7%A7%BB%E9%99%A4%E9%83%A8%E7%BD%B2%E7%9A%84-api-%E7%BD%91%E5%85%B3\" aria-label=\"移除部署的 api 网关 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>移除部署的 API 网关</h3>\n<p>在 <code class=\"language-text\">serverless.yml</code> 文件所在的目录下，通过 <code class=\"language-text\">sls remove</code> 命令移除部署的 API 网关，移除后该组件会对应删除云上部署时所创建的所有相关资源。</p>\n<hr>\n<div id='scf-deploy-iframe-or-md'></div>\n<hr>\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>\n<p><a href=\"/best-practice/2020-05-20-serverless-http-introduction/#serverless-http-%E6%9C%8D%E5%8A%A1%E4%BD%93%E9%AA%8C\">Serverless HTTP 服务体验</a></p>\n<ul>\n<li><a href=\"/best-practice/2020-05-20-serverless-http-introduction/#%E4%BF%AE%E6%94%B9-api-%E9%85%8D%E7%BD%AE\">修改 API 配置</a></li>\n<li><a href=\"/best-practice/2020-05-20-serverless-http-introduction/#%E7%A7%BB%E9%99%A4%E9%83%A8%E7%BD%B2%E7%9A%84-api-%E7%BD%91%E5%85%B3\">移除部署的 API 网关</a></li>\n</ul>\n</li>\n</ul>"},"previousBlog":{"id":"61754f2f-f98a-5a66-867e-55d36c778712","frontmatter":{"thumbnail":"https://img.serverlesscloud.cn/2020522/1590145638649-%E8%85%BE%E8%AE%AF%E5%9C%A8%E7%BA%BF%E6%95%99%E8%82%B2%E5%89%AF%E6%9C%AC.jpg","authors":["蒋林源"],"categories":["best-practice"],"date":"2020-05-22T00:00:00.000Z","title":"Serverless SSR 技术在「腾讯在线教育」的实践","description":"腾讯在线教育团队基于腾讯云 Serverless 技术在其项目中应用 SSR","authorslink":["https://zhuanlan.zhihu.com/ServerlessGo"],"translators":null,"translatorslink":null,"tags":["Serverless SSR","腾讯在线教育"],"keywords":"Serverless,Serverless Framework,SSR","outdated":null},"wordCount":{"words":427,"sentences":67,"paragraphs":67},"fileAbsolutePath":"/opt/build/repo/content/best-practice/2020-05-22-edu-ssr-interview.md","fields":{"slug":"/best-practice/2020-05-22-edu-ssr-interview/","keywords":["serverless","ssr","云函数","serverlesscloud","函数"]}},"nextBlog":{"id":"49ee9eda-a7e0-5ae3-a0e9-732c16b21b85","frontmatter":{"thumbnail":"https://img.serverlesscloud.cn/2020519/1589879581175-%E4%BA%BA%E4%BA%BA%E8%A7%86%E9%A2%91%E5%89%AF%E6%9C%AC.jpg","authors":["马晓"],"categories":["best-practice"],"date":"2020-05-19T00:00:00.000Z","title":"马晓：Serverless SSR 在人人视频的落地探索","description":"人人视频前端团队基于腾讯云 Serverless 技术在其项目中应用 SSR","authorslink":["https://zhuanlan.zhihu.com/ServerlessGo"],"translators":null,"translatorslink":null,"tags":["Serverless","Serverless SSR"],"keywords":"Serverless,Serverless Framework,SSR","outdated":null},"wordCount":{"words":253,"sentences":21,"paragraphs":21},"fileAbsolutePath":"/opt/build/repo/content/best-practice/2020-05-19-rrvideos-ssr-interview.md","fields":{"slug":"/best-practice/2020-05-19-rrvideos-ssr-interview/","keywords":["java","php","serverless","vue","客户端渲染","云函数","页面","Serverless","serverless","业务","开发","团队","Nuxt","前端"]}}},"pageContext":{"isCreatedByStatefulCreatePages":false,"blogId":"1c3ebfaf-a0c0-5d6b-9a27-f4499638e71f","previousBlogId":"61754f2f-f98a-5a66-867e-55d36c778712","nextBlogId":"49ee9eda-a7e0-5ae3-a0e9-732c16b21b85"}}}