gpt4 book ai didi

python - 为 mariadb 和 postgres 数据库启用 ssl 是否会导致服务器过载或影响性能?

转载 作者:行者123 更新时间:2023-12-01 06:20:31 24 4
gpt4 key购买 nike

启用ssl在连接数据库的过程中会带来什么影响?我知道握手会带来负载,但加密不会。我使用以下代码在 sqlalchemy 中使用 create_engine 连接到数据库时启用 ssl:

uri = "{0}://{1}@{2}:{3}/{4}".format(db_creds.get('scheme'),
self._get_auth_str(db_creds.get('username'),
db_creds.get('password')),
db_creds.get('hostname'),
str(db_creds.get('port')),
db_creds.get('name'))
ssl_args = {}
if self.config['ssloption'].lower() == 'true':
# connecting securely
if db == 'mysql':
self.config['ssloption'] = 'required'
ssl_args = {
'ssl': {
'sslmode': str(self.config['ssloption'])
}
}
if db == 'warehouse':
self.config['ssloption'] = 'require'
ssl_args = {
"sslmode": str(self.config['ssloption'])
}
self._connections[db] = create_engine(uri, connect_args=ssl_args, encoding='utf8')
else:
# not connecting securely
self._connections[db] = create_engine(uri, encoding='utf8')

最佳答案

加密和解密数据肯定会占用CPU时间。

要查看该性能影响是否会对您产生重大影响,请运行性能测试。

通常,这不是一个大问题。

关于python - 为 mariadb 和 postgres 数据库启用 ssl 是否会导致服务器过载或影响性能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60382285/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com