Performance optimization Case (i): Improve the system performance by modifying the routing algorithm __ algorithm

Source: Internet
Author: User
Tags split cpu usage

Performance optimization case one improves system performance by modifying the routing algorithm optimization effect of system structure optimization method

Performance Optimization Case (i): Improve system performance by modifying routing algorithms Overview

There are two general performance optimization methods: One is to optimize the performance of a method from the code level, thereby improving the performance of a single machine, and secondly, optimizing from the system structure level, reducing the resource consumption by reducing the effort. Here, we write an example that optimizes performance using the second method. System Structure

First, describe the initial system structure. We have a ticket search system, and the architecture is as follows:

Provider provides a search service, consumer is responsible for initiating a search request to provider, router provides routing capabilities, routes the request hash to provider processing, and hashes to increase the cache hit rate on provider. Of course, in order to reduce the release jitter, a consistent hashing algorithm is used.

In practice, a large route may have hundreds of flights, the smallest route is only a few flights, while a search request, will bring dozens of agents, each agent has its own price. If there are 200 flights on one of the requested routes, there are 30 agents, there are 6,000 flights, so the amount of calculation is very large. In order to accelerate the query speed of the large route, in the router section, the request is split in accordance with the agent dimension, and a request from consumer is dispersed into multiple requests sent to provider processing. The router routing algorithm is shown in the following figure:

Note: This does not consider how provider returns the computed results, whether it is a synchronous return or an asynchronous return, without affecting the subsequent optimization scheme.

How does the search service in provider work? You can look at the following figure:

After receiving the search request, asynchronously parallel calls the external interface to obtain four resources A, B, C, D, and then obtain the quotation data, and finally calculate and return the results. The quote data is cached and no other data is cached (mainly repetitive, even if the cache hit ratio is not high).

When 1 requests are dispersed to n at the router, the N, B, C, D Four resources are the same for the nth request, and the quotation data are different. Assuming that N is 30, the search request obtains 30 times A, B, C, D data service. Originally we divided the request according to the agency dimension, is to speed up the large route inquiry. However, because there is no different processing for the size of the route, resulting in small routes are also split. Split the previous 1 search requests, only need to get a, B, C, D four resources, after splitting into 30 times. For small routes, not split processing, the processing time is also satisfied with the requirements, after splitting, the equivalent of a white increase in 29*4 external calls.

Here's a summary of what the problem is. When we split 1 search requests into N processing, for small routes, splitting requests did not result in much faster processing, instead of 30*4 external calls. And the large route should also be appropriate to control the degree of dispersion, such as 1 requests split into 30 are also a bit too scattered, split into 10 more reasonable. Optimization Method

The original router request split in the N equals the number of agents in a request, the optimization method is to reduce the number of sub-requests split out, that is, reduce N. For example, the number of flights is a small single-digit route, n can be set to 5, for the large route N can be set to 10. optimization effect Router machine calls provider's QPS decreased by 50%, while CPU utilization and network bandwidth decreased by 25%. The CPU usage and network bandwidth of the provider machine is reduced by 15%. Provider calls the ABCD four interface to reduce the QPS by 50%. ABCD's system resource usage also decreased by 15% to 40%, because the request from the ABCD four interfaces accounted for more than half of the overall requests from the search system.

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.