The pain of a big concurrent server 1: Transmission response Mode

Source: Internet
Author: User
Tags thread unique id

If you buy clothes on Taobao, you will find that a picture of the model is a bit slow to load. Sometimes the experience is just awful.

Let's analyze the transmission lifeline:

This is the ald.taobao.com domain name under the three requests, we found is in order to request the response, can not help but ask, why three requests not at the same time, could overlap it.

Now on the market all kinds of servers such as Nginx, Apache transmission of HTTP response is currently only one, namely: request----response----Request-----Response, we tentatively for the traditional mode, in the traditional mode, each request must be in the last response before, In fact, the overall response time is elongated, which is particularly noticeable on a number of content pages.

Today's internet has always been such a serial processing request, but the speed increased the disguise of narrowing the problem, slowing the development of parallel processing.

Some TCP-based streaming media Transmission control requests, is very much in need of parallel processing, but unfortunately the current market of video servers are blocking, but this kind of products are not many, we are holding can use on a good mentality, did not go to serious research to improve efficiency.

The traditional server handles the event in a way that multiple connections correspond to one process, for example, Nginx, a connection unique to a process, the event and memory is bound on the connection, the advantage is that the management of the event and memory can be done very simple, the disadvantage is also obvious, such as do not get the request--request-response---response.

This new pattern actually requires a connection that corresponds to multiple processes, and each process transmits content with a unique identification Fu Pe character.

Sharing connections between multiple processes is actually cumbersome, but it can be replaced with threads. The resulting event model is converted to the following pattern:

Memory and event management cannot be easily bound on a connection, unless the lock (inefficient, personal exclusion), should be in the speed and space compromise, such as the thread can allocate memory internally, the thread to deal with the event when the release, do not do is the processing granularity of the threads expanded, in some need of water processing business, You need to mount the memory allocated in the thread to the connection, or allocate large chunks of memory to the thread in advance.

The client can assign a unique ID for each emphasis, and the server's response also contains the corresponding ID, which avoids clutter in the client's response.

See more highlights of this column: http://www.bianceng.cn/Servers/zs/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.