caching php and javascript file
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?? Wh开发者_如何学运维en the traffic is high during the day the site slows down and cpu utilization also goes up.
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.
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?
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/
精彩评论