0

I have a site that gets around 1000 page views a minute when traffic is high and the page has a js code which stores the browser details of the visitor into mysql using a php file for connecting to db. For eg browser.js calls storebrowserdata.php Is there a way for me to cache the php file and js file without affecting my stats data that is stored in the db?? When the traffic is high during the day the site slows down and cpu utilization also goes up.

3
  • why you don't use get_browser function? Commented Sep 11, 2011 at 11:04
  • How do you want to cache something that by definition has to be run for every visitor? ... As @Death says, storing browser info on server side would be much preferable (if it's just browser info you're storing and not stuff like screen size, which can't be detected using a server side language) Commented Sep 11, 2011 at 11:08
  • I store the browser size and run my own query on the data that is got so i cant use google analytics. Also i use the js on multiple sites Commented Sep 12, 2011 at 3:55

3 Answers 3

1

PHP is interpreted. If you want to grab each visitor's browser/user agent information on each page load then you kinda need to run that script each time; you can't cache it.

If this functionality is slowing down your site, either use an alternative solution like Google Analytics, or investigate a NoSQL solution like Mongo DB that offers atomic updates and in general runs faster than MySQL.

Sign up to request clarification or add additional context in comments.

Comments

0

you can cache js file as well as php one.
but it will do nothing good for you.

it's database update that most likely slows down your site.

what certain operation consumes most CPU? Did you profile your application? Is it the only page using PHP mysql on your site?

Comments

0

If you need to control the flow of process executed, you can use a Queue and control the rate of execution.

About this system, this is a great open source project: http://www.rabbitmq.com/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.