Using the Redis list data structure as a lightweight message queue, the small system is really small and beautiful, controllable ability.
Of course, compared with Kafka and RABBITMQ it has many shortcomings, in the service production and consumption, but also need to add some logic to deal with.
Write yourself a bit of Golang code and stress test the performance of the Redis list.
Machine configuration: Dual Core, 4G
Test data: 100w
Stress test Source (GitHub)
producers , producing up to 13,817 data per second, averaging data.
Begin time:2018-07-29 14:03:55.606
End time:2018-07-29 14:05:07.976
Produce message:1000000
avg:13817.860879118389
Load
Code Snippets
consumers , consumption of data, the average can read 9,433 data per second about.
Begin time:2018-07-29 14:46:11.166
End time:2018-07-29 14:47:58.038
Custom message:1000000
avg:9433
Load code Fragment
Summarize:
The above production and consumption testing are independent testing, production data and consumption data, can reach about 1w concurrency, if the producers and consumers at the same time, the concurrency of their respective capacity will be reduced by about 20%.
True, the general small business system, the real core business data (non-water, behavioral records and other log-type data), write concurrency can reach 1 W is already very strong, some financial companies, millions of registered users (not active enough), peak write concurrency is only thousands of. The general system should be read more than write operation, of course, the specific situation should be specific analysis ^_^.