Large complicated - Message Queue

message queue:

Message Queue Middleware is a distributed system, an important component, mainly to solve application coupled, asynchronous messaging, traffic clipping and other issues.
High performance, high availability, scalable architecture and eventual consistency. Large-scale distributed systems is essential middleware.

Usage scenarios
asynchronous processing:

Scene Description: After the user registration is successful, sending registered mail and then send the registration SMS.
Serial: After successful registration information into the database, send a message to the user, and then send the registration message, the results returned to the client
in parallel: the registration information into the database after successfully while sending registered mail, send a registration SMS, after more than three tasks completed, returned to the client.
Message Queue: After successful registration information into the database, registration information into the message queue, send messages and read text messages consumers asynchronous message queue, the message queue is about to write the results back to the client.

Write pictures described here

Application of Decoupling

Scene Description: After the user orders, the order system needs to notify the inventory system.
The traditional way: Order Inventory System system call interface

Message Queuing:
Order System: After a single user, the order processing system to complete persistence, writes messages to the message queue, the user returns the successful single order.

Inventory System:
Feed single messages, using the pull / push manner, acquires the order information, inventory information system according to the orders, inventory operations.
Write pictures described here

Traffic clipping

Scene Description: spike activity, usually because of too much traffic, leading to traffic surge.
Traditional way: the server receives a large number of sudden orders from the front end of a request
message queue: the front end of the application message queue was added

1, the user's request, the server accepts, first written message queue. Add message queue length exceeds the number of rally, the user request or discarded directly jump to the error page.
2, spike service according to the request information message queue, do the subsequent processing.
Write pictures described here

Write pictures described here

Write pictures described here

Write pictures described here

Write pictures described here

Published 65 original articles · won praise 3 · views 50000 +

Guess you like

Origin blog.csdn.net/web_orange/article/details/78583155