A keyword aggregation page (http://www.chinabyte.com/list/A/) has about 30 thousand keywords, including two pages: one is the keyword list page, the other is the keyword search result page, this is because the crawling frequency of the page search engine is high and the server is often overwhelmed. these keyword data, including the search result pages, are all cached by memcache for one week. A keyword aggregation page (http://www.chinabyte.com/list/A/) has about 30 thousand keywords, including two pages: one is the keyword list page, the other is the keyword search result page, this is because the crawling frequency of the page search engine is high and the server is often overwhelmed. these keyword data, including the search result pages, are all cached by memcache for one week.
The reason for exceptions on the server is suspected to be that the expiration time of the keyword data cache is relatively concentrated. as a result, when crawlers crawl data, the database is frequently read for a short period of time.
There are two solutions to solve the problem of server exceptions caused by cache invalidation time set:
1. set the random cache time
$ Rand_minute = mt_rand (30, 60); $ rand_hour = mt_rand (1, 24); $ rand_day = mt_rand (3, 7 ); $ lifetime = 60 * $ rand_minute * $ rand_hour * $ rand_day;
In this way, after a period of time, you can average the cache time to avoid being too concentrated.
2. Solution 1 + file cache
This is the solution. I think it is a bit unreliable to set this random cache time. I wonder if there are any other good optimization solutions?