SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Oct 2011
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Low-resource Hit Counter For Busy Site?

    Hi,

    I have a site which is getting over 250,000 hits a day and I'm wondering what the least resource-intensive method would be to count hits per day.

    I originally had a script that wrote a timestamp, visitor IP and referring url to a text file using fwrite().

    My hosting company has since told me that the server was going nuts when the traffic started rising so I had to disable the script.

    I'd like a script that updates a single figure and starts a new line every 24 hours if possible, but I'm unsure of the most economical PHP method for this.

    I'd like to record it in a text file.

    Can anyone offer any wisdom?

    Also, would javascript be more efficient?

    Cheers.
    Lee.

  2. #2
    SitePoint Enthusiast
    Join Date
    Apr 2012
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh my god. frwite? lol. Just insert it into a MySQL table lol. Use InnoDB as the engine table, otherwise MyISAM will lock the table until the last insert is done. I'd much rather have all the hit data like IP and page, but you could just SELECT and UPDATE it to the total. An insert would be faster though.

  3. #3
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    OR ... just look at the site stats (such as AWStats) that your hosting provider offers (e.g. via Cpanel or equivalent)?
    Ian Anderson
    www.siteguru.co.uk


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •