If you can successfully ping during a period when you can not process http or https request, this means the DNS and router is working and this is most likely a server issue.
Quick Check: Out of memory?
Use SSH (secure shell) and log in with a sudo
user account. This could be root
but root may have been disabled for security purposes, so use an account that has full permissions. Once logged into server. Type the following (note: you should do this when you are not experiencing an outage to see how it compares to when an outage does occur):
free -m
the results show how much memory is used. If the server is out of memory, the top
command
will display software running and amount of cpu and memory usage. Use Q
or Control + C
to exit the command. Solution, restart services as gracefully as possible and keep in mind you probably will need to add more RAM or resolve a software issue.
If you have a linux dedicated server, check the Apache log files
. You can do this because you have a dedicated server or VPS. Shared hosting accounts typically do not have this ability. To view the error logs, use SSH (secure shell) as a sudo and type:
sudo tail -100 /etc/httpd/logs/error_log
If using Ubuntu or Debian:
sudo tail -100 /var/log/apache2/error.log
The tail -100
stands for the last 100 records in the log. Insert your own value. If you would like to search for a particular term you could use:
sudo grep -i invalid /etc/httpd/logs/error_log
if using Ubuntu or Debian:
sudo grep -i invalid /var/log/apache2/error.log
Here, grep
is used for searching an expression, -i
makes the search case-insensitive, and invalid
is the search term. More detail of apache logs.
Reviewing the logs could reveal attempted server attacks, such as Denial of Service (DoS). You can research on Intrusion Detection Systems (IDS) or Intrusion Prevention System (IPS).
Your host company may not be looking in detail to your server. Ask them to review the logs as well for a second opinion.
You may have an issue with not enough system resources, such as RAM, to handle request at peek hours of usage. You can look into how many concurrent MySQL connections are occurring at times of outages. If your traffic numbers are in the thousands, your MySQL connections may be set too low. To view your max MySQL connections, you can use the following in a MySQL command line tool or something like phpMyAdmin:
show variables like "max_connections";
This will return a max connections value: probably 100, with an average of 20 concurrent connections assumed. You can increase it by:
set global max_connections = 200;
This command will immediately take effect, but will return to default upon a MySQL reboot. Change the value and see how the server handles your traffic. If you notice less outages, you can set the value permanently under mysqld
in the file usually found under /etc/my.cnf
.
Based on your information provided it is hard to say exactly what could be an issue. Your web application or site may not be properly closing open connections or has slow queries. You can look to enable MySQL Query Cache. This doesn't add much overhead but can help performance. Here are the documents on MySQL memory use. Enable your MySQL logs. There are several different log types for MySQL so enable the one pertaining to what you think is causing problems.
Hope this helps and comment with any questions.