{"componentChunkName":"component---src-templates-best-practice-detail-tsx","path":"/best-practice/2021-03-17-clb","result":{"data":{"currentBlog":{"id":"286a22c7-8662-5105-a6fe-de6fb25bd445","frontmatter":{"thumbnail":"https://main.qcloudimg.com/raw/984bf4cf35beba9c5f1233d1d13cfd94.png","authors":["陈涛"],"categories":["best-practice"],"date":"2021-03-17T00:00:00.000Z","title":"如何使用 Serverless + CLB 快速部署 Web 服务？","description":"更低成本、免运维，为开发者平滑迁移应用上云提供参考","authorslink":null,"translators":null,"translatorslink":null,"tags":["Serverless","CLB"],"keywords":null,"outdated":null},"wordCount":{"words":126,"sentences":29,"paragraphs":28},"fileAbsolutePath":"/opt/build/repo/content/best-practice/2021-03-17-clb.md","fields":{"slug":"/best-practice/2021-03-17-clb/","keywords":["serverless","云函数","width"]},"html":"<p>在 <a href=\"https://serverlesscloud.cn/best-practice/2021-03-01-clb-serverless\">《如何快速迁移传统 LB 公网业务到 Serverless?》</a>  文章中，为大家介绍了负载均衡 CLB 触发器接入 Serverless 函数的优势、适用场景及配置指引。</p>\n<p>在本篇文章中，将实践如何使用负载均衡 CLB 作为 Serverless 服务的访问入口，拓展其低成本、免运维等优势，为开发者平滑迁移应用上云提供参考。</p>\n<h2 id=\"创建云函数-scf\"><a href=\"#%E5%88%9B%E5%BB%BA%E4%BA%91%E5%87%BD%E6%95%B0-scf\" aria-label=\"创建云函数 scf 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>创建云函数 SCF</h2>\n<ol>\n<li>进入云函数控制台，点击 “新建” 进行函数创建。</li>\n</ol>\n<p>函数控制台地址：<a href=\"https://console.cloud.tencent.com/scf/list\">https://console.cloud.tencent.com/scf/list</a></p>\n<img src=\"https://main.qcloudimg.com/raw/64a25671353d0726904fd13145955cb4.png\" width=\"700\">\n<ol start=\"2\">\n<li>选择自定义模版进行创建，运行环境设置为 “Python3.6” ，选择 “本地上传文件夹” ，下载 Demo 内容，成功下载后，需进行解压，在 “函数代码” 中上传整个本地文件夹。</li>\n<li><strong>执行方法</strong>：index.main_handler</li>\n<li><strong>Demo 下载地址</strong>：<a href=\"https://scfdemo-1253970226.cos.ap-chengdu.myqcloud.com/21_3_17_daxigua.zip\">https://scfdemo-1253970226.cos.ap-chengdu.myqcloud.com/21_3_17_daxigua.zip</a></li>\n</ol>\n<img src=\"https://main.qcloudimg.com/raw/229ea386f276586165df82d522aa8886.png\" width=\"700\">\n<ol start=\"3\">\n<li>完成后即可在函数控制台对相关代码进行自定义编辑。</li>\n</ol>\n<img src=\"https://main.qcloudimg.com/raw/4a651423e6ea29e9ecd60a9391895ace.png\" width=\"700\">\n<h2 id=\"创建负载均衡-clb-资源\"><a href=\"#%E5%88%9B%E5%BB%BA%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1-clb-%E8%B5%84%E6%BA%90\" aria-label=\"创建负载均衡 clb 资源 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>创建负载均衡 CLB 资源</h2>\n<ol>\n<li>进入负载均衡 CLB 控制台，点击 “新建” 进行资源创建。</li>\n</ol>\n<p>CLB 控制台地址：<a href=\"https://console.cloud.tencent.com/clb/instance?rid=1\">https://console.cloud.tencent.com/clb/instance?rid=1</a></p>\n<img src=\"https://main.qcloudimg.com/raw/ecd8efd308cd6b284c19653eb6c11d91.png\" width=\"700\">\n<ol start=\"2\">\n<li>选择云函数支持的负载均衡实例。</li>\n</ol>\n<img src=\"https://main.qcloudimg.com/raw/306b7e10231d87baa5d10ab5d35cd89d.png\" width=\"700\">\n<blockquote>\n<p>注：目前云函数支持绑定网络类型为“公网”、网络为 “私有网络” 的同地域实例，监听器支持 “七层监听器” ，暂不支持四层监听器。</p>\n</blockquote>\n<ol start=\"3\">\n<li>创建监听器。</li>\n</ol>\n<img src=\"https://main.qcloudimg.com/raw/2db3b1fd34b6681e9018c56b1b43bc21.png\" width=\"700\">\n<ol start=\"4\">\n<li>在 CLB 控制台或云函数控制台绑定 SCF 实例资源。</li>\n</ol>\n<img src=\"https://main.qcloudimg.com/raw/9c935ea7ebdb1953741733509acf4aca.png\" width=\"700\">\n<img src=\"https://main.qcloudimg.com/raw/c921a32ba1890245c0de52b670fd6849.png\" width=\"700\">\n<ol start=\"5\">\n<li>访问 CLB 监听器路径，查看整体效果（体验地址：<a href=\"http://129.226.10.72:81/daxigua%EF%BC%89%E3%80%82\">http://129.226.10.72:81/daxigua）。</a></li>\n</ol>\n<img src=\"https://main.qcloudimg.com/raw/f59a60ec5a4eeb906d4a9c8a329fac80.png\" width=\"700\">\n<img src=\"https://main.qcloudimg.com/raw/6eda0c5ba4aed5e6deb5ac3141b4d634.png\" width=\"400\"> \n<h2 id=\"方案总结\"><a href=\"#%E6%96%B9%E6%A1%88%E6%80%BB%E7%BB%93\" aria-label=\"方案总结 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>方案总结</h2>\n<p>通过 CLB 监听器访问路径，可以快速拓展 Serverless 应用的访问及使用场景。为开发者提供高可用的 Serverless 应用访问服务。</p>\n<h2 id=\"使用说明\"><a href=\"#%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E\" aria-label=\"使用说明 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>使用说明</h2>\n<ul>\n<li>CLB 触发器目前处于灰度测试阶段，您可提交<a href=\"https://cloud.tencent.com/apply/p/h2r3ix3s5vs\">申请</a>使用</li>\n<li>CLB 账户分为标准账户类型和传统账户类型，传统账户类型不支持绑定云函数 SCF ，建议升级为标准账户类型。详情可参见<a href=\"https://cloud.tencent.com/document/product/1199/49090\">账户类型升级说明</a></li>\n</ul>\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><a href=\"/best-practice/2021-03-17-clb/#%E5%88%9B%E5%BB%BA%E4%BA%91%E5%87%BD%E6%95%B0-scf\">创建云函数 SCF</a></li>\n<li><a href=\"/best-practice/2021-03-17-clb/#%E5%88%9B%E5%BB%BA%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1-clb-%E8%B5%84%E6%BA%90\">创建负载均衡 CLB 资源</a></li>\n<li><a href=\"/best-practice/2021-03-17-clb/#%E6%96%B9%E6%A1%88%E6%80%BB%E7%BB%93\">方案总结</a></li>\n<li><a href=\"/best-practice/2021-03-17-clb/#%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E\">使用说明</a></li>\n</ul>"},"previousBlog":{"id":"f0acbdfd-118b-58af-8a7b-21f4e09b9176","frontmatter":{"thumbnail":"https://main.qcloudimg.com/raw/fbb92fa50e4adc7f22e7e0babc61232e.png","authors":["臧琳"],"categories":["best-practice"],"date":"2021-03-24T00:00:00.000Z","title":"深度好文：云函数 SCF + KonaJDK11 + Spring + 提速降存一把梭","description":"KonaJDK11 如此优秀，我们能不能把它引入到 Serverless 呢？","authorslink":null,"translators":null,"translatorslink":null,"tags":["Serverless","KonaJDK"],"keywords":null,"outdated":null},"wordCount":{"words":383,"sentences":70,"paragraphs":69},"fileAbsolutePath":"/opt/build/repo/content/best-practice/2021-03-24-scf-konajdk11-spring.md","fields":{"slug":"/best-practice/2021-03-24-scf-konajdk11-spring/","keywords":["java","云函数","云原生","函数","juejin","byteimg"]}},"nextBlog":{"id":"afd5844f-4acb-5f10-9eb9-bde98bf0c567","frontmatter":{"thumbnail":"https://main.qcloudimg.com/raw/cb8be2ca0ef4971973d7e3bde82687f6.jpg","authors":["April"],"categories":["best-practice"],"date":"2021-03-15T00:00:00.000Z","title":"Serverless Wordpress 系列建站教程（四）","description":"使用 Serverless Wordpress 部署的网站整体性能高于传统方式","authorslink":null,"translators":null,"translatorslink":null,"tags":["Serverless","WordPress"],"keywords":null,"outdated":null},"wordCount":{"words":162,"sentences":21,"paragraphs":21},"fileAbsolutePath":"/opt/build/repo/content/best-practice/2021-03-15-wp4.md","fields":{"slug":"/best-practice/2021-03-15-wp4/","keywords":["serverless","Serverless","WordPress","网站","请求","服务器","serverless","部署"]}}},"pageContext":{"isCreatedByStatefulCreatePages":false,"blogId":"286a22c7-8662-5105-a6fe-de6fb25bd445","previousBlogId":"f0acbdfd-118b-58af-8a7b-21f4e09b9176","nextBlogId":"afd5844f-4acb-5f10-9eb9-bde98bf0c567"}}}