Tomcat connector元素常用配置(最大连接数等)
在tomcat的server.xml中有类似:
<Connector port="" protocol="HTTP/1.1" connectionTimeout="" redirectPort="" maxSpareThreads="" maxThreads="" minSpareTHreads="" acceptCount="" maxProcessors="" URIEncoding="gbk" useBodyEncodingForURI="true"/>
的配置, 其中:
acceptCount="1000" 可接受的最大连接数
maxProcessors="1000" 最大活动线程数
port="8080" 服务端口
protocol="HTTP/1.1" 服务协议
connectionTimeout="20000" 超时时间 单位是ms
redirectPort="8443" 重定向端口 需要安全通信的场合,将把客户请求转发至SSL的redirectPort端口
maxThreads:Tomcat可创建的最大的线程数,每一个线程处理一个请求; maxThreads决定了tomcat的最大线程阀值,需要设置的大一些
minSpareThreads:最小备用线程数,tomcat启动时的初始化的线程数;
maxSpareThreads:最大备用线程数,一旦创建的线程超过这个值,Tomcat就会关闭不再需要的socket线程;
URIEncoding="gbk" 设置tomcat默认的转码格式
查看$TOMCAT_HOME/webapps/tomcat-docs/config/http.html这个说明文档,有如下说明: URIEncoding:This specifies the character encoding used to decode the URI bytes, after %xx decoding the URL. If not specified, ISO-8859-1 will be used. 也就是说,如果没有设置URIEncoding, Tomcat默认是按ISO-8859-1进行URL解码,ISO-8859-1并未包括中文字符,这样的话中文字符肯定就不能被正确解析了。
转载别人的博客:
一.Tomcat连接池配置 Tomcat想要承受大的并发量,必须增大连接数,一般的Tomcat的Connector可以做如下修改:
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="60000"
redirectPort="8443"
maxThreads="5000"
acceptCount="500"
minSpareThreads="100"
maxSpareThreads="5000"
enableLookups="false"
compression="on"
compressionMinSize="2048"
compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain"
disableUploadTimeout="true"
URIEncoding="UTF-8"
/>
其中几个关键的参数:
connectionTimeout:连接超时,毫秒为单位.对于高并发对实时要求不高的可以使适当增加该值
maxThreads:最大并发连接数
acceptCount:在超过最大连接数后,可以接受的排队数量
minSpareThreads:Tomcat初始化时默认创建的线程数,也是以后线程增加时一次增加的最小数量
maxSpareThreads:这个参数标识,一旦创建的线程数量超过这个值,Tomcat就会关闭不活动的线程
enableLookups:关闭DNS查询 在实现中,我们发现使用该配置,连接数上去之后很难下降,导致CPU一直维持在一个比较高的水平.
后来我们换了一种连接方式,采用线程池的方式,首先定义一个Executor:
<Executor name="tomcatThreadPool"
namePrefix="tomcatThreadPool-"
maxThreads="1000"
maxIdleTime="300000"
minSpareThreads="200"/>
参数的意义和上述相同
在Connector中使用定义的这个连接池:
<Connector executor="tomcatThreadPool"
port="20003" protocol="HTTP/1.1"
acceptCount="800"
minProcessors="300"
maxProcessors = "1000"
redirectPort="8443" />
minProcessors,maxProcessors与上面的minSpareThreads,maxThreads意义差不多. 使用连接池以后,发现连接数上升后如果一段时间没有请求了,连接数会很快下降,CPU的消耗得到了有效的降低, 处理能力得到了增强.
如何查看当前tomcat的连接数呢?
假设服务器上开启了 2个tomcat实例,分别监听8040和8050端口
netstat -na | grep ESTAB | grep 8040 | wc -l
netstat -na | grep ESTAB | grep 8050 | wc -l
二者之和,就是所有tomcat的连接数
Tomcat connector元素常用配置(最大连接数等)的更多相关文章
- tomcat安装以及常用配置
目录 一 什么是tomcat 二 tomcat 的版本: 三 tomcat的下载 3.1 tomcat9版本下载链接 3.2 tomcat8.5版本下载链接 四 tomcat的安装 4.1 java环 ...
- Apache、tomcat、Nginx常用配置合集
配置文件地址: Apache: /etc/httpd/conf/httpd.conf tomcat: /usr/local/tomcat/conf/server.xml Nginx : /usr/l ...
- Tomcat服务器的常用配置
1.如何修改端口号, tomcat启动后经常会报端口冲突, 怎么办 如果部署在Linux环境下面, 首先使用netstat -apn命令检查是否是真的端口已经被占用了 如果真的被占用,进入tomcat ...
- Tomcat server.xml常用配置 含有外带文件及默认host
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE server-xml [<!ENTITY ...
- Tomcat记录-tomcat常用配置详解和优化方法(转载)
常用配置详解 1 目录结构 /bin:脚本文件目录. /common/lib:存放所有web项目都可以访问的公共jar包(使用Common类加载器加载). /conf:存放配置文件,最重要的是serv ...
- tomcat常用配置详解和优化方法
tomcat常用配置详解和优化方法 参考: http://blog.csdn.net/zj52hm/article/details/51980194 http://blog.csdn.net/wuli ...
- Tomcat服务器常用配置和HTTP简介
国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html 内部邀请码:C8E245J (不写邀请码,没有现金送) 国 ...
- JavaEE:Tomcat服务器常用配置和HTTP简介
Web服务器常用配置1.Web系统采用B/S结构通信的:Browser --- Server1)浏览器向服务器发送访问目标资源请求(请求)2)服务器根据请求的目标资源路径,在服务器端进行查找(请求查找 ...
- Tomcat常用配置修改
Tomcat常用配置修改 说明 运行需要设置环境变量 JAVA_HOME 即JDK安装目录 tomcat 默认登录地址 http://localhost:8080 配置tomcat 1.端口设置 打开 ...
随机推荐
- java.lang.String
1.String 是一个类,广泛应用于 Java 程序中,相当于一系列的字符串.在 Java 语言中 strings are objects.创建一个 strings 最直接的方式是 String g ...
- javascript平时小例子③(setInterval使用1)
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>& ...
- 讨论一下hibernate如何动态注册一个动态生成的实体类
如何动态生成实体类请参考这篇博文:http://www.cnblogs.com/anai/p/4269858.html 下面说说得到实体类后,如何能使用hibernate的接口来进行数据访问. 我们都 ...
- [转]从网页Web上调用本地应用程序(.jar、.exe)的主流处理方法
这个方法主要思路是利用自定义URL Protocol来调用应用程序.浏览器在解析到自定义URL Protocol之后,会寻找注册表,然后通过注册表启动相应的程序,然后启动改程序,传入参数.对于我这个项 ...
- C# Color
一.创建一个Color对象: Color c=Color.FromKnownColor(KnownColor.colorname); 二.四种同样颜色的不同方式: Color c1=Color.Fro ...
- Algorithm | Tree traversal
There are three types of depth-first traversal: pre-order,in-order, and post-order. For a binary tre ...
- A trip through the Graphics Pipeline 2011_08_Pixel processing – “fork phase”
In this part, I’ll be dealing with the first half of pixel processing: dispatch and actual pixel sha ...
- A trip through the Graphics Pipeline 2011_05
After the last post about texture samplers, we’re now back in the 3D frontend. We’re done with verte ...
- Centos7 安装 nodejs
https://nodejs.org/en/download/package-manager/ 设置node v4的源 curl --silent --location https://rpm.nod ...
- 如何使用 vimdiff 来 git diff /svn diff
#git 如何实现vimdiffgit config --global diff.tool vimdiff git config --global difftool.prompt false git ...