简体   繁体   中英

Database or file record keeping - php

I am creating a record system for my site which will track users and how they interact with my site's pages. This system will record button clicks, page view times, and the method used to navigate away from a page (among other things.) I an considering one of two options:

  1. create a log file and append a string to it for each action.
  2. create a database table and save entries based on user interaction.

Although I am sure that both methods could easily fill my needs, which would be better in the long run. Other considerations:

  1. General page viewing will never cause this data to be read (only added to it.)
  2. Old Data should be archived, but still accessible.
  3. Data will be viewed and searched via web app

As with most performance questions, the answer is 'It depends.'

I would expect it depends on the file system, media type, and operating system of your server.

I don't believe I've ever experienced performance differences INSERTing data into a large, or a small MySQL database. The performance differences manifest when you retrieve that data. The database will almost always outperform queries to files, especially when you want complex or statistical data.

If you are only concerned with the speed of inserting/appending data, and expect a large amount of traffic, build a mock environment and benchmark each approach. If you want to have any amount of speed retrieving that data in a structured way, go with the database.

如果您想提高性能,则应检查服务器日志,而不是尝试构建日志系统...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM