We cannot troubleshoot any issue by just referring to the user comments or problem statement. In order to troubleshoot the issue, we have to narrow down the problem to its root level and fix the issue.
Many web administrators always ask this question; how do we know that the system has a particular problem?
The solution to these issues will be found, if you dig the problem in the correct path. Secondly, if you come across a number of problems in your career, then you can correlate them and solve the problem. If you ask me, practically it's impossible to teach troubleshooting, as it comes from your own experience and your interest to solve the problem. Here, we discuss one of the common problems, application slowness, that occurs in every environment and the web administrator has to face this problem in his/her career.
Let's take a real-time situation where users complain about the performance of the application. The application comprises of an enterprise setup, which is a combination of the Apache HTTP server as a frontend, Tomcat 7 is used as a servlet container, and the Oracle database running as a backend database server.
Issue:
Let's discuss one of the common issues of the middleware application, which make it very difficult for the administrator to solve. This issue is called slowness of application, where users complain that the application is running slow. It's a very critical problem from the administrator's point of view, as slowness can be caused by any component of the web application, such as the OS, DB, web server, network, and so on.
Until and unless we find out which particular component is causing the problem, the slowness will persist and from the user's point of view, the application will not run in a stable manner. The following figure shows the typical web infrastructure request flow for a web application:
Slowness in the application can be caused by any component, so it is best practice to start troubleshooting from the user end.
Perform the following steps to troubleshoot:
abc.com
, using the command ping
. If you get an appropriate response, it means the connectivity for the application server and user machine is working fine.ping abc.com
ping
response for abc.com
. There are some important points we have to keep in mind during ping status monitoring, which are mentioned as follows: 4
. If the count is less, it means that there is some issue within the network.Many external sites disable the ping
response for their nodes. This doesn't mean the system is down. In that case, try the telnet port, by using the command telnet URL port
.
The previous screenshot shows the ping
response for the server working appropriately. That means there are no issues from the user end in terms of the system and network.
Once we know that there are no issues at the user end, we will move to the next level in the application, that is web server. Now, we have to dig down in the server to check if there are any issues.
Web server issues are more often related to the load of the server, user threads, or mounting problems. Let us see how to solve the issue.
ps -aef |grep httpd
top|head
httpd.exe: Could not reliably determine the server's fully qualified domain name, using 10.0.0.3 for ServerName.
apache error_log
. The log in the previous screenshot shows that " the Apache HTTP server could not find a fully qualified domain". This means that in the httpd.conf
, we have missed defining the server name with a fully-qualified domain, for example, we have defined the localhost as the server name; instead of that, we have to define [email protected]
.Also, there are two commands which are useful for searching the error in the logs. They are as follows:
tail -f log file |grep ERROR
grep " 500 " access_log
df
command to check the mount space, where df
= disk free and switch -h
= human readable. The syntax to use the df
command is as follows and the output is shown in the following screenshot:df -h
If we don't find any error in the previously mentioned components, than we can conclude that there are no issues with the web server.
In Java-based applications, slowness is caused due to many issues. Some of them are due to the JVM memory, improper application deployment, incorrect DB configuration, and so on. Let's discuss some basic troubleshooting steps for Tomcat 7:
ps -ef |grep java
The following screenshot shows the output of the head
command on the Tomcat server:
top|head
head
command displays the content from the first line of a file or output. It is very frequently used with -n
switch where n=
the number of lines to display. By default, it displays 10 lines if -n
is not used. TOMCAT_HOME/logs
, and search for the exception in the log files, mainly in catalina.out, localhost.yyyy-mm-dd.log
using the following command:grep INFO catalina.out
As a web administrator, you don't have access to the database servers. But a web administrator can connect to the DB server externally, without logging into a physical machine, as the administrator has the connection string (credentials for accessing the database). For example, you can do the telnet on the port where the DB server is running, and check whether the services are running or not.
If the telnet is successful, then you can verify the following processes:
There are some chances where the JVM is over utilized in the application. To view the memory allocation for the JVM instance, you can use the command-line utility, jmap
. This command comes with JDK 1.6. It's a Java utility, which determines the entire memory allocation of the Tomcat instance.
[root@localhost logs]# jmap -heap "TOMCAT INSTANCE PID "
Let us discuss how the previous command performs. The jmap
command internally collects the JVM memory details, -heap
is the switch that tells jmap
to collect and display the heap memory footprint, TOMCAT INSTANCE PID
is the process ID of the Tomcat instance for which process jmap
has to fetch the memory details.
[root@localhost logs]# jmap -heap 10638
The following screenshot shows the output of the jmap
command for the previous process ID:
How to find the process ID
We can find the process ID using the following command:
ps -ef |grep "tomcat instance name " |awk -F" " '{print $2}'|head -1
This command can be described as, ps -ef |grep "tomcat instance name "
will find all the processes running for the Tomcat instance. awk -F" " '{print $2}'
awk prints the process ID of a particular process and head -1
will display the first process ID.
The jmap
command is present in JAVA_HOME/bin
and if you set the JAVA _HOME/bin
in the path, then you can execute the command from anywhere.
The previous utility gives the entire footprint of the JVM memory and its allocation for the Tomcat instance. The JVM memory comprises of the following components:
Out of memory issues such as perm generation and max heap are very commonly known issues in the production environment. Check the memory to see whether any of the previous components are utilizing more than 95 percent. If so, then we have to increase the respective parameter.
Now it comes to the place where we can determine which JVM component is creating the issue for the Tomcat instance. If the memory is working fine, then it is time to generate a thread dump to drill the application-level issue.
34.239.150.167