<tomcat-users>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="admin-gui"/>
<user username="jaky" password="123456" roles="manager-gui,admin-gui"/>
</tomcat-users>
在这里,rolename 不是随便定义的
manager-gui
role to a user named
tomcat
with a password of
s3cret
, add the following to the config file listed above.
<role rolename="manager-gui"/> <user username="tomcat" password="s3cret" roles="manager-gui"/>
Note that for Tomcat 7 onwards, the roles required to use the manager application were changed from the single
manager
role to the following four roles. You will need to assign the role(s) required for the functionality you wish to access.
manager-gui
- allows access to the HTML GUI and the status pagesmanager-script
- allows access to the text interface and the status pagesmanager-jmx
- allows access to the JMX proxy and the status pagesmanager-status
- allows access to the status pages only
The HTML interface is protected against CSRF but the text and JMX interfaces are not. To maintain the CSRF protection:
- Users with the
manager-gui
role should not be granted either themanager-script
ormanager-jmx
roles. - If the text or jmx interfaces are accessed through a browser (e.g. for testing since these interfaces are intended for tools not humans) then the browser must be closed afterwards to terminate the session.
- Users with the
For more information - please see the Manager App HOW-TO.
BIO
APR< Connector port = "8080" protocol = "HTTP/1.1"
connectionTimeout = "20000"
redirectPort="8443" />
改为< Connector port = "8080" protocol = "org.apache.coyote.http11.Http11NioProtocol"
connectionTimeout = "20000"
redirectPort = "8443" />成功后在Tomcat Manager 中显示:
<Connector port="80" protocol="org.apache.coyote.http11.Http11AprProtocol"connectionTimeout="20000"redirectPort="8443" URIEncoding="UTF-8"/>
protocol | Sets the protocol to handle incoming traffic. The default value is |
7. 让测试说话
优化系统最忌讳的就是只调优不测试,有时不适当的优化反而会让性能更低。以上所有的优化方法都要在本地进行性能测试过后再不断调整参数,这样最终才能达到最佳的优化效果。
补充Bio、Nio、Apr模式的测试结果:
对于这几种模式,我用ab命令模拟1000并发测试10000次,测试结果比较意外,为了确认结果,我每种方式反复测试了10多次,并且在两个服务器上都测试了一遍。结果发现Bio和Nio性能差别非常微弱,难怪默认居然还是Bio。但是采用apr,连接建立的速度会有50%~100%的提升。直接调用操作系统层果然神速啊,这里强烈推荐apr方式!
roduction |
The HTTP Connector element represents a Connector component that supports the HTTP/1.1 protocol. It enables Catalina to function as a stand-alone web server, in addition to its ability to execute servlets and JSP pages. A particular instance of this component listens for connections on a specific TCP port number on the server. One or more suchConnectors can be configured as part of a single Service, each forwarding to the associated Engine to perform request processing and create the response. If you wish to configure the Connector that is used for connections to web servers using the AJP protocol (such as the Each incoming request requires a thread for the duration of that request. If more simultaneous requests are received than can be handled by the currently available request processing threads, additional threads will be created up to the configured maximum (the value of the |
minProcessors:最小空闲连接线程数,用于提高系统处理性能,默认值为10
maxProcessors:最大连接线程数,即:并发处理的最大请求数,默认值为75
maxThreads和acceptCount这两个值
maxThreads | The maximum number of request processing threads to be created by this Connector, which therefore determines the maximum number of simultaneous requests that can be handled. If not specified, this attribute is set to 200. If an executor is associated with this connector, this attribute is ignored as the connector will execute tasks using the executor rather than an internal thread pool. |
acceptCount | The maximum queue length for incoming connection requests when all possible request processing threads are in use. Any requests received when the queue is full will be refused. The default value is 100. |
connectionTimeout | The number of milliseconds this Connector will wait, after accepting a connection, for the request URI line to be presented. Use a value of -1 to indicate no (i.e. infinite) timeout. The default value is 60000 (i.e. 60 seconds) but note that the standard server.xml that ships with Tomcat sets this to 20000 (i.e. 20 seconds). Unless disableUploadTimeout is set to |
- <Connector port="8080"
- protocol="org.apache.coyote.http11.Http11NioProtocol"
- connectionTimeout="20000"
- redirectPort="8443"
- maxThreads="500"
- minSpareThreads="20"
- acceptCount="100"
- disableUploadTimeout="true"
- enableLookups="false"
- URIEncoding="UTF-8" />