1. Three major objectives of high concurrency system design

High concurrency High availability extensible
concept By means of design, the system can handle more user requests and carry more traffic, which is the background and premise of all architectural design
Design considerations Performance + availability

Performance: Indicates the user experience

Availability: the time when the system can provide normal services to users
Traffic = Normal traffic + peak traffic

Cope with rapid expansion during peak traffic

2. Performance optimization principles

  1. Performance must not be blind, it must be problem-oriented
    1. Blind optimization increases system complexity and wastes time
    2. May damage business
  2. Performance follows the principle of 82
    1. Solve 80% of your performance problems with 20% of your effort
    2. We must grasp the principal contradiction
  3. Performance optimization requires data titles
    1. Keep track of optimization indicators
  4. Performance optimization is continuous
    1. The reason for the performance problems is multiple, continuous optimization

3. Performance metrics

Data is necessary to identify existing performance problems, and it is important to identify performance metrics

Throughput (number of requests) + response time (start to end time of a single request)

A performance metric is usually the response time of a system interface, which needs to be represented by an eigenvalue over a period of time

The average Can reflect performance over time Poor sensitivity The average value is only used as a reference to measure performance
The maximum Maximum number of requests per unit time Too sensitive
Quantile values Sort all request times per unit time

A 90-bit response time is a 90-bit response time

Most commonly used in practical work
It’s a good reflection of performance over time

The larger the quantile, the more sensitive it is to slow requests

Experience:

The interface does not experience latency within 200ms

Within 1s, the delay is felt, but acceptable

The interface duration does not exceed 1s

4. Performance optimization under high concurrency

Provides the number of system cores: Increases the parallel processing capability of the system. Increasing the number of system cores may degrade the system performance

During the pressure test, it is necessary to find the inflection point of the system, find the bottleneck of the system, and continuously optimize the system performance

[image upload failed…(image-d42C7a-1633760715912)]

Reduce the response time of a single task: Divide tasks into CPU intensive + IO intensive tasks

CPU intensive: efficient algorithm + reduce the number of operations tool: Profile+ PEFF +eBPF

IO intensive: disk I/O+ Network I/O tools: Linux toolset + language-specific memory analysis tools + performance monitoring

Alignment optimizes when performance bottlenecks are found (vs dosing) :

If the database access is slow, it depends on whether there is a table lock, whether there is a full table scan, whether the index is added properly, whether there is a JOIN operation, whether there is a need to add cache

If it is a network problem, it depends on whether there is room for optimization of network parameters, packet capture to see whether there is a large number of timeout retransmission, network card whether there is a large number of packet loss, etc

5. Summary

Any optimizations require data first

Master the tools and methods of performance optimization and accumulate them in work

The basics are important to grasp the key to performance issues during optimization

Silver bullet: Cure-all, for every situation, for every problem