[转帖]高并发下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 [字体:大 中 小] 注:下文涉及到配置的,如无特别 ...
随机推荐
- CentOS 7 NTP服务端和客户端详细配置
参考: https://blog.csdn.net/ankang654321/article/details/103542015 ntp同步时间实验 服务端IP 192.168.1.101 ...
- 如何用 vscode 捞出还未国际化的中文词条
做国际化一个很头疼的坑就是,你不知道项目里到底还有哪些中文词条没有国际化处理 纯靠人工去检查不现实,也不靠谱,而且浪费资源 所以还是得通过脚本工具来检查,思路是: 先保存好本地代码变更,准备好一个无文 ...
- 马某 说c# 不开源,他是蠢还是坏?
马某在视频 计算机主流开发语言的现状和未来3-5年的发展前景--Java.Golang.Python.C\C#\C++.JS.前端.AI.大数据.测试.运维.网络安全 点评各种语言,其中说到C# 的时 ...
- 通过JDK动态代理类实现一个类中多种方法的不同增强
1.为什么说JDK动态代理必须要实现当前父接口才能使用 JDK动态代理是基于接口的代理,它要求目标类(被代理的类)必须实现一个或多个接口.这是因为JDK动态代理是通过创建目标类的接口的代理对象来实现的 ...
- 文心一言 VS 讯飞星火 VS chatgpt (58)-- 算法导论6.4 2题
文心一言 VS 讯飞星火 VS chatgpt (58)-- 算法导论6.4 2题 二.试分析在使用下列循环不变量时,HEAPSORT 的正确性:在算法的第 2~5行 for 循环每次迭代开始时,子数 ...
- LeetCode 数、二叉树、二叉搜索树篇(94、144、145)
94. 二叉树的中序遍历 给定一个二叉树,返回它的中序 遍历. 示例: 输入: [1,null,2,3] 1 2 / 3 输出: [1,3,2] 进阶: 递归算法很简单,你可以通过迭代算法完成吗? / ...
- 云小课|GaussDB(DWS)数据存储尽在掌控,冷热数据切换自如
阅识风云是华为云信息大咖,擅长将复杂信息多元化呈现,其出品的一张图(云图说).深入浅出的博文(云小课)或短视频(云视厅)总有一款能让您快速上手华为云.更多精彩内容请单击此处. 摘要: GaussDB( ...
- 带你用VUE实现上传图片效果
摘要:在逛b站时看到一个上传图片的效果,想着可以自己也做一个,因为原作者是用原生js写的,那我不如就用vue写好了,当然,是一个很小的东西,在HTML文件直接引用vue就好了,详细步骤如下~ 本文分享 ...
- 实例讲解将Graph Explorer搬上JupyterLab
摘要:基于 Graph Explorer 在 Jupyter 上进行图探索,可以大大降低编码成本,丰富 JupyterLab 的数据表现力. 本文分享自华为云社区<将 Graph Explore ...
- 机器人多目标包围问题(MECA)新算法:基于关系图深度强化学习
摘要:中科院自动化所蒲志强教授团队,提出一种基于关系图的深度强化学习方法,应用于多目标避碰包围问题(MECA),使用NOKOV度量动作捕捉系统获取多机器人位置信息,验证了方法的有效性和适应性.研究成果 ...