SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2002
    Location
    Trondheim, Norway
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Best way of counting hits

    I'm wondering what the best way to count hits on a website is.
    Up until now I've simply used a update query on a mysql db to count hits, but I'm feeling this might be the wrong approach.

    I'm currenty developing an internet portal witch is estemated to generate about 100 000 hits\month within a short period of time.
    I'm using php to generate every html page on the site so that there dosen't have to be several request to the database for each page request.

    So there's going to be quite a few html pages, what would be the best way of counting hits on each and every one of these pages?


    I'm thankful for all input regarding counting hits and the way of generating the html pages (is this a good approach?)

  2. #2
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Personally i'd use something like AWStats for this or some other log file analyser. It's not really PHP's job to count hits and it can get icky counting unique hits etc and the counting of hits will only slow your pages down. Course, this presumes you have access to the log files

  3. #3
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you want to count the clicks on every single generated page, or every click is going to be a counter iterator?

    If the latest, just use a single simple text file incrementing on each new page generation

  4. #4
    SitePoint Enthusiast
    Join Date
    Nov 2002
    Location
    Trondheim, Norway
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is opening, edeting and closing a txt file mutch more efficient then to do a update mysql query?

  5. #5
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know if it is more efficient, but I've never had a problem with it. It's been reliable, and speedy.

  6. #6
    SitePoint Guru defiance's Avatar
    Join Date
    Oct 2004
    Location
    United states
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i would suggest you using txt file rather than database.

    much more faster ( i think, given my knowlegde)

  7. #7
    SitePoint Enthusiast Bobbi's Avatar
    Join Date
    Mar 2005
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Keeping in mind that neither opening a textfile, nor selecting a single, updated SQL field is a really intensive task, I think you should really put your focus on other things for optimizing
    You'll have serious issues even getting a time for these tasks (try microtime ) so it doesn't really matter how you do it.

    Bobbi

  8. #8
    Fully Sweet Car noddy's Avatar
    Join Date
    Aug 2002
    Location
    Perth, Western Australia
    Posts
    759
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Personally I would use a database. Easier to query and compare results against one another I feel.


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
  •