The best way to store page hits on a crowded site

I have a site with too much traffic and I want to add a hit counter. what's the best way to keep this? I have 2 options
1- create a database and store hits.
2- create local txt file and save hits.
the server is already loaded, so what would be better to avoid more pressure on the server?

+3


source to share


5 answers


I would not use a.

If the server is already under heavy load, it will be even worse if you add access to additional files with access (read / write)



I confirm @ Antonys answer. It will delegate work for statistics to clients, not the server.

+2


source


To avoid additional server load, use external services such as Google Analytics and Statcounter .



+5


source


If you don't want to use external services, a NoSQL database is your best bet.

+3


source


Alternative PHP Cache (APC) would be an option.

+3


source


This is another option for you https://www.kissmetrics.com/

+2


source







All Articles