I am 3Y, a markdown programmer with one year CRUD experience and ten years’ experience 👨🏻💻 known as a quality octuan player all the year round

The first channel that the Austin project implemented: : started with SMS

01. SMS introduction

At the time of the project introduction, the core functionality of the Austin project was defined: sending messages

In my opinion, SMS is the most important message type in the whole message push platform (after all, it is associated with many important business scenes). Think about the scenes in our daily use of APP:

  • Verification code: login, registration, payment and other important scenarios
  • Notification: users order information, important information to inform users, important information to inform merchants and other scenarios
  • Marketing: The operation will send marketing messages within a specific time, which will affect the completion of KPI indicators of the business (but this is relatively less important).

(Imagine if the system was down for 10 minutes.)

In this article, I will let you know that sending a message is not so simple and easy to do well, and why I need to introduce so many middleware when I introduce the Austin project.

(It all started with a text)

02. Sending SMS Messages Preparations are required

It has been several days since the last system architecture drawing, so let’s review the whole process of our Austin system

Because it is a preliminary implementation, so I first open an interface to call the Austin-handler module directly, as long as the austin-handler module under the implementation of sending SMS logic is good.

We want to send SMS, generally direct access to SMS channel business. As I understand it, texting works like this:

Just a few days ago in the group, there is a brother is in the company to do the relevant business of the channel business. He said that the interface has 20W QPS concurrency (I was doing various middleware optimization to avoid message accumulation), he didn’t know that sending a short message would go through so much process until he went in (LET me copy his exact words).

Now I know that a text message sent to our mobile phone has gone through an unknown number of procedures, including blacklist check, risk control check, keyword check, unsubscribe check, template check, customer account check, routing gateway check, channel check, status report check, operator check…

Generally, we need to evaluate whether to use a certain SMS channel provider to send, considering two points: cost and success rate. Here should be relatively easy to understand, there are many SMS channels, they all need to make money, we need to save money as the access side (that naturally has price differences). If a channel business and cheap send success rate and high, that of course with him as the main channel ah!

This time, I choose Tencent Cloud as the channel provider for sending SMS messages under the Austin project.

The reason I chose this time was simple: after I entered the SMS product, he gave me 100 free SMS experience cards. I can’t be the son of Destiny.

I found that there are a lot of small partners following my steps in doing, I certainly can not put their SMS account and password directly open to everyone experience. So you can try it on your own account when you’re interested.

Please **@ Tencent cloud to lay down advertising fees for me. @Alicloud seems to have it? (but the entrance is too hard to find, just) @Huawei cloud ** I have not logged in to experience, wait for me!

To send an SMS or access to an SMS channel, there are two essential points: SMS template and SMS signature. Look not to understand? That’s okay, I’ll take a specific test text message as an example:

SMS signatures let users know who might be sending the message, and SMS templates can greatly reduce the probability of sending spam messages.

Some people may ask: that I every send a message, all need to have a corresponding template, that I maintain not very troublesome? This is a push platform after all! Every time a business needs to send a new copy, do we have to go to the corresponding channel provider background to apply for a template?

Originally I thought this is normal, did not think, if you are the company, but also can talk about (🐶 general people I do not tell him). So, there might be a generic SMS template.

However, the SMS channel will still check the logic (it will still check the logic, and you will lose more than you gain if you send your account to stream limiting and set up a sampling manual to verify copywriting).

03. Function realization

There are two possible options for calling third-party apis: HTTP calls and embedded SDKS (if the platform has one).

I used to make direct HTTP calls so that my code didn’t have to build in someone else’s SDK (which means introducing other dependencies). So I started with the access documents provided by him directly and tried to use HTTP for access.

Well, it took me more than two days to plug in. I can’t stop. If it goes on like this, people will come to my house and knock on my door.

Tencent cloud interface with HTTP check also wife too complex! It turns out his note wasn’t a bluff:

I had been working on it for two nights and was so frustrated that I had to compromise with the SDK they provided, plus the auto-generated code, and Gaga did it pretty quickly (I wonder if any warriors have ever accessed their interface over HTTP as per the latest API documentation).

I won’t post the specific code, as usual you can find the Gitee link at the end of the article (read the original text) 🔗.

As long as you change your account information and call the interface in the configuration file, you can receive your own SMS. (The question should not be big, if you have any questions, just ask in the group)

Why is Austin a messaging platform

Sending SMS messages is simple (judging by the length of the article), and sending messages from other channels is simple as well. In essence, this is to connect to the API call send interface for sending.

