秒殺tomcat最適化
2749 ワード
秒殺tomcat最適化
QQ, !
要件:
本文はtomcat 8.5.20を目標とする
1.
2.
3.APR
APR最適化関連パッケージ
1.メモリの最適化
catalina
JAVA_OPTS="-server -Xms2048M -Xmx2048M -XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=$CATALINA_HOME/logs/heap.dump"
# Register custom URL handlers
server.xml
maxConnections="300"
acceptCount="200"
maxThreads="400"
minSpareThreads="200"/>
${tomcat}/webapps/docs/config/host.html
autoDeploy:This flag value indicates if Tomcat should check periodically for new or updated web applications while Tomcat is running
${tomcat}/webapps/docs/config/http.html
enableLookups:false
${tomcat}/webapps/docs/config/context.html:
reloadable:false
2.もしあなたのウェブサイトが高い同時性を持っているならば、APRモードを使うことを提案します
http://apr.apache.org/
:
APR 1.2+ development headers (libapr1-dev package) OpenSSL 1.0.2+ development headers (libssl-dev package) JNI headers from Java compatible JDK 1.4+ GNU development environment (gcc, make)
yum install apr* openssl-devel gcc make
tar zxvf apr-1.4.5.tar
cd apr-1.4.5
./configure --prefix=/usr/local/apr
make
make install
tar -zxvf apr-iconv-1.2.1.tar.gz
cd apr-iconv-1.2.1
./configure --prefix=/usr/local/apr-iconv --with-apr=/usr/local/apr
make
make install
yum install expat-devel
tar zxvf apr-util-1.3.12.tar.gz
cd apr-util-1.3.12
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make
make install
openssl 1.0.2
./config --prefix=/usr/local/openssl
Makefile:
vi Makefile
:CFLAG= -DOPENSSL_THREADS
: CFLAG= -fPIC -DOPENSSL_THREADS
-fPIC
:
make && make install
cd bin
tar -zxvf tomcat-native.tar.gz
cd tomcat-native-1.2.12-src
cd native
./configure --with-apr=/usr/local/apr --with-ssl=/usr/local/openssl
make
make install
catalina.sh:
JAVA_OPTS="$JAVA_OPTS -Djava.library.path=/usr/local/apr/lib
: apr ,jvm native , Metaspace , JVM :-XX:MetaspaceSize=128m
JAVA_OPTS="-server -Xms2048M -Xmx2048M -XX:MetaspaceSize=128M -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=$CATALINA_HOME/logs/heap.dump"
server.xml: