解决docker中使用nginx做负载均衡时并发过高时的一些问题

解决docker中使用nginx做负载均衡时并发过高时的一些问题


1.问题产生原因:

由于通过nginx作为负载均衡服务,在访问并发数量达到一定量级时jmeter报错。
nginx日志关键信息:accept4() failed (24: Too many open files)。
此日志引起原因是nginx进程打开文件数过多。度娘一堆类似的帖子这里引用网上的解决方式比太实用
同时出现一些502 504nginx假死问题。考虑通过增加nginx工作进程数解决。

2.解决思路:

通过配置修改ulimit -n的值,因为结合docker-compose的方式使用nginx想到对应配置

3.解决方法:

nginx:
restart: always
image: nginx
container_name: nginx
ports:
  - 80:80
volumes:
  - ./conf/nginx.conf:/etc/nginx/nginx.conf
  - ./wwwroot:/usr/share/nginx/wwwroot
ulimits:
  nproc: 65535
  nofile:
    soft: 65535
    hard: 65535

引用:引用博文
nginx工作进程数配置方案引用

posted @ 2019-02-20 15:03  白色程序猿  阅读(2540)  评论(0编辑  收藏  举报