C++ summary of several performance problems encountered in high concurrency

1. For a single request, it takes less than 4ms, and when the amount of concurrency comes up, it takes about 15ms;

      - When compiling with gcc, use the -O2 option;

2. On the basis of 1, when high concurrency, the time-consuming becomes about 8ms;

     - Change the copy of the object in the code to pointer copy;

3. On the basis of 2, when the concurrency is high, the time consumption becomes about 5ms, and the qps can only reach 2000;

    - Delete the -pg option of gcc;

4. On the basis of 3, when the concurrency is high, the time-consuming becomes about 3ms, but when the qps reaches 3100, the timeout rate becomes higher.

     According to the characteristics of the relatively large length of the returned data, check the situation of the network card (iftop -B), and reach the maximum bandwidth;

    - The next step is to use protobuf or compress first, and then send;

5. On the basis of 4, you can consider changing ptmalloc to jemalloc

Guess you like

Origin blog.csdn.net/zgb40302/article/details/85100924