Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
apollo
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
apollo
Commits
d259b376
Commit
d259b376
authored
May 06, 2016
by
Jason Song
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #176 from nobodyiam/tomcat-concurrent-performance
able to adjust tomcat acceptor count
parents
ac2808e1
cc64acb8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
0 deletions
+48
-0
TomcatContainerCustomizer.java
...ctrip/apollo/biz/customize/TomcatContainerCustomizer.java
+45
-0
application.properties
apollo-biz/src/main/resources/application.properties
+3
-0
No files found.
apollo-biz/src/main/java/com/ctrip/apollo/biz/customize/TomcatContainerCustomizer.java
0 → 100644
View file @
d259b376
package
com
.
ctrip
.
apollo
.
biz
.
customize
;
import
org.apache.catalina.connector.Connector
;
import
org.apache.coyote.ProtocolHandler
;
import
org.apache.coyote.http11.Http11NioProtocol
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer
;
import
org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer
;
import
org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomizer
;
import
org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
;
import
org.springframework.core.env.Environment
;
import
org.springframework.stereotype.Component
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
@Component
public
class
TomcatContainerCustomizer
implements
EmbeddedServletContainerCustomizer
{
private
static
final
String
TOMCAT_ACCEPTOR_COUNT
=
"server.tomcat.acceptor-count"
;
@Autowired
private
Environment
environment
;
@Override
public
void
customize
(
ConfigurableEmbeddedServletContainer
container
)
{
if
(!(
container
instanceof
TomcatEmbeddedServletContainerFactory
))
{
return
;
}
if
(!
environment
.
containsProperty
(
TOMCAT_ACCEPTOR_COUNT
))
{
return
;
}
TomcatEmbeddedServletContainerFactory
tomcat
=
(
TomcatEmbeddedServletContainerFactory
)
container
;
tomcat
.
addConnectorCustomizers
(
new
TomcatConnectorCustomizer
()
{
@Override
public
void
customize
(
Connector
connector
)
{
ProtocolHandler
handler
=
connector
.
getProtocolHandler
();
if
(
handler
instanceof
Http11NioProtocol
)
{
Http11NioProtocol
http
=
(
Http11NioProtocol
)
handler
;
http
.
setBacklog
(
Integer
.
parseInt
(
environment
.
getProperty
(
TOMCAT_ACCEPTOR_COUNT
)));
}
}
});
}
}
apollo-biz/src/main/resources/application.properties
View file @
d259b376
...
...
@@ -7,3 +7,6 @@ spring.datasource.validationQuery=SELECT 1
spring.jpa.hibernate.naming_strategy
=
org.hibernate.cfg.EJB3NamingStrategy
spring.jpa.hibernate.globally_quoted_identifiers
=
true
spring.jpa.properties.hibernate.globally_quoted_identifiers
=
true
# Tomcat configuration
server.tomcat.acceptor-count
=
1024
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment