Tuesday, October 30, 2012

Tomcat architecture

Here is a sum up on the architecture of tomcat for a quick recap:

Server
  • Is the top level component.
  • Shutdown port, string are configured here, but the request should be sent from same server on which Tomcat is running
  • Only one per jvm
  • Any implementation of org.apache.catalina.Server can be used via className attribute, if not specified org.apache.catalina.core.StandardServer is used
  • Global naming resources are configured here
  • Listeners could be configured here
Listener
  • Performs actions when specific events occur, usually Tomcat starting or Tomcat stopping
  • May be nested inside a Server, Engine, Host or Context only
  • Some Listeners are only intended to be nested inside specific elements only
  • APR Lifecycle, Jasper, Server Lifecycle, Global Resources Lifecycle, JMX Remote Lifecycle listeners could be configured only within Server
Container
  • Any one of Engine, Host, Context, and Cluster are referred as Container
  • Engine contains Host, it contains Context.  Cluster could be inside Engine or Host
Service
  • Groups a container (of type Engine) with a set of Connectors
  • Cannot define sub-components at level as it is not a Container
  • Only components that may be nested inside a Service element are one or more Connector elements, followed by exactly one Engine element
  • Can have multiple services under server, name must be unique (probably when we want one per protocol?)
  • Any implementation of org.apache.catalina.Service can be used via className attribute, if not specified org.apache.catalina.core.StandardService is used
 Connector
  • Is associated with a TCP port to handle communications between the Service and the clients
 Engine
  • Highest-level of a container, contains one or more Hosts
  • Represents the entire request processing machinery associated with a particular Service
  • Receives and processes all requests from one or more Connectors, and returns the completed response to the Connector for ultimate transmission back to the client
  • Exactly one Engine element MUST be nested inside a Service element, following all of the corresponding Connector elements associated with this Service
Host
  • Receives HTTP requests from the HTTP connector, and direct them to the correct host based on the hostname/IP address in the request header
  • Exactly one of the Hosts associated with each Engine MUST have a name matching the defaultHost attribute of that Engine
  • Can nest at most one instance of Realm, Valve
Realm
  • A Realm is a database of user, password, and role for authentication
  • You can define Realm for any container, such as Engine, Host, and Context, and Cluster
Valve
  •  A Valve can intercept HTTP requests before forwarding them to the applications, for pre-processing the requests
  • A Valve can be defined for any container, such as Engine, Host, and Context, and Cluster

No comments: