Java+redis for high-performance news click-to-volume updates
1, Redis Brief introduction. It is excellent for high-performance data access.
2, Example: News click Volume.
1) Every time we refresh, we don't have to update the data in the database immediately.
2) Key-value storage can be done in Redis
3) Set a threshold value to update to the database when the user refreshes to a certain number
3. This class is deployed under Windows.
4. The Linux deployment will also cover the following
Course Address: http://edu.51cto.com/index.php?do=lesson&id=42104
------------------------------------------------------------------------------------------
Redis achieves click-through volume
Business Description: CMS article view volume (title is loaded), click Statistics (the amount of the article was clicked Open)
Main technology: Redis,nodejs,redis application of click Cache to reduce database pressure, Nodejs realize CMS business logic and statistical function differentiation by asynchronous non-blocking mechanism
Incoming parameters: Cateid (category ID), ArticleID (article ID), SOURCEIP (Request source IP)
First, the storage policy
1, according to the time granularity of records
Redis is stored as hash
HASH KEY VALUE
Time his
0 0
1 10
cateid_arvicleid_t. .
. .
. .
23 230
2, by Source statistics
Redis is also stored in hash, and the source is divided into provinces
HASH KEY VALUE
Provinc his
Hebei 0
Henan 10
Cateid_arvicleid_p. .
. .
. .
Shandong 230
Second, the data synchronization mechanism
Now only the time to synchronize Redis data to the database with Linux scheduled tasks
Third, cache data expiration mechanism
Scenario one through Redis auto-expiration Time
This scenario needs to be performed later in the data synchronization mechanism, to ensure that the data is in storage, to clean out the expired cache, and now consider that synchronization is performed 0 o'clock daily, then the Redis cache needs to be set up for more than 24 hours
Scenario two clears simultaneously through the database synchronization mechanism
The scenario is to put the synchronization and cleanup caches together and discard the Redis expiration mechanism.
Synchronize at the wee points of the morning because of script 1. Synchronization scripts may fail 2. When the data is large, yesterday's 0 o'clock data will be covered by 0 o'clock today.
A redis that claims 1 seconds of 10W is not afraid of the concurrency of 1000
Redis achieves clicks/views