Write first (skip)

I just looked at the concept of multiplexing and realized that my brain was not just looking at it, it needed vivid examples to deepen the memory. If you’re like me then you can spare a moment to listen to me tell you a little story. [Through my own understanding made up, there is something wrong, please pass by the big guy to point out]

To cough up

Imagine you buy a burger at Laurie’s somewhere, and there’s an order man at the counter

HTTP / 1.0

The orderer can only remember that you ordered one thing. If you want a burger, French fries, and chicken krispies, you need to say to the ordering person, “I want a burger.” д) ), and the person will bring you the burger, hand it to you, and order is over. You say, “I want more French fries.” The diner repeats the steps. The order is over. You said order man, I want chicken rice flower, repeat… . It’s a hassle. If I need to order a corporate meal, I need to keep ordering. ! At this time, a keep-alive notepad appeared. When you order, you take the Keep-alive notepad with you. You write down everything you want to order and show it to the orderer

HTTP / 1.1

This version comes with its own keep-alive notepad, so when you go to order, you can go empty-handed. Imagine two scenarios

  1. You want a super deluxe burger and oh, a bottle of water, so the orderer writes super Deluxe Burger and a bottle of mineral water on his notepad. Super deluxe burgers are complicated and can take a while to make. You’re so thirsty, the orderer doesn’t give you water and looks at you… . (The order taker says I can’t help it. My notebook is out of order and I’m afraid of messing it up. I’d better wait. • get out of here. ) Well, I’m really thirsty! (If one of your colleagues calls you and says you have two more orders, one of which is one order of French fries, one order of rice chicken, one order of ice cream; The other one is… Because you still haven’t finished your burger, you have to wait for two more orders. This is called “queue blocking”.)
  2. If we set the maximum number of orders a customer can order, say 60, we order 6. Since the ordering staff can handle 60 items in total, they can order up to 10 items per order. When you have a list of 20 things that you want to order, the orderer can only deal with 10 of them, and the rest can only be processed through the previous order. Even though you’re devastated, the orderer can’t help it!

HTTP / 2 version

Since the user experience in previous versions has not been great, “multiplexing” has emerged. What is multiplexing? It’s to solve the problems in front of us

  1. You want grilled wings, a super deluxe burger, a bottle of mineral water. The first two are slow to make, so instead of waiting for them at the window, the orderer goes to the cooler and brings you a bottle of mineral water, marks your bottle with a 3 with a frame (the symbol used to mark the order, “binary frame”), and returns to the window, etc. After the wings are ready, the order giver gives you the wings and marks your wing bag with a 1 with a frame. Then the burger is ready and the order giver gives you a hamburger with a 2. ! Your colleagues will call you and ask you to take two more orders to take with them, and the order taker will bring it to you as soon as possible. Because frames mark your order number and order, you won’t mess up your order if it’s out of order, and neither will the person ordering it (the binary frames form a “stream” to keep the order in order).
  2. Because the above optimization allows you to order 20 things you want, because the order is marked by frames, there is no need to wait! Because the assumption is that the maximum number of orders is 60, now the ordering person can handle only 60, and the next 6 orders will handle 360! Six times more efficient than the original! <(▰˘ plus-one item ˘▰)> This is multiplexing

explain

Ordering: one HTTP connection (three handshakes and four waves, good service) Ordering: Server we: browser Watch it again!)

The last

In fact, if you want to really understand or need to see the concept, there are a lot of online baidu. The short story is just to give you a glimpse or to reinforce your memory so that you don’t forget. I hope every knowledge point we learn can really understand, master, learn from others to become their own.

This article is formatted using MDNICE