Search code examples
phpmysqllaravellogginguser-activity

Laravel Best Practice for save user activity log in database ( with considering database Performance)


I have a website (Laravel + Mysql on top of 'dedicated server') where I save all the pages that every user sees for reporting. My site is visited 10,000 times a day and this statistic makes the database size bigger after a few months. now 'visits' table occupied 85% of whole database!

Is there a way to do this that is the best way possible?


Solution

  • I have not encountered this problem before, but I think its better to take the logging with this much of heavy load out of primary database, you can move it to a file system or logging services (read this).

    Or you can have job (background process) to remove the logs that you don't need Like logs from a month ago, this will help db a little bit.
    Read some best practices