Summary
If a request is for a simple, static file such as HTML or an image, the Apache web server will send that file back to the client. If the request requires some logic, the Apache web server passes the request to the Tomcat server. As such, the Tomcat server is considered to be part of the middle-tier of a modern software architecture topology. Apache Tomcat is an open-source Java application web server. All that means is that it enables you to run Java on your Operating System (OS). It’s also an effective tool that can aid in your deployment of the web pages you create. If you’re looking for a Java web servlet, Apache Tomcat is a solid choice. Tomcat is normally defined as a reference implementation of the Java Servlet and the Java Server Page (JSP) Specifications. It basically executes Java servlets and renders web pages which include JSP coding. It is available on the Apache site in both source and binary versions.
Running cluster of Tomcat servers behind the Web server can be demandingtask if you wish to archive maximum performance and stability.This article describes best practices how to accomplish that.By Mladen Turk
Fronting Tomcat
One might ask a question Why to put the Web server in front of Tomcatat all? Thanks to the latest advances in Java Virtual Machines (JVM)technology and the Tomcat core itself, the Tomcat standalone is quitecomparable with performance to the native web servers.Even when delivering static content it is only 10%slower than recent Apache 2 web servers.
The answer is: scalability.
Tomcat can serve many concurrent users by assigning a separate thread ofexecution to each concurrent client connection. It can do that nicely butthere is a problem when the number of those concurrent connections rise.The time the Operating System will spend on managing those threads will degradethe overall performance. JVM will spend more time managing and switching thosethreads then doing a real job, serving the requests.
Besides the connectivity there is one more significant problem, and it causedby the applications running on the Tomcat. A typical application will processclient data, access the database, do some calculations and present the databack to the client. All that can be a time consuming job that in most casesmust be finished inside half a second, to achieve user perception of a workingapplication. Simple math will show that for a 10ms application response time youwill be able to serve at most 50 concurrent users, before your users startcomplaining. So what to do if you need to support more users?The simplest thing is to buy a faster hardware, add more CPU or add more boxes.A two 2-way boxes are usually cheaper then a 4-way one, so adding more boxesis generally a cheaper solution then buying a mainframe.
First thing to ease the load from the Tomcat is to use the Web serverfor serving static content like images, etc..
| Figure 1. Generic configuration |
Figure 1. shows the simplest possible configuration scenario. Here theWeb server is used to deliver static context while Tomcat only does thereal job - serving application. In most cases this is all that you will need.With 4-way box and 10ms application time you'll be capable of serving 200concurrent users, thus giving 3.5 million hits per day, that is by allmeans a respectable number.
For that kind of load you generally do not need the Web server in front ofTomcat. But here comes the second reason why to put the Web server in front, andthat is creating an DMZ (demilitarized zone). Putting Web server on acomputer host inserted as a 'neutral zone' between a company's private networkand the internet or some other outside public network gives the applicationshosted on Tomcat capability to access company private data, while securingthe access to other private resources.
| Figure 2. Secure generic configuration |
Beside having DMZ and secure access to a private network there canbe many other factors like the need for the custom authentication for example.
If you need to handle more load you will eventually have to add more Tomcatapplication servers. The reason for that can be either caused by the factthat your client load just can not be handled by a single box or that youneed some sort of failover in case one of the nodes breaks.| Figure 3. Load balancing configuration |
Configuration containing multiple Tomcat application servers needs a load balancerbetween web server and Tomcat. For Apache 1.3, Apache 2.0 and IIS Web serversyou can use Jakarta Tomcat Connector (also known as JK), because it offersboth software load balancing and sticky sessions. For the upcoming Apache 2.1/2.2use the advanced mod_proxy_balancer that is a new module designed and integratedwithin the Apache httpd core.
Calculating Load
When determining the number of Tomcat servers that you will need to satisfythe client load, the first and major task is determining the Average ApplicationResponse Time (hereafter AART). As said before, to satisfy the user experiencethe application has to respond within half of second. The content received by the clientbrowser usually triggers couple of physical requests to the Web server (e.g. images). Theweb page usually consists of html and image data, so client issues a seriesof requests, and the time that all this gets processed and delivered iscalled AART. To get most out of Tomcat you should limit the number of concurrentrequests to 200 per CPU.
So we can come with the simple formula to calculate the maximumnumber of concurrent connections a physical box can handle:
The other thing that you must care is the Network throughput between theWeb server and Tomcat instances. This introduces a new variable calledAverage Application Response Size (hereafter AARS), that is the number ofbytes of all context on a web page presented to the user. On a standard100Mbps network card with 8 Bits per Byte, the maximum theoreticalthroughput is 12.5 MBytes.
For a 20KB AARS this will give a theoretical maximum of 625 concurrentrequests. You can add more cards or use faster 1Gbps hardware if needto handle more load.
The formulas above will give you rudimentary estimation of the number ofTomcat boxes and CPU's that you will need to handle the desirednumber of concurrent client requests.If you have to deploy the configuration withouthaving actual hardware, the closest you can get is to measure the AART ona test platform and then compare the hardware vendor Specmarks.
Fronting Tomcat with Apache
If you need to put the Apache in front of Tomcat use the Apache2 withworker MPM. You can use Apache1.3 or Apache2 with prefork MPM for handlingsimple configurations like shown on the Figure 1. If you need to frontseveral Tomcat boxes and implement load balancing use Apache2 and workerMPM compiled in.
MPM or Multi-Processing Module is Apache2 core feature and it is responsiblefor binding to network ports on the machine, accepting requests,and dispatching children to handle the requests.MPMs must be chosen during configuration, and compiled into the server.Compilers are capable of optimizing a lot of functions if threads are used,but only if they know that threads are being used. Because some MPMs use threadson Unix and others don't, Apache will always perform better if the MPM ischosen at configuration time and built into Apache.
Worker MPM offers a higher scalability compared to a standard preforkmechanism where each client connection creates a separate Apache process.It combines the best from two worlds, having a set of child processes eachhaving a set of separate threads. There are sites that are running10K+ concurrent connections using this technology.
Connecting to Tomcat
In a simplest scenario when you need to connect to single Tomcat instanceyou can use mod_proxy that comes as a part of every Apache distribution.However, using the mod_jk connector will provide approximately double the performance.There are several reasons for that and the major is that mod_jk manages apersistent connection pool to the Tomcat, thus avoiding opening and closingconnections to Tomcat for each request. The other reason is that mod_jk uses a customprotocol named AJP an by that avoids assembling and disassembling headerparameters for each request that are already processed on the Web server.You can find more details about AJPprotocol on the Jakarta Tomcat connectors site.
For those reasons you can use mod_proxy only for the low load sitesor for the testing purposes. From now on I'll focus on mod_jk for frontingTomcat with Apache, because it offers better performance and scalability.
One of the major design parameters when fronting Tomcat with Apacheor any other Web server is to synchronize the maximum number of concurrentconnections. Developers often leave default configuration values from both Apache andTomcat, and are faced with spurious error messages in theirlog files. The reason for that is very simple. Tomcat and Apache can each accept onlya predefined number of connections. If thosetwo configuration parameters differs, usually with Tomcat havinglower configured number of connections, you will be faced with thesporadic connection errors. If the load gets even higher, your users willstart receiving HTTP 500 server errors even if your hardware is capableof dealing with the load.
Determining the number of maximum of connections to the Tomcatin case of Apache web server depends on the MPM used.
| MPM | configuration parameter |
|---|---|
| Prefork | MaxClients |
| Worker | MaxClients |
| WinNT | ThreadsPerChild |
| Netware | MaxThreads |
On the Tomcat side the configuration parameter that limits the numberof allowed concurrent requests is maxProcessors with default value of20. This number needs to be equal to the MPM configuration parameter.

Load balancing
Load balancing is one of the ways to increase the number of concurrentclient connections to the application server. There are two types ofload balancers that you can use. The first one is hardware load balancerand the second one is software load balancer. If you are using load balancinghardware, instead of a mod_jk or proxy, it must support a compatible passiveor active cookie persistence mechanism, and SSL persistence.
Mod_jk has an integrated virtual load balancer worker that can containany number of physical workers or particular physical nodes.Each of the nodes can have its own balance factor or the worker'squota or lbfactor. Lbfactor is how much we expect this workerto work, or the workers's work quota.This parameter is usually dependent on the hardware topology itself, andit offers to create a cluster with different hardware node configurations.Each lbfactor is compared to all other lbfactors in the cluster and itsrelationship gives the actual load. If the lbfactors are equal the workersload will be equal as well (e.g. 1-1, 2-2, 50-50, etc...). If firstnode has lbfactor 2 while second has lbfactor 1, than the first nodewill receive two times more requests than second one.This asymmetric load configuration enables to have nodes with differenthardware architecture.
In the simplest load balancer topology with only two nodes in thecluster, the number of concurrent connections on a web server sidecan be as twice as high then on a particular node. But ...
The upper statement means that the sum of allowed connections on aparticular nodes does not give the total number of connections allowed.This means that each node has to allow a slightly higher number ofconnections than the desired total sum. This number is usually a20% higher and it means that
So if you wish to have a 100 concurrent connections with two nodes,each of the node will have to handle the maximum of 60 connections.The 20% margin factor is experimental, and depends on the Apacheserver used. For prefork MPMs it can rise up to 50%, while forthe NT or Netware its value is 0%. The reason for that is thateach particular child process menages its own balance statisticsthus giving this 20% error for multiple child process web servers.
The minimum configuration for a three node cluster shown in theupper example will give the 25%-50%-25% distribution of the load,meaning that the node2 will get as much load as the rest of the two members.It will also impose the following number of maxProcessors for each particularnode in case of the MaxClients=200.
Using simple math the load should be 50-100-50 but we needed to add the20% load distribution error. In case this 20% additional load is not sufficient,you will need to set the higher value up to the 50%. Of course the averagenumber of connections for each particular node will still follow theload balancer distribution quota.
Sticky sessions and failower
Tomcat Server Download
One of the major problems with having multiple backendapplication servers is determining the client-server relationship.Once the client makes a request to a server application thatneeds to track user actions over a designated time period,some sort of state has to be enforced inside a stateless httpprotocol. Tomcat issues a session identifier thatuniquely distinguishes each user. The problem with that sessionidentifier is that he does not carry any information about theparticular Tomcat instance that issued that identifier.

Tomcat in that case adds an extra jvmRoute configurablemark to that session. The jvmRoute can be any name that willuniquely identify the particular Tomcat instance in the cluster.On the other side of the wire the mod_jk will use that jvmRouteas the name of the worker in it's load balancer list. This meansthat the name of the worker and the jvmRoute must be equal.
When having multiple nodes in a cluster you can improve your applicationavailability by implementing failover. The failover means that if theparticular elected node can not fulfill the request the another nodewill be selected automatically. In case of three nodes you are actually doubling yourapplication availability. The application responsetime will be slower during failover, but noneof your users will be rejected. Inside the mod_jk configuration thereis a special configuration parameter called worker.retries that has default value of 3, butthat needs to be adjusted to the actual number of nodes in the cluster.
If you add more then three workers to the load balanceradjust the retries parameter to reflect that number.It will ensure that even in the worse case scenario the requestgets served if there is a single operable node. Of course, therequest will be rejected if there are no free connections available on theTomcat side , so you should increase the allowed number of connectionson each Tomcat instance. In the three node scenario (1-2-1)if one of the nodes goes down, the othertwo will have to take its load. So if the load is divided equally you will needto set the following Tomcat configuration:
This configuration will ensure that 200 concurrent connections willalways be allowable no matter which of the nodes goes down. The reason fordoubling the number of processors on node1 and node3 is because theyneed to handle the additional load in case node2 goes down (load 1-1).Node2 also needs the adjustment becauseif one of the other two nodes goes down, the load will be 1-2. As youcan see the 20% load error is always calculated in.
| Figure 4. Three node example load balancer |
| Figure 5. Failover for node2 |
As shown in the two figures above setting maxProcessors depends bothon 20% load balancer error and expected single node failure. Thecalculation must include the node with the highest lbfactor asthe worst case scenario.
Domain Clustering model
Since JK version 1.2.8 there is a new domain clustering model andit offers horizontal scalability and performance of tomcat cluster.
Tomcat cluster does only allow session replication to all nodes in the cluster.Once you work with more than 3-4 nodes there is too much overhead and risk inreplicating sessions to all nodes. We split all nodes into clustered groups.The newly introduced worker attribute domain letmod_jk know, to which other nodes a session gets replicated (all workers withthe same value in the domain attribute). So a load balancing worker knows, onwhich nodes the session is alive. If a node fails or is being taken downadministratively, mod_jk chooses another node that has a replica of the session.
For example if you have a cluster with four nodes you can maketwo virtual domains and replicate the sessions only inside the domains.This will lower the replication network traffic by half
| Figure 6. Domain model clustering |
For the above example the configuration would look like:
Now assume you have multiple Apaches and Tomcats. The Tomcats are clustered andmod_jk uses sticky sessions. Now you are going to shut down (maintenance) onetomcat. All Apache will start connections to all tomcats. You end up with alltomcats getting connections from all apache processes, so the number of threadsneeded inside the tomcats will explode.If you group the tomcats to domain as explained above, the connections normallywill stay inside the domain and you will need much less threads.
Fronting Tomcat with IIS
Just like Apache Web server for Windows, Microsoft IIS maintainsa separate child process and thread pool for serving concurrent clientconnections. For non server products like Windows 2000 Professional orWindows XP the number of concurrent connections is limited to 10.This mean that you can not use workstation products for productionservers unless the 10 connections limit will fulfil your needs.The server range of products does not impose that 10 connectionlimit, but just like Apache, the 2000 connections is a limit whenthe thread context switching will take its share and slow down theeffective number of concurrent connections.If you need higher load you will need to deploy additional web serversand use Windows Network Load Balancer (WNLB) in front of Tomcat servers.
| Figure 7. WNLB High load configuration |
For topologies using Windows Network Load Balancer the same rules are in placeas for the Apache with worker MPM. This means that each Tomcat instancewill have to handle 20% higher connection load per node than its real lbfactor.The workers.properties configuration must beidentical on each node that constitutes WNLB, meaning that you will have toconfigure all four Tomcat nodes.
Apache 2.2 and new mod_proxy
For the new Apache 2.1/2.2 mod_proxy has been rewriten and hasa new AJP capable protocol module (mod_proxy_ajp) and integratedsoftware load balancer (mod_proxy_balancer).
Because it can maintain a constant connection pool to backedservers it can replace the mod_jk functionality.
The above example shows how easy is to configure a Tomcat cluster withproxy loadbalancer. One of the major advantages of using proxy is theintegrated caching, and no need to compile external module.
Mod_proxy_balancer has integrated manager for dynamic parameter changes.It offers changing session routes or disabling a node for maintenance.
| Figure 8. Changing BalancerMember parameters |
The future development of mod_proxy will include the option todynamically discover the particular node topology. It will also allowto dynamically update loadfactors and session routes.
About the Author
Mladen Turk is a Developer and Consultant for JBoss Inc in Europe, where he isresponsible for native integration. He is a long time commiter for Jakarta Tomcat Connectors,Apache Httpd and Apache Portable Runtime projects.
Links and Resources
Jakarta Tomcat connectors documentation
Apache 2.0 documentation
Apache 2.1 documentation
1. What is Tomcat?
Answer: Tomcat is a Java Servlet container and web server from the Jakarta project of the Apache software foundation.
A web server responds with web pages to requests from client browsers.
Web servers can provide dynamic content based on the requests sent by the user.
Tomcat is very good at this because it provides both Java servlet and JavaServerPages (JSP) technologies.
Tomcat can also be used as a web server for many applications even if free servlet and JSP engine are wanted.
It can be used standalone or used behind traditional web servers such as Apache httpd, with the traditional server serving static pages and Tomcat serving dynamic servlet and JSP requests.
2. Difference between apache and apache-tomcat server?
Answer: Apache:
Apache mostly serves static content by itself, but there are many add-on modules (some of which come with Apache itself) that let it modify the content and also serve dynamic content written in Perl, PHP, Python, Ruby, or other languages.
Basically Apache is an HTTP Server, serving HTTP.
Apache-Tomcat:
Tomcat is primarily a servlet/JSP container. It’s written in Java. It can serve static content too, but its main purpose is to host servlets and JSPs.
JSP files (which are similar to PHP, and older ASP files) are generated into Java code (HttpServlet), which is then compiled to .class files by the server and executed by the Java virtual machine.
Apache Tomcat is used to deploy your Java Servlets and JSPs. So in your Java project, you can build your WAR (short for Web ARchive) file, and just drop it in the deploy directory in Tomcat.
Although it is possible to get Tomcat to run Perl scripts and the like, you wouldn’t use Tomcat unless most of your content was Java.
Tomcat is a Servlet and JSP Server serving Java technologies
Note:
The two technologies can be used together through a connector module called mod_jk. This will allow you to use the Apache HTTP server to serve regular static webpages, and the Tomcat Servlet engine to execute servlets.
3. What are the directories under the apache-tomcat installation dir?
Answer: conf – Server configuration files (including server.xml)
logs – Log and output files
shared – For classes and resources that must be shared across all web applications
web-apps – Automatically loaded web applications
work – Temporary working directories for web applications
temp – directory used by the JVM for temporary files (java.io.tmpdir)
4. How to know your Apache tomcat version?
Answer: root@ubuntu:~# /usr/share/tomcat7/bin/version.sh
Using CATALINA_BASE: /usr/share/tomcat7
Using CATALINA_HOME: /usr/share/tomcat7
Using CATALINA_TMPDIR: /usr/share/tomcat7/temp
Using JRE_HOME: /usr/lib/JVM/java-1.7.0-OpenJDK-i386
UsingCLASSPATH: /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar
Server version: Apache Tomcat/7.0.26
Server built: Apr 1 2013 08:32:04
Server number: 7.0.26.0
OS Name: Linux
OS Version: 3.2.0-105-generic-page
Architecture: i386
JVM Version: 1.7.0_101-b00
JVM Vendor: Oracle Corporation
5. Where can be set roles, username, and password?
Answer: /conf/tomcat-users.xml
You might also like:
The VI Editor
Apache Server Interview Questions & Answers
PL/SQL Tutorial Part – 01
6. What Is Default Session Time Out In Tomcat?
Answer: The default session timeout 30 minutes in tomcat and can change in $TOMCAT_HOME/conf/web.xml via modifying below entry.
7. what is the configuration file in tomcat server?
Answer: Tomacat XML Configuration Files:
server.xml(TOMCAT-HOME/conf/server.xml)
web.xml (TOMCAT-HOME/conf/web.xml)
tomcat-users.xml (TOMCAT-HOME/conf/tomcat-users.xml)
8. How to change the default(8080) port number?
Answer: Go to the tomcat>conf folder.
Edit server.xml. (https://svrtechnologies.b-cdn.net/usr/share/tomcat/conf/server.xml)
Search “Connector port”
Replace “8080” by your port number.
Restart tomcat server.
For example, if you change the port to 1977, you would request the URL
Note: While changing the port number make sure that port is not already in use and port no should be greater than 1024, as ports less than or equal to 1024 require superuser access to bind to. ( python training )
9. How to start and shutdown to tomcat server?
Answer: There are two .sh file in cd $CATALINA_HOME/bin dir or in /usr/share/tomcat7/bin/
./startup.sh
./shutdown.sh
10. How do I enable Server Side Includes (SSI)?
Answer:
Two things have to be done for tomcat to acknowledge SSI scripts:
1. Rename $CATALINA_BASE/server/lib/servlets-SSI.renametojar to $CATALINA_BASE/server/lib/servlets-ssi.jar.
2. Uncomment the section of web.xml found in $CATALINA_BASE/conf/web.xml that deals with SSI. it looks like this when it is uncommented:
SSI
org.apache.catalina.ssi.SSIServlet
buffered 1
debug 0
expires 666
isVirtualWebappRelative 0
11. How do you define a welcome file list?
Answer: We can define the welcome file list in web.xml deployment descriptor by using the welcome-file-list tag as shown in the following sample code:
index.html
index.htm
index.jsp
The actual welcome file being presented to the user shall be decided from the above list. If index.html is present then it shall be shown. If no index.html file is present in the root folder of a web application, then server tries to find a file with the name index.htm and that also fails then it finds index.jsp.
12. What is the directory structure of a web application deployed on Tomcat?
Answer: The typical web application structure which is deployed on tomcat is:
Tomcat-application-structure
The contents of the WEB-INF folder shall look like:
web-inf
13. Can we run multiple instances of Tomcat server on a single machine? If yes how?
Answer: I had posted a blog entry about configuring multiple instances of tomcat on a single machine. ( data science training online )
14. Explain what does the MAC stands for?
Answer:
MAC means Medium Access Control
15. Mention what are Catalina’s Configuration files?
Answer: Catalina consists of configuration files are
- policy
- properties
- properties
- xml
- xml
- Tomcat-users.xml
- xml
16. How To Communicate Between Two Web Servers In Two Diff Systems?
Answer: By using a plug module.
it is having two containers:
Web Container (for interpreting/executing servlets and jsps)
EJB container(for executing EJBs).
it can perform operations like load balancing, transaction demarcation, etc.
17. ow to communicate between two webservers in two diff systems?
Answer: By using a plug module.
18. Explain When To Use Ssl With Tomcat?
Answer: You would use Tomcat to handle connection when you are running Tomcat as a stand-alone web server.
19. Does Apache have any limits when it comes to URL aliasing and rewriting?
Answer: No, Apache web server has no fixed limit on the total aliases and redirects that may be prompted in the configuration files. ( hadoop training online)
20. Does the installation of Apache HTTP server require SSL or PHP support?
Answer: The answer is yes since the installation of Apache requires the support of both the SSL and PHP support.
21. Who is responsible for Tomcat?
Answer: The Apache Software Foundation. The Apache Software Foundation is an umbrella organization that looks after a number of Open Source projects.
Jakarta is the group name for the Java-based projects of the Apache Software Foundation.
Tomcat is a Web Server that handles server-side Java (in the form of Servlets and JSPs), and it’s a part of the Apache Jakarta project group. Tomcat is the “reference” implementation of the Servlet and JSP standards – in other words, if it runs under Tomcat, it should run under any compliant Servlet / JSP container.
22. What is the web.xml configuration file?
Answer: The web.xml file is derived from the Servlet specification and contains information used to deploy and configure the components of your web applications. ( data science training online )
23. What is Coyote?
Answer: Coyote is a Connector component for Tomcat that supports the HTTP 1.1 protocol as a web server. This allows Catalina, nominally a Java Servlet or JSP container, to also act as a plain web server that serves local files as HTTP documents.
Coyote listens for incoming connections to the server on a specific TCP port and forwards the request to the Tomcat Engine to process the request and send back a response to the requesting client.
Coyote is the HTTP connector that’s built into Tomcat and provides Tomcat with an interface that browsers can connect to.
Tomcat Web Application
24. What is the engine?
Answer: The Engine element represents the entire request processing machinery associated with a particular Catalina Service. It 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. ( devops training online )
25. What is the host?
Answer: The Host element represents a virtual host, which is an association of a network name for a server.
26. What is the Context?
Answer: The Context element represents a web application, which is run within a particular virtual host. Each web application is based on a Web Application Archive (WAR) file, or a corresponding directory containing the corresponding unpacked contents, as described in the Servlet Specification.
27. What is Tomcat-users.xml configuration file?
Answer: It is where the Tomcat users are defined and it is located in the conf folder of the Tomcat server root. company
28. What is Catalina?
Answer: Catalina is Tomcat’s servlet container. Catalina implements specifications for servlet and JavaServer Pages. Catalina is the Java Engine (JRE / JVM) that’s built into Tomcat and provides an environment in which Servlets can be run.
29. What is Service?
Answer: A Service element represents the combination of one or more Connector components that share a single Engine component for processing incoming requests. One or more Service elements may be nested inside a Server element.
30. What is a Tomcat cluster?
Answer: This component is used to manage large applications. It is used for load balancing and can be achieved through many techniques. Apache Tomcat cluster is used to manage more traffic. It provides multiples instances of the Tomcat server with its content balanced between these instances.
31. What is the Tomcat default port?
Answer: The default port for Tomcat is 8080. You can change the default port by editing the file server.xml under the conf folder in the Tomcat installed directory. Change the property Connector port=”8080″ to the desired port and restart Tomcat so the changes can take effect.
32. What do you know about Tomcat history?
Answer: Tomcat started off as a servlet reference implementation by James Duncan Davidson, a software architect at Sun Microsystems. He later helped make the project open source and played a key role in its donation by Sun Microsystems to the Apache Software Foundation. The Apache Ant software builds automation tool was developed as a side-effect of the creation of Tomcat as an open source project.
33. What is TomEE?
Answer: Apache TomEE (pronounced “Tommy”) is the Java Enterprise Edition of Apache Tomcat (Tomcat + Java EE = TomEE) that combines several Java enterprise projects including Apache OpenEJB, Apache OpenWebBeans, Apache OpenJPA, Apache MyFaces and others.
34. Where do you configure a database connection pool in Tomcat server?
Answer: The Configure pool is in the context.xml inside the conf folder of tomcat.
35. Name some Tomcat features?
Answer: Tomcat 7.x implements the Servlet 3.0 and JSP 2.2 specifications. It requires Java version 1.6. Tomcat 8.x implements the Servlet 3.1 and JSP 2.4 Specifications. Tomcat 8.5.x is intended to replace 8.0.x and includes new features pulled forward from Tomcat 9.0.x. Tomcat 8.5 is designed to run on Java SE 7 and later.
36. What services are provided by Tomcat?
Answer: Tomcat server provides a host of services which are not provided by normal web servers like Apache Web Server. Those are:
Servlet Life cycle
Handle Web Requests
Database connection pooling
Clustering
High availability
37. What is the difference between Tomcat and an Application server?
Answer: Tomcat is a servlet container that supports servlets and JSP technology. An Application server supports many other Java EE technologies. company
38. What is a Tomcat High availability?
Answer: A high-availability feature has been added to facilitate the scheduling of system upgrades without affecting the live environment. This is done by dispatching live traffic requests to a temporary server on a different port while the main server is upgraded on the main port. It is very useful in handling user requests on high-traffic web applications.
39. What is the Connector?
Answer: A Connector represents an endpoint in which requests are received.
40. What is a servlet container?
Answer: The servlet container is the component of a web server that interacts with Java servlets. The servlet container is responsible for managing the lifecycle of servlets, mapping a URL to a particular servlet and ensuring that the URL requester has the correct access rights.
The servlet container handles requests to servlets, JavaServer Pages (JSP) files, and other types of files that include server-side code. The Web container creates servlet instances, loads and unloads servlets, creates and manages request and response objects, and performs other servlet-management tasks.
The servlet container implements the web component contract of the Java EE architecture, specifying a runtime environment for web components that includes security, concurrency, lifecycle management, transaction, deployment, and other services. Tomcat Training
Tomcat Web Server In Web Technology Definition
41. What is the servlet container life cycle?
Answer: 1 Servlet life cycle
1 Servlet life cycle
A servlet life cycle can be defined as the entire process from its creation until the destruction.
Life cycle steps followed by a servile
The servlet receives a request from a client through one of its connectors then is initialized by calling the init() method.
The servlet calls service() method to process a client’s request and send the response.
The servlet is terminated by calling the destroy() method.
The servlet is garbage collected by the garbage collector of the JVM.
42. What is a connector and why it is used in Tomcat?
Answer: The Apache Tomcat Connectors project is a part of the Tomcat project and provides web server plug-ins to connect web servers with Tomcat and other back-ends.
The supported web servers are:
The Apache HTTP Server with a plugin named mod_jk.
Microsoft IIS with a plugin named ISAPI redirector.
The iPlanet Web Server with a plugin named NSAPI redirector.
43. What is the server?
Answer: A Server element represents the entire Catalina servlet container. Therefore, it must be the single outermost element in the conf/server.xml configuration file. Its attributes represent the characteristics of the servlet container as a whole.
44. What is the server server.xml configuration file?
Answer: The server.xml file is Tomcat main configuration file, and it is responsible for specifying the Tomcat configuration on startup.
45. How to deploy War web applications in Tomcat?
Answer: You can drop the WAR file inside the web apps folder or use the Tomcat manager to deploy War files. ( tableau online training )
46. Can Tomcat use SSL?
Answer: Yes, you need to make additional configurations to make Tomcat use SSL. In resume, you need to do these tasks
Generate Keystore
Add a connector in server.xml
Restart Tomcat
47. What is virtual hosting?
Answer: This is a way of hosting more than one domain names on one server using a single IP address. This way, the single server can share its resources which may include memory, processor cycles among others to ensure its efficient use.
48. What is Document Root?
Answer: DocumentRoot directive is the configuration where you can specify the folder location from where the static files will be served. It’s also called as WebRoot.
49. What is a mod_evasive module?
Answer: mod_evasive is a third-party module that performs one simple task and performs it very well. It detects when your site is receiving a Denial of Service (DoS) attack and it prevents that attack from doing as much damage. mod_evasive detects when a single client is making multiple requests in a short period of time and denies further requests from that client. The period for which the ban is in place can be very short because it just gets renewed the next time a request is detected from that same host.
50. What are the log files generated by Apache?
Answer: There are two popular log files created;
access.log – all request details with the status code
error.log – capture all the errors within apache or connecting in the backend.
51. What tool do you use for log analysis?
Answer: You got to speak the truth but to give you an idea you can use GoAccess, SumoLogic or few mentioned here.
52. What is mod_vhost_alias?
Answer: It allows hosting multiple sites on the same server via simpler configurations.
53. what is a difference between Apache and Nginx web server?
Answer: Both are categorized as a Web Server and here are some of the main differences.
Nginx is an event-based web server where Apache is process based
Nginx is known for better performance than Apache
Apache supports a wide range of OS where Nginx doesn’t support OpenVMS and IBMi
Apache has a large number of modules integration with backend application server where Nginx is still catching up
Nginx is lightweight and capturing the market share rapidly. If you are new to Nginx, then you may be interested in checking out my articles on Nginx.
54. What is the difference between Worker and Prefork MPM?
Answer: Both MPMs, Worker and prefork has their own mechanism to work with Apache. It totally depends on you that in which mode you want to start your Apache.
Basic difference between Worker and MPM is in their process of spawning the child process. In the Prefork MPM, a master httpd process is started and this master process starts manages all other child processes to serve client requests. Whereas, In the worker MPM one httpd process is active, and it uses different threads to serve client requests.
Prefork MPM uses multiple child processes with one thread each, where worker MPM uses multiple child processes with many threads each.
Connection handling in the Prefork MPM, each process handles one connection at a time, whereas in the Worker MPM each thread handles one connection at a time.
Memory footprints Prefork MPM Large memory footprints, where Worker has smaller memory footprints.
55. What is the main configuration file of the Apache server?
Answer: The Apache Web Server is the most commonly used web server. Before going for any interview involving web servers, make sure to go through these apache interview questions. This way you get an idea of what Apache entails. You can share your thoughts in this article with regards to the apache interview questions and the way answers are provided. Feel free to suggest more issues and solutions for the same to help others learn more about the Apache webserver. ( hadoop training online )
56. What do you mean by a valid ServerName directive?
Answer: The DNS system is used to associate IP addresses with domain names. The value of ServerName is returned when the server generates a URL. If you are using a certain domain name, you must make sure that it is included in your DNS system and will be available to clients visiting your site.
What Is Tomcat Web Server
Note: Browse latest Apache Tomcat Interview Questions and Tomcat Tutorial Videos. Here you can check Tomcat Training details and Tomcat Training Videos for self learning. Contact +91 988 502 2027 for more information.
