Joke Collection Website - Blessing messages - Short link service structure

Short link service structure

Keywords: long link; Short link; Redirect;

Long link problem:

Copying is easy to make mistakes, long link URL is long, sometimes there is more than one parameter, and copying is easy to be omitted or truncated by editing when pasting;

It's easy to be shielded. Most long links expose resource sources and allocation strategies, and are easily blocked when put into a third party, such as being blocked by SMS and WeChat.

Counterexample:

So we consider short link service to compress long links and jump instead!

1. User access short link:/daogou/20200914/64294.html.

3. The server returns the status code 30 1/302 and sets the position in the response header as the original link;

4. The browser redirects to the original link;

5. Return the response;

Short link generation:

1. Library table design: id, code (short chain code) and url (original link) are stored in key-value mode.

2, short chain code

1), storage mode: 62, optional for each bit? A-Z, a-z and 0-9? 62 characters, etc. , larger than the usual digital storage. note:

Four digits can represent 62 4 =1477 and 6336 about150,000 pieces of data;

5 digits can represent 62 5 =? 9 16 132832 about 900 million pieces of data;

Six bits can represent 62 6 = 568,00235584 about 56 billion pieces of data;

Example:

Through the length of the short chain code, we can judge the historical business volume of each platform service plate, as shown in the above figure:

Like Pinduoduo, the rookie station uses 8-digit short chain code, 62 8 = 218,34010,05584896, and its business volume has accumulated to several trillion levels.

In addition, it is worth noting that clicking Pinduoduo's link directly opens the App (refer to the specific technical scheme: How to arouse the APP from the promotion of SMS links), which is better than the promotion of most applications.

2) Generation method: it can be generated by ID self-increasing sequence (binary conversion from 10 to 62 after self-increasing) and hash algorithm. For reference, if you are taught to design a short link system, what aspects will you improve your performance?

Redirect performance considerations:

1, 30 1, 302 jump difference:

1), 30 1 jump, permanent redirect, which is cached by the browser by default. As long as you visit the short chain once, you will jump directly to the original chain address without going through the server;

2), 302 jump, temporary redirection, not cached by the browser, passing through the short link server every time;

Therefore, in order to realize more flexible resource hop configuration in short chain, it is more appropriate to use 302 hop. Disadvantages are: unfriendly to search engines+performance problems (short-chain service is needed every time); Considering SEO+ access performance (browser caching solution), it is recommended to adopt 30 1 jump mode.

2. Make a query table through Redis, and map the short chain code to the long link Url;;

3. Prevent robot scripts from accessing, and combine mechanisms such as whitelisting;

Note: As a short-chain service open to the outside world, it requires high design requirements and is designed as an independent system.

Note: The writing ideas and methods of all contents in this chapter:

1. Manually generate a short link of the specified resource and start it;

2. For the specified resources, generate short links in batches and form records for delivery;

3. Automatically generate short links in some links (such as SMS delivery and WeChat sharing) to complete delivery;

Describe how to apply the scenario:

1, friends circle message:

2. WeChat /QQ group plug-ins automatically send links.

Wechat, the effect of saving space is good:

Commonly used QQ group automatic reply plug-ins:

3. SMS marketing

Advantages:

1, when the link is placed, it is convenient to copy and paste;

2. Short URL makes typesetting beautiful and concise, and users pay attention to copywriting;

3. Prevent blocking, such as SMS blocking and WeChat blocking.

4. Access resource validity control, add password, etc. :

In principle, you can do anything the backend wants to do before jumping, such as access statistics, such as switching the subsequent access links, so the access resources are more controllable.

For example, the jump resource is unstable. If today is A and tomorrow is B, you can switch the jump resource by modifying the original link.

Extended introduction of related technologies

1 and 30 1 influence on redirection: /p/457.html

2. If it is launched, it will inevitably involve the management of resources, channels and effects:

Resource management, such as articles;

Channel management, such as WeChat channel (WeChat official account, friends circle, private chat of operators), QQ, Weibo, SMS and headlines. .....

Statistics of delivery effect, statistics of article effect (what is the effect of each article? ), the effect of channel statistics (what is the effect of each channel? ), for the article &; Channel effect statistics (that is, what is the effect of different articles in different channels? )

3, everything is for revenue! How to arouse App to promote SMS links?

4. If you were taught to design a short link system, what aspects would you improve your performance?