1. Why do I need Message Queuing?
When there are inconsistencies in the speed or stability of "production" and "consumption" in the system, Message Queuing is required as an abstraction layer to bridge the differences between the two sides.
For example: The business system triggers the SMS sending request, but the text message sending module speed can not keep up, need to be too late to deal with the message of the temporary storage, buffering pressure.
Another example: adjust the remote system under the higher order cost, and because of network factors, unstable, save a batch sent together.
Another chestnut, interactive module 5:00 to 24:00 and e-commerce system Unicom, and internal ERP disconnected. 1:00 to 4:00 and ERP Unicom, and e-commerce system disconnected.
For example, the waiter orders fast, cooks slow cooking.
For example, there are more people working in banks and fewer windows providing services.
Get in line, boy.
2. What are the benefits of using Message Queuing? 2.1. Improve system response speed
Using Message Queuing, the producer side, throwing the message into the queue, can return immediately and respond to the user. No waiting for the results to be processed.
The results can be used by the user to fetch them later, such as the hospital to take the test list. It is also possible for producers to subscribe (for example, to leave a mobile phone number or to allow a producer to implement a listener interface, join a listening queue) and have a result notification. Get agreed to place the results somewhere without notice.
2.2. Improve system stability
Consider e-commerce system orders, send data to the production system situation.
The network between the e-commerce system and the production system may be dropped, and the production system may suspend service for reasons such as maintenance.
If you do not use Message Queuing, e-commerce system data published, customers can not order, affecting business development.
It should not be so tightly coupled between the two systems. Should be decoupled through Message Queuing. At the same time make the system more robust and stable.
3, why need distributed? 3.1. Multi-system collaboration requires distributed
Data in Message Queuing requires sharing data across multiple systems to be valuable.
Therefore, it is necessary to provide distributed communication mechanism and coordination mechanism.
3.2. A single-system deployment environment requires a distributed
Within a single system, for better performance, in order to avoid a single point of failure, more than a clustered environment.
In a clustered environment, applications run in multiple JVMs on multiple servers, and data is stored on various types of databases or on multiple nodes of non-databases.
In order to meet the needs of multi-node collaboration, a distributed solution is required.
4. What problems need to be solved in distributed Environment 4.1, concurrency problem
Good concurrency control is required. Ensure "thread safety."
Do not appear an order is shipped two times. Do not appear under customer a orders, delivery sent to customer B and other situations.
4.2. Simple and unified operation mechanism
You need to define a simple, semantically clear, business-agnostic, properly secured, and unified approach to access.
4.3. Fault tolerance
Control the single point of failure to ensure data security.
4.4. Can be scaled horizontally
Easy to expand.
5, how to achieve?
Mature Message Queuing middleware products are too many, the family is not enough to download.
Mature products are validated, interface specification, scalability is strong.
Combining business environment factors, organizational process heritage, implementation operations and maintenance considerations, technical route considerations, developers and other reasons for the comprehensive consideration, based on Redis to do one is the most feasible choice.
How to do it?
Please listen to tell.
Implementing distributed Message Queuing based on Redis (1)