Nginx and Tomcat server optimized nginx Tomcat load balancing Nginx tomcat and static isolation Nginx Tomcat Access

Source: Internet
Author: User
Tags nginx server
1.Nginx Server optimization (mainly related to the configuration of some properties of the nginx.conf file)

#一般建议小于CPU个数, the general process runs on the CPU, and Nginx is a non-blocking multiplexed Epoll model that takes time
1.worker_processes
#将work process is bound to a specific CPU to avoid switching overhead between CPUs (8-core setup 00000001 00000010 00000100 00001000)
2.worker_cpu_affinity 0001 0010 0100 1000
#进程最大可以打开文件描述符数量502错误 (System descriptor support maximum/number of processes)
3.worker_rlimit_nofile
#每个进程允许的最大连接数 (when doing a static server: Number of client connections =worker_connections* processes/2 number of client connections when doing reverse proxy server =worker_connections* processes/4)
4.worker_connections 200000
#设置http里面的访问日志和错误日志的打印级别或者关闭, reduce IO
5.http{access_log offl;error_log Logs/error.log Crit}
#启动内核复制模式 to keep IO most efficient
6.http{Sendfile on}
#连接时间保持长度, the advantage is to reduce the creation of connections and speed up response. However, the number of connections to the response will be limited (up to 100 connections, and no new connections will be created when they come up)
7.http{keepalive_timeout 30s}
# compression, compression of the minimum resource size, rank, the higher the level, the better the compression effect, occupy the server more serious resources.
8.gzip On/gzip_min_length 1000/gzip_comp_level
#压缩文件类型的选择, some file compression effect is not good choose not to compress, reduce server performance loss
9.gzip_type
#最大缓存数量, the file does not use survival time
10.open_file_cache max=655350 inactive=20s;
Open_file_cache_valid 30s #验证缓存有效时间间隔
Open_file_cache_min_uses 2 Minimum number of files used within the validity period
= = = Less than 2 times in 20 seconds, removed at 30 seconds when the hit detection is not up to standard

2.tomcat optimization

1. First optimize the catalina.sh file in the Tomcat installation directory bin directory
(1) Setting heap memory
java_opts= $JAVA _opts-server-xms1024m-xmx2048m
(2) Setting PermGen memory (Java.lang.OutOfMemoryError) jdk1.8 not set
-xx:permsize=256m-xx:maxpermsize=512m
(3) Set Java to run in a mode with no graphical display
-djava.awt.headless=true
2. Set Server.xml
Some of the parameters set


The above describes the Nginx and Tomcat server optimization, including the tomcat,nginx aspects of the content, I hope the PHP tutorial interested in a friend helpful.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.