As a general project, there is no follow-up after sending a message, but as a “platform”, this is not enough.

4.1 What Can I Do If the User fails to Receive the MESSAGE after invoking the SMS Sending Interface?

We only called the interface that sent the SMS, and did not record the return information of the interface (so there was no certificate to send). When others came to us, we did not do anything (we did not record anything, nothing was known).

Solution: We need to store the records sent to store, but also need to have an interface to pull back SMS receipt and store, and in the push background to provide relevant pages for quick query.

4.2 How to deal with the failure of a SMS channel provider?

Don’t think that we rely on ali Cloud, Tencent cloud or Huawei cloud such big companies, their products are not foolproof, it is very normal to fail. So if we only rely on one SMS channel and it dies, does that mean we die?

Solution: SMS needs to be connected to multiple channel providers. If the interface fails to be invoked, other channel providers need to be continued to be invoked. Dynamic distribution of channel providers’ traffic is supported (in case of early warning, channel providers can be directly switched)

4.3 How much did SMS cost this month? How do I know?

The SMS background has corresponding statistics, but if we have a large amount, we need to “check accounts”, with our sending records and receipt statistics and SMS background statistics.

After all, it’s money. You can’t trust them all. I once encountered a big discrepancy between the bill of the other party and our own statistics, and later investigation found that there were problems in their statistics.

Solution: Import SMS sending and receipt data to Hive and run the Hive script once a month to check accounts

4.4 Is there a large volume of SMS calls now?

Third-party interfaces generally have limited flow. For example, there is a limit of 3000QPS for sending interfaces on Tencent Cloud official website. We need to know how various types of messages are being sent and whether there are limited flow operations. If traffic limiting occurs, can you tell the service party that traffic limiting may be triggered due to excessive current traffic?

The system has a complete monitoring, you know all kinds of system indicators data, they will not panic. (Troubleshooting problems will be easily located with monitoring)

If one day someone tells you that your system is down, you are not stupid enough to go to the server to read the logs, are you? Turn on the monitoring to see if there is flow, flow is not normal can see it at a glance.

Solution: Monitor data from interface invocation to message delivery (mainly interface QPS and delivery number)

4.5 What should the business party do if it accidentally sends it twice in a row?

The business side uses it improperly and accidentally pushes it twice in a row. If there is no restriction, it really sends it twice. Imagine if you clicked on a CAPtcha and suddenly you got two identical messages. How would you feel?

Solution: As a platform, it is necessary to have such a bottom-saving function (to avoid accidents caused by improper business use as much as possible).

4.6 Who sent this message?

Customer service feedback: the user received a short message (the user does not understand the details of the specific message). Customer service looked at the message also two eyes meng force, the company is so big, do not know by which business team issued. Now only text copy, how can quickly find the team to send messages.

We need to make all messages passing through the Austin project have a “carrier” (literally a template). With a template, the business side needs to fill in all kinds of information when accessing, and this information can be combined with the search engine to locate the information quickly.

“Traceability” is useful in many situations (for example, if you provide an HTTP interface, if there are no restrictions on the business. Maybe someday you want to make a big change to this interface, but you don’t know who’s calling it right now, and it’s a pain.)

Solution: Set “template” to access party, with template can be traced, data tracking, template is the cornerstone of the platform. (In the next post, WHEN I build the table, I will tell you more about the corresponding business.)

4.7 How to access SMS channels frequently?

Business has found a cheap SMS channel, access to see the effect? This is a real money saver! Every time I write a class (access SMS is equivalent to writing a class), do I have to restart the release online? Is that crazy?

Solution: The uprules engine pulls out the business code and does not need to go up or down.

05,

It’s easy to implement features, but if you think about robustness, stability, and flexibility in the process of implementing features, what’s the fear in the interview process? Go out for an interview and say that I introduced a distributed configuration center based on the existing scenario, which greatly improved the work efficiency. When I go out for an interview, I will say that I have carried out complete monitoring and alarm for the whole system. There is no fault on the line in this process, and what is my solution when I meet problems at ordinary times.

This article is actually a “preview”, and I will implement all of these features in the future (of course, my small goal is not only mentioned above).

Follow my wechat public number [Java3y] in addition to technology I will also talk about some daily, some words can only say quietly ~ [line interview + write Java project from zero] continuous high intensity update! O star!!!!! Original is not easy!! Three times!!

Gitee link: gitee.com/austin

GitHub link: github.com/austin