1. basic components:
Server,
Service:
Connector (http, https, ajp for Apache reverse proxy), Engine
Engine:
Realm for security configuration, etc., as UserDatabaseRealm
Host: Valve chain, such as built-in AccessLogValve can access log records
DefaultServlet unified treatment of static resources:
Process: doGet method of determining whether there is a resource file, whether the file is read, according to the file type stream content-type, time written to the output file
JspServlet the JSP requests: url-pattern = * .jsp or * .jspx
jsp compilation process: JspServlet determine whether Servelt JSP file creation / expiration (such as class file modification time and jsp different file modification time, tomcat will create a new classLoader load the same jsp),
Compiler generated by the Servlet file, call the method _jspService Servelt if tomcat closed dev mode, the dynamic loader fails
HttpServletRequest: use the facade pattern
getParameter method, it is determined whether the parsed parameters, if not, the key parameters to be parsed, the parsed parameters into Map <String, List> structure, so that each
When you call getParameter method returns the first value key of
Filter, FilterChain: Filter after every completed call FilterChain of doFilter method calls the next Filter
Connector: Depending on the configuration of using different protocol ProtocolHandler, the request is handled entirely by Handler, such Http11NioProtocol
Connector will file exceeds 48k direct sendfile (channel.transferTo) sent without compression, reducing CPU utilization
Endpoint Handler for internal use request receiving process
Executor: Connector can be configured to use the thread pool
跨域请求:response.setHeader("Access-Control-Allow-Origin","*"); CorsFilter
Optimization Tomcat GC: gc select the appropriate algorithm according to the delay and throughput characteristics of the application
ParallelGC throughput priority, can not meet the demand for low latency
CMS: old's recovery and parallel applications, low latency (need to configure the -XX: + UseParNewGC implement the new generation of parallel recovery, the default single-threaded), single-core server needs to configure
CMS application threads and cpu collection thread share ratio (alternating application threads to run garbage collector).
-XX: + UseCMSCompactAtFullCollection compression of the old generation in Full GC time
-XX:+UseG1GC
-XX: + DisableExplicitGC: not recommended to open, Java NIO heap memory outside the code has explicitly call System.gc
ELParser: EL analytical expressions
Load class:
Webapp class loader: first load it, can not find in their own class path will be re-commissioned parent (base class not allowed to reload, and servlet-api not allowed to reload)
Different examples of applications using WebappClassloader
If the parent is not delegated to achieve a plurality of spacer web app
When the application starts, it will create a corresponding WebappClassLoader
Common class loader: WebappClassloader the parent, common to all applications visible class