Log to file via PHP or log to MySQL database - which is quicker?

前端 未结 15 1282
故里飘歌
故里飘歌 2021-02-03 11:07

I have a database driven website serving about 50,000 pages.

I want to track each webpage/record hit. I will do this by creating logs, and then batch processing the logs

15条回答
  •  遇见更好的自我
    2021-02-03 11:24

    1. Write to file. Rotate logs.

    2. Batch load the file to the database on a scheduled basis.

    There are many, many reasons to choose this architecture -- ease of scaling (write to many logs, load them to db), lack of reliance on a SPOF in the database (if something goes wrong, you just accumulate logs for a while), ability to do cleaning and non-trivial parsing at load-time without burdening your production servers, and more.

提交回复
热议问题