Sinsing Analysis of pub/sub function in Redis

Source: Internet
Author: User

The Pub/sub function is also the Publish/subscribe function, which is the Publish subscription function. In an event-based system, PUB/SUB is a widely used communication model that uses events as a basic communication mechanism to provide loosely coupled interaction patterns required by large-scale systems: subscribers, such as the client, express an event or a class of events that it is interested in receiving in the form of an event subscription. Publishers, such as servers, can notify subscribers of events of interest to subscribers 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 moment, they do not have to participate in interaction.

(2) Space is not coupled, that is, publishers and subscribers do not need to know each other's location. When the publisher publishes time through the event Service, the Subscriber obtains the event indirectly through the event service. Publishers and Subscribers do not need to have a direct reference to each other, nor do they have to know how many subscribers or publishers are involved in the interaction.

(3) Synchronous non-coupling, publish/subscribe is asynchronous mode. Publishers can constantly generate events, and subscribers (through a callback) can asynchronously get notifications of events that generate them.

The Pub/sub functionality is divided into topics (topic-based), Content-based (content-based), type-based (type-based), in terms of subscription methods. It is a distributed interaction model that can be applied to a highly scalable and loosely coupled system. In the abstraction layer, its time non-coupling, spatial non-coupling and spatial non-coupling can allow the participant to operate independently of the other and have some extensibility. But at the time of implementation, scalability remains constrained by other causes.

Pub/sub generally applicable range:

(1) Flexible subscription requires complex filtering and routing algorithms

(2) High availability overhead (event listening, log retransmission)

(3) Network traffic consumption caused by message recognition

(4) Overhead of large subscriber data

The development and utilization of event-based PUB/SUB middleware can improve the efficiency of the system to some extent.


The implementation process in Redis:

(1) Subscribers subscribe to two topic, example:

Subscribe First Second

(2) Publisher post information, example:

Publish First Hello

Publish Second World

(3) Subscribers cancel a topic, rebate:

Unsubscribe first












Sinsing Analysis of pub/sub function in Redis

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.