[转帖]高并发下nginx配置模板
| user web; | |
| # One worker process per CPU core. | |
| worker_processes 8; | |
| # Also set | |
| # /etc/security/limits.conf | |
| # web soft nofile 65535 | |
| # web hard nofile 65535 | |
| # /etc/default/nginx | |
| # ULIMIT="-n 65535" | |
| worker_rlimit_nofile 65535; | |
| pid /run/nginx.pid; | |
| events { | |
| # | |
| # Determines how many clients will be served by each worker process. | |
| # (Max clients = worker_connections * worker_processes) | |
| # Should be equal to `ulimit -n / worker_processes` | |
| # | |
| worker_connections 65535; | |
| # | |
| # Let each process accept multiple connections. | |
| # Accept as many connections as possible, after nginx gets notification | |
| # about a new connection. | |
| # May flood worker_connections, if that option is set too low. | |
| # | |
| multi_accept on; | |
| # | |
| # Preferred connection method for newer linux versions. | |
| # Essential for linux, optmized to serve many clients with each thread. | |
| # | |
| use epoll; | |
| } | |
| http { | |
| ## | |
| # Basic Settings | |
| ## | |
| # | |
| # Override some buffer limitations, will prevent DDOS too. | |
| # | |
| client_body_buffer_size 10K; | |
| client_header_buffer_size 1k; | |
| client_max_body_size 8m; | |
| large_client_header_buffers 2 1k; | |
| # | |
| # Timeouts | |
| # The client_body_timeout and client_header_timeout directives are | |
| # responsible for the time a server will wait for a client body or | |
| # client header to be sent after request. If neither a body or header | |
| # is sent, the server will issue a 408 error or Request time out. | |
| # | |
| # The keepalive_timeout assigns the timeout for keep-alive connections | |
| # with the client. Simply put, Nginx will close connections with the | |
| # client after this period of time. | |
| # | |
| # Finally, the send_timeout is a timeout for transmitting a response | |
| # to the client. If the client does not receive anything within this | |
| # time, then the connection will be closed. | |
| # | |
| # | |
| # send the client a "request timed out" if the body is not loaded | |
| # by this time. Default 60. | |
| # | |
| client_body_timeout 32; | |
| client_header_timeout 32; | |
| # | |
| # Every 60 seconds server broadcasts Sync packets, so 90 is | |
| # a conservative upper bound. | |
| # | |
| keepalive_timeout 90; # default 65 | |
| send_timeout 120; # default 60 | |
| # | |
| # Allow the server to close the connection after a client stops | |
| # responding. | |
| # Frees up socket-associated memory. | |
| # | |
| reset_timedout_connection on; | |
| # | |
| # Open file descriptors. | |
| # Caches information about open FDs, freqently accessed files. | |
| # | |
| open_file_cache max=200000 inactive=20s; | |
| open_file_cache_valid 30s; | |
| open_file_cache_min_uses 2; | |
| open_file_cache_errors on; | |
| # | |
| # Sendfile copies data between one FD and other from within the kernel. | |
| # More efficient than read() + write(), since the requires transferring | |
| # data to and from the user space. | |
| # | |
| sendfile on; | |
| # Tcp_nopush causes nginx to attempt to send its HTTP response head in one | |
| # packet, instead of using partial frames. This is useful for prepending | |
| # headers before calling sendfile, or for throughput optimization. | |
| tcp_nopush on; | |
| # | |
| # don't buffer data-sends (disable Nagle algorithm). Good for sending | |
| # frequent small bursts of data in real time. | |
| # | |
| tcp_nodelay on; | |
| types_hash_max_size 2048; | |
| include /etc/nginx/mime.types; | |
| default_type application/octet-stream; | |
| ## | |
| # Logging Settings | |
| ## | |
| # | |
| # Use analytics to track stuff instead of using precious file IO resources. | |
| # Disabling logging speeds up IO. | |
| # | |
| access_log off; | |
| error_log /root/PROJECTS/logs/error.log crit; | |
| ## | |
| # Gzip Settings | |
| ## | |
| gzip on; | |
| gzip_disable "MSIE [1-6]\."; | |
| # Only allow proxy request with these headers to be gzipped. | |
| gzip_proxied expired no-cache no-store private auth; | |
| # Default is 6 (1<n<9), but 2 -- even 1 -- is enough. The higher it is, the | |
| # more CPU cycles will be wasted. | |
| gzip_comp_level 9; | |
| gzip_min_length 500; # Default 20 | |
| gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; | |
| ## | |
| # Virtual Host Configs | |
| ## | |
| include /etc/nginx/conf.d/*.conf; | |
| } |
[转帖]高并发下nginx配置模板的更多相关文章
- nginx配置模板问题404
nginx配置模板问题 一.nginx主配置文件如下 cat /etc/nginx/nginx.conf user nginx; worker_processes ; #error_log logs/ ...
- 阿里云Linux CentOS8.1 64位服务器安装LNMP(Linux+Nginx+MySQL+PHP) 并发调试之Nginx配置
搭建好LNMP环境之后,接着要考虑的就是整个系统的并发能力了. 一.Nginx的配置 Nginx有很好的并发能力.但是要想使它的并发能力能够施展出来,需要在初步安装好的Nginx上做一些配置.主要需要 ...
- GitLab 配置模板
GitLab 配置模板 GitLab 使用模板和参数生成配置文件. 一般来说,我们会通过 gitlab.rb 文件修改配置,例如 Nginx 相关配置. gitlab.rb 只能使用特定的几个 Ngi ...
- 高并发下的 Nginx 优化与负载均衡
高并发下的 Nginx 优化 英文原文:Optimizing Nginx for High Traffic Loads 过去谈过一些关于Nginx的常见问题; 其中有一些是关于如何优化Nginx. ...
- 高并发下的Nginx优化
高并发下的Nginx优化 2014-08-08 13:30 mood Nginx 过去谈过一些关于Nginx的常见问题; 其中有一些是关于如何优化Nginx. 很多Nginx新用户是从Apach ...
- JAVA跨域、RestTemplate高并发下异常与配置、JSON数据Long转String
## 跨域支持 import org.springframework.context.annotation.Bean; import org.springframework.context.annot ...
- Nginx 配置实例-配置高可用
Nginx 配置实例-配置高可用 1. 实现效果 2. 两台机器 nginx 的安装 2.1 192.168.25.120 中 nginx 的安装 2.1.1 安装 pcre 依赖 2.1.2 安装其 ...
- [转帖]nginx配置ssl加密(单/双向认证、部分https)
nginx配置ssl加密(单/双向认证.部分https) https://segmentfault.com/a/1190000002866627 nginx下配置ssl本来是很简单的,无论是去认证 ...
- [转帖]nginx配置ssl证书实现https访问
https://www.cnblogs.com/tianhei/p/7726505.html 今天就是如此处理的 感觉挺不错的. 一,环境说明 服务器系统:ubuntu16.04LTS 服务器IP地址 ...
- CentOS7.1下生产环境Keepalived+Nginx配置
CentOS7.1下生产环境Keepalived+Nginx配置 [日期:2015-07-20] 来源:Linux社区 作者:soulful [字体:大 中 小] 注:下文涉及到配置的,如无特别 ...
随机推荐
- Mybatis 源码2——SqlSession,执行器和一级缓存
一丶 SqlSessionFactoryBuilder,SqlSessionFactory,sqlSession mybatis 获取sqlSession是通过SqlSessionFactory获取的 ...
- POJ 1156 单调队列优化
原题链接 题意 给我们一个n * m矩阵,要求我们求出一个面积最大的子矩阵,满足其内部的极差小于等于c, 同时宽度小于等于100 输入 m, n, c,求这个最大面积.n,m <= 700,c ...
- AutomaticKeepAliveClientMixin 缓存PageView页面
一旦页面滑出屏幕它就会被销毁 ,实际项目开发中对页面进行缓存是很常见的一个需求,下面我们就看看如何使用AutomaticKeepAliveClientMixin 缓存页面. 注意:使用时一定要注意是否 ...
- Dio和http库是Flutter中两种常用的网络请求库
Dio Dio 的优点: 强大的功能:Dio提供了丰富的功能,支持拦截器.文件下载和上传.超时设置等高级特性,满足了大多数网络请求的需求. 支持并发请求:Dio具有良好的并发性能,可以同时处理多个网络 ...
- SQLite3使用笔记(2)——插入
目录 1. 论述 2. 总结 1. 论述 如同上一篇文章SQLite3使用笔记(1)--查询所述,使用SQLite进行查询操作同样有两种方式.对于比较简单的表格插入,使用sqlite3_exec()接 ...
- 8种ETL算法汇总大全!看完你就全明白了
摘要:ETL是将业务系统的数据经过抽取.清洗转换之后加载到数据仓库的过程,是构建数据仓库的重要一环,用户从数据源抽取出所需的数据,经过数据清洗,最终按照预先定义好的数据仓库模型,将数据加载到数据仓库中 ...
- 《华为云DTSE》期刊2023年第二季—HDC.Cloud 2023专刊
本文分享自华为云社区<<华为云DTSE>期刊2023年第二季-HDC.Cloud 2023专刊>,作者: HuaweiCloudDeveloper . AI技术风起云涌,百家争 ...
- 终于搞懂了Python模块之间的相互引用问题
摘要:详细讲解了相对路径和绝对路径的引用方法. 在某次运行过程中出现了如下两个报错: 报错1: ModuleNotFoundError: No module named '__main__.src_t ...
- Chrome 英文翻译插件,沙拉查词
下载: https://pan.baidu.com/s/1VRaZzKgyPKc0Qt6Gufk3yw 提取码: chbm 下载: https://pan.baidu.com/s/1VRaZzKgyP ...
- CNCF大使预测:2024年云原生面临倦怠、离职及云成本精简
本文由 CNCF 大使 Eric D. Schabell 撰写,预测2024年云原生领域最可能发生的3大变化,并与其对云原生可观测性领域的见解结合. 关注云原生倦怠 毫无疑问,在 2023 年中云原生 ...