Redis Business Description for clicks
CMS article page views (titles loaded), clicks statistics (number of clicked articles)
The following are my statistics services, mainly including redis, nodejs, and redis applications with clickthrough cache to reduce database pressure. nodejs uses asynchronous non-blocking mechanism to differentiate CMS business logic from statistics functions.
Input parameter cateid (Category id), articleid (Article id), sourceip (Request source ip)
I. storage policy
1. record by time granularity
Redis is stored in hash
HASH
KEY VALUE
Time his
0 0
1 10
Cateid_arvicleid_t ..
..
..
23 230
2. Statistics by source
Redis is also stored in hash, with the source differentiated to the province
HASH
KEY VALUE
Provinc his
HEBEI 0
HENAN 10
Cateid_arvicleid_p ..
..
..
SHANDONG 230
II. data synchronization mechanism
Now, I only want to synchronize redis data to the database through scheduled tasks in linux.
III. cache data expiration mechanism
Solution 1: automatic expiration time through redis
This scheme needs to be executed later in the data synchronization mechanism to ensure that the expired cache is cleared after the data is written into the database. now we want to execute the synchronization at every day, so the redis Cache needs to be set more than 24 hours.
Solution 2 clear both data through the database synchronization mechanism
This solution combines synchronization and cache cleanup, and discards the redis expiration mechanism.
Younger brother, I hope you will give me some suggestions on improper and optimization.
On the basis of 10000 online users and 1000 concurrency, the above redis storage mechanism is feasible for memory pressure
Is there a better solution for the synchronization mechanism and cache expiration mechanism?
Thank you here
Reply to discussion (solution)
It is best to set the KEY to 2014_10_30. cateid_arvicleid_t format
Select Solution 2. use the database synchronization mechanism to clear the 2 ~ Synchronization because Script 1. synchronization script may fail 2. when the data volume is large, the data at yesterday will be overwritten by today.
Redis, which claims to have 10 million requests per second, is not afraid of 1000 concurrent requests.
It is best to set the KEY to 2014_10_30. cateid_arvicleid_t format
Select Solution 2. use the database synchronization mechanism to clear the 2 ~ Synchronization because Script 1. synchronization script may fail 2. when the data volume is large, the data at yesterday will be overwritten by today.
Redis, which claims to have 10 million requests per second, is not afraid of 1000 concurrent requests.
Thank you very much.
Indeed, because of the synchronization mechanism and cache expiration, the key value must be differentiated by the date to prevent overwriting.
In your analysis, solution 2 is more feasible.