Popular Searches

How to See How Many Hits Your Server is Handling

Shutterstock/Andrey VP

The amount of traffic your server is receiving is an important metric for any sysadmin to watch. There are tools that show you easy to read graphs compiled using your web server’s access log, which make this process simple.

Use Your Log Files

Every time someone accesses your web server, a new line entry in your web server’s access log is created. Usually, the IP address of the client and the request they made is logged, as well as the response code, date and time it was accessed, and other information about the request.

Combing through the log files manually would be a pain, but there is software that can use your log files to monitor the health of your server in real-time. GoAccess is a popular open-source tool for this use case. It can run in a terminal and displays useful statistics based on your log entries. It can track total visits per day, and which pages are getting the most traffic.

GoAccess also provides a web interface, if you’d rather access it that way. This interface provides much more detailed information, as well as real-time graphs tracking every single visit. Visitors with the same IP, date, and agent can be grouped into unique visitors.

GoAccess is entirely free and open source. It’s intended to be used for a single web server; if you have multiple web servers, you may want to consider a log management tool, otherwise you’ll have multiple instances of GoAccess running on each server.


Alternatively, you can use a command like apachetop, or Nginx’s status module if you just want to know how much traffic you’re getting. If you’re worried about the CPU or memory usage of your web servers, you can monitor that with Monit, another open source tool.

Installing GoAccess

You can install GoAccess from your distro’s package manager. For Debian based systems like Ubuntu, that would be:

apt-get install goaccess

You can also download and compile from source if you’d like.

Next, you’ll want to locate your web server’s primary access log. This is usually in /var/log/. For Apache, it should be /var/log/apache2/access.log, and for Nginx it should be /var/log/nginx/access.log. You can use tail to preview the ends of these log files.

Then, you’ll want to run GoAccess and pass it the location of the log file:

goaccess /var/log/nginx/access.log

You’ll be prompted to select a log file format; “Common Log Format” should work for Apache and Nginx.


Then, you’ll be able to view your access statistics from the command line.

If you’d like to make use of the real-time web interface, you can run that using the following command:

goaccess /var/log/nginx/access.log -o /var/www/html/report.html --log-format=COMMON --real-time-html

This will output an HTML page and run a WebSocket server to receive updates from. You may want to put this page behind basic auth, but it will be accessible from anywhere by your webserver if you put it in your document root (usually /var/www/html/).

If You Want More Data, Install an Analytics Suite

Log files are great, but they can’t tell you everything. They’re best used when you need accurate, real-time reports on the raw traffic coming in and going out. If you have a second to spare for more data, you can make use of an analytics suite.

You’ll likely want to install Google Analytics regardless, as it’s entirely free to use. You simply include the <script> tag in your site’s header, and every visit to your site will report back to Google. It provides simple pageview, bounce rate, and session tracking, as well as demographic information and detailed summaries about how users go about using your site.

Google Analytics also supports basic A/B testing, which can be used to improve the design of your website and help you achieve your goals more often.

Anthony Heddings Anthony Heddings
Anthony Heddings is the resident cloud engineer for LifeSavvy Media, a technical writer, programmer, and an expert at Amazon's AWS platform. He's written hundreds of articles for How-To Geek and CloudSavvy IT that have been read millions of times. Read Full Bio »

The above article may contain affiliate links, which help support CloudSavvy IT.