마크 토마스 랑 ...
- 톰캣 커비터로 5년 넘게 일해왔다.
- 아파치 멤버
- 시니어 소프트웨어 엔지니어 이자 컨선턴트
- 스프링소스 Covalent 부서
- 성능, 트러블슈팅, 보안 전문가

톰캣 버전 얘기
- 6.0.x가 최신 버전
- 7.x가 슬슬 수면위로 들어나고 있다.(서블릿 3.0 스펙, ..)

주요 안건
- 대규모 개발에서 톰캣
- 톰캣 & JVM 업그레이드
- ...

setenv.sh - 여기서 커스텀 옵션
- JAVA_HOME
- JAVA_OPTS
- CATALINA_OPTS
- ...
- 이 파일은 톰캣이 기본으로 제공하는게 아니니깐 복사해서 가지고 다니면서 수정하라.
- 여기서 자바 버전 설정하면 톰캣 스트립트 수정하지 않아도 된다.
- 인스턴스 데이터를 분리해낼 수 있다.(별도의 톰캣 서버 인스턴스)
- 톰캣이나 JVM을 변경할 때 이 파일을 이용하면 편하다.
- RPM을 사용하면 롤백 과정이 복잡하다.

Production 세팅

server.xml
- <Server port="8005" shutdown="SHUTDOWN" > : will allow unauthorized shut-down of Tomcat instance
- <Server port="-1" shutdown="SHUTDOWN" > : 셧다운 포트 disable.
- 톰캣 멈추기: kill <pid>

애플리케이션 제거하기
- ROOT - 제공할 애플리케이션으로 대체하기
- 다음 폴더는 제거하는게 보안 최선책(security best practice)이다.
- /examples
- /docs
- /manager(원격 배포를 할 수 없게 된다.)
- /host-manager(원격 호스트 관리를 할 수 없게 된다.)

로깅
- conf/loggin.properties: 핸들러 등록
.handlers = \1catalina.org.apache.juli.FileHandler
- 파일에만 로깅한다.
- 개발할 때 가끔은 stdou/stderr가 더 쉬울때도 있다.

Rotating catalina.out(모르는 거)
- http://www.cronolog.org - 예제 도구
>> "$CATALINA_BASE" /logs/catalina.out 2>&1 &
-  하루 주기로 로테이트
2>&1 | /bin/cronlog/ ...

접근 로깅(이것도 모르는거..)
- valve를 사용해서 접근 로깅을 할 수 있다.

글로벌 기본값
- ex) 커넥션 풀
- 모든 기본 값은 conf/context.xml 또는 conf/web.xml 에 설정할 수 있다.
- 기본값은 애프리케이션에서 설정한 값이 재정의할 수 있다.

Templating
- catalina.properties의 값을 server.xml에서 사용할 수 있다.

배포 방법
- server.xm에서 <Context> 엘리먼트 사용하기
- WAR 파일 자동 배포
- 디렉토리 자동 배포
- XML 파일 자동 배포
- 원격 배포
- Best Practice는 한 가지 선호하는 방법을 사용하는 것이다. 여러 방법을 혼용하면 얘상치 못한 상황을 보게 될지도 모른다.

Building Tomcat Native(이것도 모르는 거)
- OpenSSL 소스 distro 압축 풀기
- APR 소스 distro 압출 풀기
- APR Util 소스 disto 압축 풀기
- tomcat-nartive.tar.gz distro 압축 풀기
- setenv.sh (64비트로 컴파일 했으면 64 비트 JVM 사용하도록 설정해야 한다.)

커넥터 선택하기(아파치 커넥터 얘기하는건가?)
- BIO(Blocking IO)
- NIO(None-blocking IO)
- 왜 NIO 커넥터를 사용하려는가?
- 네이티브(APR) 커넥터는 솔라시스에서 안정적이지 않다.
- NIO는 순수 자바 솔루션이다.
- SSL로 NIO와 BIO를 교환하는 건 간단하다.

버추얼 호스팅은 무엇인가?
- 단일 톰캣 인스턴스에 여러 호스트 이름 주는거
- http://a.foo.com
- http://b.foo.com

호스트 정의
- server.xml에 호스트 설정
- 자신만의 appBase 필요함
- ...

버추어 호스팅 컨텍스트 정의
- 표준 방법 적용 http://apache.org/tomcat-6.0-doc/config/context.html

버추어 호스팅 사용이 적당한 경우
- DNS 가 설정되어 있지 않을 때
- docBase == appBase
- ROOT.war 사용하지 않을 때
- ...

문서화되어 있지 않은 옵션
- W3C Extended 로그 파일 포맷
- 캐싱 - private chaching을 권장한다.

스프링소스에서 아파치 톰캣 지원

질문 답변

Q: mod_jk vs mod_proxy_ajp ? Which is preferred for Apache2.2 to Tomcat6.0.x?
A: We recommend them in the following order
 mod_proxy_http, mod_jk, mod_proxy_ajp
 we prefer the HTTP protocol, if you want AJP, mod_jk is more stable than mod_proxy_ajp (which is the newest addition)

Q: mysql-connector: why not shared/lib?
A: since connection pool library doesn't have access to shared/lib
 if you want mysql jars in the webapp, you can add a connection pool library in your webapp and configure it there. Tomcat has to follow the class loader rules

Q: Currently we see that with 3 apache servers having each 100 clients (prefork + mod_jk) each tomcat server (10) has also 100 threads. Which doesn't look logical. Is there a mod_jk config option which could change this behaviour?
A: in httpd.conf -
 JkOptions +DisableReuse
 this will turn of AJP keep alive, and you no longer have to balance threads

Q: Is Log Valves a tomcat6 feature?
A: AccessLogValves have been around in Tomcat since Tomcat 5 (possible 4) Can be found under the Valves section of the Tomcat Configuration Reference

Q: does the connector preference also apply to AJP connections (using mod_jk)?
A: Yes, with the exception of SSL. No SSL support on AJP, but you can keep more connections than threads using APR/AJP, so you no longer have to carefully balance maxThreads(Tomcat) with MaxClients(httpd)

Q: Is there a way to solve the problem of "PermGen memory error" that usually arises after many reloads of the contexts?
A: PermGen error, are very hard to resolve, as they are very subtle bugs in the web applications
 If the bug can't be fixed, increase -XX:MaxPermSize large enough to be able to reload applications during the day and then do a restart of tomcat at night

Q: If you are passing .jsp pages to Tomcat from Apache , do the Tomcat docBase and the Apache Document root need to be the same for the given Virtual Server ?
A: For security reasons, you don't want httpd to have access to the Tomcat file system (webapps), as one can exploit your configuration to download your code

ps: 큰일이네;; PPT에 집중하니까 귀는 하나도 안 들리네;;