大网数据广告活动
服务器运维问答

Database Connections Persist After Security Group Change

· 52CE 我爱测

We've set up a system to send a message to a queue in SQS when there's an outage on a dependency. In order to simulate an outage and test the system, I blocked the outbound port to a database on the security group, but found that…

问题原文

原帖链接 · Hazel T · CC BY-SA 4.0

We've set up a system to send a message to a queue in SQS when there's an outage on a dependency. In order to simulate an outage and test the system, I blocked the outbound port to a database on the security group, but found that the ec2 instance still managed to retrieve data through JDBC connections from the database even after the port was blocked for quite some time (over 10 minutes, less than two hours).

What's going on? Security group changes are supposed to take effect immediately, but I assume it has to do with not shutting down live connections?

Is there a better way to simulate an outage given that we don't want to actually shut down the database?

已采纳解答

原帖链接 · Michael - sqlbot · CC BY-SA 4.0

Security group rules changes do take effect almost immediately.

However, what the rules allow is the establishment of connections. Once a connection is up, the network remembers the connection's tuple (protocol, source/dest address, source/dest port) and the connection is allowed to continue to exist because it's already been created.

By contrast, network ACLs are stateless. Blocking the connections with the network ACL should have the effect you're looking for, though perhaps not precisely the same, because the database can fail in multiple ways that may manifest themselves differently.

When network ACLs deny traffic (or security groups deny new connections) the effect is a timeout -- because the denied packets are simply dropped, discarded, with no message sent in the reverse direction to indicate that there's a black hole in the network.

By contrast, real-world failures might alternately result in network errors like "destination host unreachable" or "connection refused" or "connection reset by peer." Each of these failures should tend to be faster failures than timeouts, and there isn't a way to simulated them inside the VPC infrastructure.

But simulating a failure with timeouts should be a very worthwhile test, and Network ACLs should facilitate that.

Note, of course, that if you are still able to establish new connections with the security group supposedly blocking the traffic, then your security group behavior is not what you believe it to be.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-08-03)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。