Analysis of pub/sub function in Redis, Xinxing redis

Source: Internet
Author: User

Analysis of pub/sub function in Redis, Xinxing redis

The pub/sub function is the publish/subscribe function, that is, the publish and subscribe function. In an event-based system, pub/sub is a widely used communication model. It uses events as the basic communication mechanism to provide a loosely coupled interaction mode required by large-scale systems: A subscriber, for example, a client subscribes to an event to express an event or an event that it is interested in receiving. A publisher, for example, a server, can notify relevant subscriber of the event of interest to the subscriber at any time.



The pub/sub function can have three non-coupling:

(1) Time is not coupled, that is, publishers and subscribers do not have to be online at the same time, and they do not have to participate in interaction at the same time.

(2) The space is not coupled, that is, the publisher and subscriber do not have to know each other's location. The publisher obtains the event indirectly by means of the Event Service release time. The publisher and the subscriber do not need to have a reference directly to the other party, nor do they need to know how many subscriber or the publisher participates in the interaction.

(3) synchronization is not coupled, and publishing/subscription is an asynchronous mode. The publisher can continuously generate events, while the subscriber (through a callback) can asynchronously receive notifications of events.

The pub/sub function can be divided into topic-based, content-based, and type-based on the subscription method. It is a distributed interaction model suitable for highly scalable and loosely coupled systems. In the abstraction layer, the time-not-coupling, space-not-coupling, and space-not-coupling allow the participants to operate independently without relying on the other, with certain scalability. But in implementation, scalability is still restrained by other reasons.

Pub/sub:

(1) Flexible subscription requires complex filtering and Routing Algorithms

(2) high availability (event listening and log retransmission)

(3) network traffic consumption caused by message Recognition

(4) system overhead caused by massive subscriber data

The development and utilization of event-based pub/sub middleware can improve the system efficiency to a certain extent.


Implementation process in Redis:

(1) Subscriber subscribes to two topics. Example:

Subscribe first second

(2) publisher publishing information, for example:

Publish first hello

Publish second world

(3) The Subscriber cancels a topic and returns the following benefits:

Unsubscribe first












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.