Joke Collection Website - Blessing messages - Construction of short message communication service

Construction of short message communication service

With the continuous development of the Internet, there are more and more ways and channels of information transmission between users. Today, we will take a look at the main components of the construction of SMS communication service introduced by Jade Bird of Changping Peking University. Non-functional requirements mainly include the following points: 1. Stable delivery guarantee:

It is divided into two parts, one is the stability of the service itself, and the other is the stability of the SMS service provider.

The stability of the service itself needs to be realized by itself, and some existing tools of the micro-service platform can guarantee it, so we will not expand it here. The other one needs external guarantee, and the one that needs external guarantee is always fragile, so it is necessary to use not only one service provider, but also multiple ones.

Second, it is convenient to expand:

Next, it may be necessary to change service providers, and it is necessary to ensure that ready-made service providers are easily available.

Third, asset protection:

A difference between SMS and email, WeChat notification, etc. That is, the cost is relatively high. The price of a message is about 3 cents. Long short messages will be split into multiple messages, and if they are not protected, it will easily cause a lot of financial losses.

Fourth, technology choice.

With the above requirements, what technology to choose. Companies can use basic web services. For storage, because it involves sending information and reports, the volume may be relatively large (actually, it's okay after going online, less than10 million records in 3 months), and statistics may be based on some sent contents. Using MySQL or something like that may not be reliable, so choose ES. In order to be safe, it is necessary to limit the number and frequency of mobile phone numbers sent every day, and redis can easily solve it. 5. Access to multiple service providers requires access from multiple service providers, and one service provider may provide multiple SMS functions at the same time. At the same time, the same SMS function needs to call all service providers in turn, and try again after one fails. It also needs to support flexible configuration, which can disable some service providers or easily add new ones. 6. Set the sending limit. Counting the number of sending mobile phone numbers and ip, simply using the incr of reids and the key related to timestamp can be completed, so I don't need to repeat it here. If the sending restriction is aimed at different functions, because the usage of different functions is completely different, and it also has the function of isolation. Second, the sending restrictions need to be layered. After reaching the global limit, it should not be sent out even if it does not exceed the limit of a single mobile phone.

Global time of the function->; Single access application limit (times/whitelist/switch)->; Single phone /ip limit (times/whitelist/switch)->; The frequency of risk control services (switching) should be adjusted according to statistical data and business changes. Eight. Performance.

This service is obviously IO-intensive, so there is no calculation. Mainly call various external services and wait for IO to return. Therefore, these thread pools for issuing requests can be configured slightly larger, mainly HTTP connection pools. However, the connection timeout and read timeout are not suitable for setting too large.