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

AWS Elastic Beanstalk - Socket failure on Puma server when more than 300 connections at a given time

· 52CE 我爱测

I've been dealing with an, arguably, strange issue on a AWS Elastic Beanstalk environment. I'm getting the following nginx error when there are more than 300 connections on a single instance at a given time: 2018/03/23 20:56:53 […

问题原文

原帖链接 · Icid · CC BY-SA 3.0

I've been dealing with an, arguably, strange issue on a AWS Elastic Beanstalk environment. I'm getting the following nginx error when there are more than 300 connections on a single instance at a given time:

2018/03/23 20:56:53 [error] 5431#0: *4121 connect() to unix:///var/run/puma/my_app.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: , server: _, request: "GET /api/v1/podcasts/ HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/api/v1/podcasts/", host:

My Puma config has

bind "unix:///var/run/puma/my_app.sock"

And the nginx config on the EC2 instance seems to have the socket properly set up (the default nginx config provided by EBS).

So yeah, I have no idea what's causing this. Any ideas? Thanks!

已采纳解答

原帖链接 · Dextro67 · CC BY-SA 3.0

Well going through the issue and the configurations the failure is related to exceeded resource limit. Possibly two of the OS resources:

  • open file descriptors
  • processes available to a single user. Just to eliminate the process limitation keep your nproc value in EC2 instance to very high value or unlimited.

    sudo vi /etc/security/limits.conf

Refer this link for a brief idea. So since you cannot have worker_rlimit_nofile more than the ulimit set on the server first approch would be to calculate the nginx parameters and tweak as per requirement:

We can serve worker_processes * worker_connections / ( keepalive_timout * 2 ) users per second.

This scaling guide may help you quantifying the values you should increase and define. Once you are done defining the values for your web server you'll need to update the limits with higher or equal values. Check upto what user concurrency the server works to help you scale up.

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

资料来源与适用范围

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

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

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