中年Serverless 实战:通过 Component 实现多地域部署容灾( 五 )

DEBUG ─ API with id api-2zag45hq created.DEBUG ─ Deploying service with id service-7daktopz.DEBUG ─ Deployment successful for the api named hello_world.ap-shanghai-hello_world.serverless_test in the ap-shanghai region.DEBUG ─ Deployed function hello_world successfulhello_world:ap-guangzhou:Name: hello_worldRuntime: Python3.6Handler: index.main_handlerMemorySize: 128Timeout: 3Region: ap-guangzhouNamespace: defaultDescription: This is a template functionAPIGateway:- serverless_test - POST - http://service-p14470dc-1256773370.gz.apigw.tencentcs.com/release/users- serverless_test - POST - http://service-p14470dc-1256773370.gz.apigw.tencentcs.com/release/usersssap-shanghai:Name: hello_worldRuntime: Python3.6Handler: index.main_handlerMemorySize: 128Timeout: 3Region: ap-shanghaiNamespace: defaultDescription: This is a template functionAPIGateway:- serverless_test - POST - http://service-7daktopz-1256773370.sh.apigw.tencentcs.com/release/users- serverless_test - POST - http://service-7daktopz-1256773370.sh.apigw.tencentcs.com/release/usersss- serverless_test - POST - http://service-7daktopz-1256773370.sh.apigw.tencentcs.com/release/usersd35s hello_world done通过以上部署 , 就可以成功将函数部署到不同的地域 , 并且针对不同地域进行额外的配置 。 上层服务的多地域部署与解析就目前来看 , tencent-scf更多是一个基础组件 , 更多人则是在使用 Koa、Express 等组件 , 那么对于这种相对高阶的组件 , 是否可以多地域部署呢?从目前文档的描述来看是可以进行多地域部署 , 且可以进行自动解析 , 以tencent-tornado为例:TornadoTest:component: "@serverless/tencent-tornado"inputs:region:- ap-guangzhou- ap-shanghaifunctionName: tornadoFunctionTesttornadoProjectName: appcode: ./functionConf:timeout: 10memorySize: 256environment:variables:TEST: valevpcConfig:subnetId: ""vpcId: ""apigatewayConf:protocols:- httpenvironment: releasecustomDomain:- domain: anycodestest1.comisDefaultMapping: "FALSE"pathMappingSet:- path: /environment: releaseprotocols:- http- domain: anycodestest2.comisDefaultMapping: "FALSE"pathMappingSet:- path: /environment: releaseprotocols:- httpcloudDNSConf:ttl: 603


推荐阅读