Redis achieves clicks/views

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.