简体   繁体   English

Sockets 在 AWS EC2 上的某个时间后花费太多时间连接 (t3a.small)

[英]Sockets taking too much time to connect after sometime on AWS EC2 (t3a.small)

I've deployed ws sockets on Amazon EC2 t3a.small instance.我已经在 Amazon EC2 t3a.small实例上部署了ws sockets。 When I start/restarts the sockets it works perfectly fine for sometime.当我启动/重新启动 sockets 时,它可以正常工作一段时间。 But after few minutes when I try to connect to the sockets it's taking more then a minute to connect and sometimes trigger timeout.但是几分钟后,当我尝试连接到 sockets 时,连接需要一分钟以上,有时会触发超时。

So I changed the instance to t3a.medium and now it's working pretty well.所以我将实例更改为t3a.medium ,现在它运行良好。 And I'm not seeing any delay in connecting/timeout to the sockets even after couple of hours.即使在几个小时后,我也没有看到 sockets 的连接/超时有任何延迟。

When I check the performance of both the instances the RAM/CAPU usage is not that much.当我检查这两个实例的性能时,RAM/CAPU 的使用并没有那么多。 RAM usage is around ~300mb and also not reaching 100% CPU usage for both cores. RAM 使用率约为 300mb,两个内核的 CPU 使用率也没有达到 100%。 So I'm not sure what could be the issue.所以我不确定可能是什么问题。

I don't think updating the instance type is right and scalable solution, As traffic increases I assume I would face the same issue?我不认为更新实例类型是正确且可扩展的解决方案,随着流量的增加,我认为我会面临同样的问题?

I want to know what is the bottleneck and what configuration I need to set in EC2 which is scalable?我想知道什么是瓶颈以及我需要在 EC2 中设置哪些可扩展的配置?


Update :更新

It seems the instance size is not an issue.似乎实例大小不是问题。 Even after changing it to t3a.medium it slowed down after sometime.即使将其更改为 t3a.medium 后,它也会在一段时间后变慢。 So figuring out what could be the issue.所以弄清楚可能是什么问题。

Apparently there was an issue with the Apache2 setting which was allowing maximum 150 concurrent connections.显然 Apache2 设置存在问题,该设置允许最多 150 个并发连接。

So I adjusted Apache httpd to allow for more concurrent connections.所以我调整了 Apache httpd 以允许更多的并发连接。

<IfModule mpm_event_module>
 StartServers 10
 MinSpareThreads 25
 MaxSpareThreads 750
 ThreadLimit 1000
 ThreadsPerChild 750
# MaxRequestWorkers aka MaxClients => ServerLimit *ThreadsPerChild
 MaxRequestWorkers 15000
 MaxConnectionsPerChild 0
 ServerLimit 20
 ThreadStackSize 524288
</IfModule>

Please note you may also need to change max open files of OS.请注意,您可能还需要更改操作系统的最大打开文件数。 By default it's 1024 in Ubuntu.默认情况下,它在 Ubuntu 中为 1024。 Set it to MAX (65536)将其设置为 MAX (65536)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM