[英]AWS single session OR multiple sessions?
I am creating an application in Golang hosted on AWS cloud, that uses multiple AWS services ie S3, DynamoDB, Parameter Store. 我正在托管在AWS云上的Golang中创建一个应用程序,该应用程序使用多个AWS服务,即S3,DynamoDB,Parameter Store。
Currently Individual modules handing each AWS service has their own AWS session. 当前,处理每个AWS服务的各个模块都有自己的AWS会话。
awsSession, err := session.NewSession(&aws.Config{Region: aws.String(os.Getenv("AWS_REGION"))})
From performance perspective, is this a correct way, or having a single session created in the main program and passing the reference to individual module will be a better approach? 从性能的角度来看,这是一种正确的方法,还是在主程序中创建单个会话并将引用传递给各个模块将是更好的方法?
It's recommended to reuse the session if possible. 如果可能,建议重用会话。
From the AWS Go SDK docs : 从AWS Go SDK 文档中 :
Sessions should be cached when possible, because creating a new Session will load all configuration values from the environment, and config files each time the Session is created. 应尽可能缓存会话,因为创建新会话将在每次创建会话时从环境和配置文件中加载所有配置值。 Sharing the Session value across all of your service clients will ensure the configuration is loaded the fewest number of times possible. 在所有服务客户端之间共享会话值将确保加载配置的次数最少。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.