How to Improve server system performance

Source: Internet
Author: User
Tags socket error

As we all know, in the development of server systems, the performance requirements are very high. Especially in the mass concurrency, the performance of server systems is particularly important. Someone may ask: why is my CPU consumption so high, why is my transaction processing so slow, and the execution efficiency cannot be improved. So how can we improve the system performance? Contact the current job to talk about this.


1. unreasonable server system architecture.

When designing a server, you must consider the efficiency, stability, high reliability, and availability of the entire system architecture. I have a deep understanding of this. In a recent project, because the server needs to accept concurrent requests from multiple clients with large volumes of small data, it poses a challenge to the server's business processing. The original design adopted the serial service processing process. As a result, the server accumulated a large number of services, resulting in serious packet loss. After discussion, in order to improve the service processing capability of the server, the producer-consumer model is adopted. When the service comes up, the server enters the queue directly, returns the result, and continues to accept the next request, shorten the communication retention time. Then, multiple business threads fetch services from the queue to speed up service processing, which effectively improves the server's ability to process services.

2. unreasonable communication protocols.

For large batches of small data and multi-client concurrency, you can consider using the UDP protocol. Because UDP is a connectionless transmission protocol, it can effectively reduce system overhead, especially for large batches of small data requests, the effect is obvious. In this case, TCP consumes a lot of resources on the system, which may lead to connection rejection or an error in the socket handle. Someone may ask, you can use short connections on the server side to save resources. In fact, the creation and destruction of a large number of sockets is a kind of extreme consumption on system performance, and sometimes the efficiency of using persistent connections is not high.

In the current P3 project, we used TCP connections. At that time, the concurrency was never raised, and in the case of a large number of concurrency, the system encountered a socket error, the resource consumption is high. Therefore, UDP protocol is used later, and TCP is used as an alternative solution to prevent the reliability of UDP.


3. Massive memory creation and destruction, and all memory-related operations will affect the system performance.

This is not obvious for a small amount of concurrency, but in a large number of concurrency, this will seriously affect the performance, such memory creation, destruction, and memory copy will consume 50% ~ 60% performance. In this case, try to create memory resources when the system is started, and then reclaim and reuse the resources after the business is processed. Do not create new memory when processing a large number of services, after processing, delete memory resources, which consumes a lot of system performance.

In addition, for custom protocol packet processing, use as few functions or types as possible that involve memory copy operations, such as memset and string. This will affect system performance when packaging and unpackaging.

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.