Question

My server's load average shoots up to 150 (and the server is actually quite powerful 8cpus too much RAM etc), and the cause of that is MySQL taking all of my CPUs 700% !

I'm aware of Apache/MySQL tuning to meet better performance, I've done some, it worked a little bit but nowhere near the results I need.

All my problems are coming from this scenario: when website file based cache invalidates, PHP scripts run to remake those cached areas, generating MySQL queries (quite heavy queries, did some optimization on them too but they're still taxing on MySQL). That's quite normal, the problem is when a 100 people hit the website at that precise time when cache is invalid so they generate the same query 100 times - which makes MySQL sink all the way down with my server.

Are there any MySQL solutions to prevent the duplication of the same query? or is there any other technique to fix that special scenario?

Was it helpful?

Solution

I my opinion you would need another marker if rebuilding the cache is already in process, so that only one update query is done and until finished the old cache is used.

That would trigger the expensive query's just once.

For a better answer please explain how you invalidate your cache.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top