Instant messaging concurrent data processing system
By adjusting the parameters of Linux operating system and Java virtual machine, optimizing database configuration, and asynchronous processing of requests, the problem of insufficient concurrency performance of instant communication software is solved, and efficient resource utilization and low-cost concurrency performance improvement is achieved.
Patent Information
- Application Number
- CN202311863622.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-29
- Publication Date
- 2025-07-01
AI Technical Summary
The concurrent performance optimization method of existing instant messaging software mainly relies on hardware expansion, resulting in waste of resources and high costs, making it difficult to meet the usage needs of a large number of users.
By adjusting the port listening queue length and socket buffer size of the Linux operating system, optimizing the memory configuration and garbage collector of the Java virtual machine, configuring database cache and indexing, using asynchronous processing of time-consuming requests, optimizing the database query process, and reducing dependence on the underlying database.
It improves the processing capability of instant communication software in high concurrency scenarios, reduces resource waste and optimization costs, and improves the system's response speed and concurrency performance.
Smart Images

Figure CN120238513A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of instant messaging, and in particular, to an instant messaging concurrent data processing system. Background Art
[0002] Instant messaging is the mainstream communication method on the Internet. With the development of social science and technology, instant messaging software has become an important tool on which people rely for work and life. However, with the increasing number of users, the concurrent performance requirements for instant messaging software are getting higher and higher. Currently, the existing solutions for optimizing the concurrent performance of instant messaging software are mainly hardware methods, such as replacing the central processing unit with high performance, increasing the memory capacity, and increasing the number of instant messaging server machines. To a certain extent, the hardware method can improve the concurrent performance, but there are still some problems, such as the performance optimization of a single instant messaging server machine is not in place, physical hardware expansion causes resource waste, high cost, and difficult maintenance. Therefore, a new instant messaging software optimization method is needed to further improve the concurrent performance of instant messaging software, avoid resource waste, and ensure the usage requirements of a large number of users of instant messaging software. Summary of the Invention
[0003] In view of this, the embodiments of the present invention provide an instant messaging concurrent data processing system, providing an improved system to meet the concurrent requirements of instant messaging software and at the same time solving the problem of high cost of the existing optimization methods.
[0004] The present invention provides an instant messaging concurrent data processing system, and the system includes:
[0005] Multiple clients;
[0006] A server, the server is connected to each client, receives the concurrent requests of each client and makes responses; the server runs based on the Linux operating system;
[0007] Wherein, the server sets the maximum listening queue length of the port to a first set value, and sets the maximum value of the socket send and receive buffers to a second set value; and / or, modifies system parameters to enable the waiting type TCP connection fast recycling mechanism; and / or, sets the system maximum handle number, the specified user maximum handle number, and the single process maximum handle number of the Linux operating system to the same value;
[0008] The server uses a Java virtual machine as the middle layer between the instant messaging program and the Linux operating system. The initial value and the maximum value of the heap space of the Java virtual machine are the same. The thread stack space is configured according to the first standard. The memory space ratio of the old generation to the young generation of the Java virtual machine is specified as a first preset value, and a G1 garbage collector is configured;
[0009] The server configures a database for the instant messaging program to query, and the database stores and manages the data of the server side.
[0010] In some embodiments of the present invention, the server side includes a user module, a message module, and a management module;
[0011] The user module is used to provide user login and logout functions;
[0012] The message module is used to provide message sending and receiving functions;
[0013] The management module is used to execute system management and permission control functions.
[0014] In some embodiments of the present invention, the first set value is set to be greater than 128; the second set value is configured according to the first set value.
[0015] In some embodiments of the present invention, receiving concurrent requests from each client and making responses further includes:
[0016] The server side asynchronously processes the time-consuming requests in the concurrent requests sent by each client;
[0017] The time-consuming request refers to a request in the concurrent requests received and processed by the server side whose processing time exceeds the set time limit.
[0018] In some embodiments of the present invention, the maximum number of system handles, the maximum number of handles for a specified user, and the maximum number of handles for a single process of the Linux operating system are set to the same value, and the same value is set to a power of 2;
[0019] The maximum number of handles of the soft limit type in the maximum number of handles for a specified user does not exceed the maximum number of handles of the hard limit type.
[0020] In some embodiments of the present invention, configuring the thread stack space according to the first standard, the first standard being greater than 1024k; specifying that the memory space ratio of the old generation to the young generation of the Java virtual machine is a first preset value, and the first preset value is greater than 2.
[0021] In some embodiments of the present invention, it further includes:
[0022] Adopting a batch storage method for the data frequently generated during the instant messaging process;
[0023] Or, storing the message data during the instant messaging process in separate tables according to the time sequence.
[0024] In some embodiments of the present invention, the database includes a cache database and an underlying database;
[0025] The underlying database is used to store the data generated during instant messaging;
[0026] The cache database is used to cache the frequently queried data;
[0027] Create a database index for the fields frequently queried in the underlying database to reduce the response time for querying the underlying database;
[0028] If a query request is initiated, first query the cache database; if the result is not found in the cache database, then query the underlying database and store the query result in the cache database.
[0029] In some embodiments of the present invention, it further includes: loading service startup hot data into the cache database.
[0030] In some embodiments of the present invention, it further includes: the underlying database uses a MySQL database.
[0031] The beneficial effects of the present invention are at least:
[0032] The present invention provides an instant messaging concurrent data processing system, which includes multiple clients and a server running based on the Linux operating system. The server is connected to each client, receives concurrent requests and responds. The server adjusts the maximum listening queue length of the port and the maximum values of the socket send and receive buffers, and / or enables the fast recycling mechanism for waiting type tcp connections, and / or sets the system maximum handle number, the specified user maximum handle number, and the single process maximum handle number of the Linux operating system to the same value. The Java virtual machine is used as the middle layer between the instant messaging program and the Linux operating system. The initial value and the maximum value of the heap space of the Java virtual machine are set to be the same, the thread stack space is optimized, the memory space ratio of the old generation and the young generation of the Java virtual machine is adjusted, and the G1 garbage collector is configured. The server configures a database for the instant messaging program to query, and the database stores and manages the data of the server. The present invention proposes a system optimized from four aspects: the operating system, the Java virtual machine, the database, and the business logic, which can improve the processing ability of the instant messaging software when there are a large number of concurrent data, improve the concurrent performance of the communication software, and compared with most of the existing optimization schemes that adopt the method of expanding hardware, the optimization cost is lower and resource waste can be reduced.
[0033] The additional advantages, objectives, and features of the present invention will be partially described below, and will become partially obvious to those of ordinary skill in the art after studying the following text, or can be learned from the practice of the present invention. The objectives and other advantages of the present invention can be achieved and obtained through the structures specifically pointed out in the specification and the drawings.
[0034] Those skilled in the art will understand that the purposes and advantages that can be achieved by the present invention are not limited to those specifically described above, and the above and other purposes that the present invention can achieve will be more clearly understood according to the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] The drawings described herein are used to provide a further understanding of the present invention, form a part of this application, and do not limit the present invention. In the drawings:
[0036] Figure 1 It is a structural diagram of an instant messaging concurrent data processing system according to an embodiment of the present invention.
[0037] Figure 2 It is an architecture diagram of an instant messaging system according to another embodiment of the present invention.
[0038] Figure 3 It is a diagram of an instant messaging system optimization method according to another embodiment of the present invention.
[0039] Figure 4 It is a data query flowchart of an instant messaging system according to another embodiment of the present invention.
[0040] Figure 5 It is a flowchart of message time-based table query and storage according to another embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0041] To make the purposes, technical solutions, and advantages of the present invention clearer and more understandable, the present invention will be further described in detail below in conjunction with the embodiments and the drawings. Herein, the illustrative embodiments of the present invention and their descriptions are used to explain the present invention, but do not limit the present invention.
[0042] Here, it should also be noted that in order to avoid obscuring the present invention with unnecessary details, only the structures and / or processing steps closely related to the solution of the present invention are shown in the drawings, while other details less related to the present invention are omitted.
[0043] It should be emphasized that the term "including / comprising" when used herein refers to the presence of features, elements, steps, or components, but does not exclude the presence or addition of one or more other features, elements, steps, or components.
[0044] Here, it should also be noted that if not otherwise specified, the term "connection" in this article can not only refer to a direct connection, but also represent an indirect connection with an intermediate.
[0045] In the following, embodiments of the present invention will be described with reference to the drawings. In the drawings, the same reference numerals represent the same or similar components, or the same or similar steps.
[0046] Instant messaging refers to a communication method that transmits messages in real time through a computer network or the Internet. It allows users to communicate in real time in forms such as text, voice, video, etc., thus achieving instant communication and information exchange. As instant messaging becomes the mainstream communication method on the Internet, the number of users and their communication needs are increasing day by day, and the concurrent performance requirements for instant messaging software are getting higher and higher.
[0047] An embodiment of the present invention provides an instant messaging concurrent data processing system, and the structure of the system is as Figure 1 shown. The system includes:
[0048] Multiple clients. The clients can be various terminal devices loaded with instant messaging programs, such as computer terminals, mobile phone terminals, tablet computers or other intelligent devices.
[0049] A server. The server is connected to each client, receives the concurrent requests of each client and responds. The server runs based on the Linux operating system. A concurrent request means that the server receives multiple requests within the same time period. These requests can come from different users or clients, and send requests to the system simultaneously, such as sending data, requesting resources, performing operations, etc. For instant messaging, concurrent requests refer to receiving a large number of requests initiated by users for message sending, receiving, logging in, logging out, etc. within a short period of time.
[0050] Among them, the server sets the maximum listening queue length of the port to a first set value, and sets the maximum value of the socket send and receive buffers to a second set value. And / or, modify system parameters to enable the waiting type TCP connection fast recycling mechanism. And / or, set the maximum number of system handles, the maximum number of handles for a specified user, and the maximum number of handles for a single process of the Linux operating system to the same value.
[0051] The server uses a Java virtual machine as the middle layer between the instant messaging program and the Linux operating system. The initial value and the maximum value of the heap space of the Java virtual machine are the same. The thread stack space is configured according to the first standard. The memory space ratio of the old generation to the young generation of the Java virtual machine is set to a first preset value, and the G1 garbage collector is configured.
[0052] The server configures a database for the instant messaging program to query, and the database stores and manages the data of the server.
[0053] It should be further explained that when the number of concurrent requests reaches a certain level, the Linux operating system will display a prompt message indicating that the number of files exceeds the limit. This is because all storage formats in the Linux operating system are files. When an instant messaging client communicates with the server, each communication request corresponds to a file, which is called a handle. Adjusting the maximum length of the port listening queue, increasing the maximum value of the socket send and receive buffer, and enabling the fast recycling of waiting-type TCP connections are all achieved by optimizing the Linux system handles to enhance the system's processing capabilities for files and network connections and improve concurrent performance.
[0054] The maximum length of the port listening queue refers to the maximum length of the queue used to store incomplete connection requests when the server is in a listening state in the TCP protocol. When a client initiates a connection request to the server's IP address and port, the server will call the accept() function to handle the connection request. If the incomplete connection queue is full, new connection requests will be rejected. In the Linux system, specific parameters are used to adjust the size of the maximum length of the port listening queue. By default, this value is usually set to 128. In high-concurrency scenarios, appropriately increasing this value can ensure that the server can handle more connection requests. A socket is an abstract concept used to describe a communication link in computer network programming. The send buffer is a storage area inside the socket used to temporarily store data to be sent. When an application attempts to send data, the data is first stored in the send buffer, and then the operating system is responsible for sending it to the network. The maximum values of the socket send and receive buffers are the maximum capacities of the buffers, that is, the maximum number of bytes of data that can be stored.
[0055] The fast recycling mechanism for waiting-type TCP connections is a TCP connection management mechanism. The states of TCP connections include established, waiting, closed, etc. A connection in the waiting state refers to being in a certain waiting state, such as waiting for the client to send data or waiting for the server to send data. In high-concurrency scenarios, there may be a large number of TCP connections in the waiting state. By enabling the fast recycling of waiting-type TCP connections, the system can quickly detect connections in the waiting state and recycle them in a timely manner, releasing resources, reducing resource occupancy, and improving the system's concurrent performance.
[0056] The Java Virtual Machine (JVM) is one of the core components of the Java platform. It is a virtual machine that runs Java bytecode on a computer. The JVM acts as an intermediate layer between Java applications and the underlying operating system, providing cross-platform capabilities so that Java programs can run on different operating systems and hardware. In Java, memory does not need to be manually released; instead, built-in garbage collectors clean up garbage objects and release memory. The G1 garbage collector is a type of garbage collector in the Java Virtual Machine that can achieve high throughput in high-concurrency scenarios while meeting the requirements for the pause time of garbage object collection as much as possible.
[0057] In some embodiments of the present invention, the server includes a user module, a message module, and a management module.
[0058] The user module is used to provide user login and logout functions.
[0059] The message module is used to provide message sending and receiving functions.
[0060] The management module is used to execute system management and permission control functions.
[0061] In some embodiments of the present invention, the first set value is set to be greater than 128. The second set value is configured according to the first set value.
[0062] In some embodiments of the present invention, when receiving concurrent requests from each client and responding, it further includes:
[0063] The server asynchronously processes time-consuming requests among the concurrent requests sent by each client.
[0064] A time-consuming request refers to a request whose processing time exceeds the set time limit among the concurrent requests received and processed by the server.
[0065] Alternatively, it is determined whether it is a time-consuming request based on the size of the data to be processed required by the request.
[0066] Alternatively, it is determined whether it is a time-consuming request based on the number of file reads and writes and database queries.
[0067] It should be further explained that asynchronously processing time-consuming requests means that when receiving such requests, the system does not immediately process them but puts them into a processing queue and then immediately returns a response. Subsequently, the system runs an asynchronous task in the background to process this request without blocking the processing of other requests. This processing method can improve the concurrent processing ability and response speed of the system because the system will not be blocked by the processing of a single time-consuming request. Asynchronous processing is usually implemented by using technologies such as threads, event-driven, or message queues.
[0068] In some embodiments of the present invention, the system maximum handle number, the specified user maximum handle number, and the single-process maximum handle number of the Linux operating system are set to the same value, and the same value is set to a power of 2.
[0069] The maximum handle number of the soft limit type in the specified user maximum handle number does not exceed the maximum handle number of the hard limit type.
[0070] Setting the system maximum handle number, the specified user maximum handle number, and the single-process maximum handle number to the same value can improve the management of handle resources and ensure that the specified user and a single process can obtain sufficient handle resources. Setting the same value to a power of 2 is because powers of 2 generally have good alignment in computer systems, and the system and hardware platform will be more efficient in processing data that is a power of 2.
[0071] In some embodiments of the present invention, the thread stack space is configured according to a first standard. The first standard is greater than 1024k and can take a value of 4096k. The memory space ratio of the old generation to the young generation of the specified Java virtual machine is set to a first preset value. The first preset value is greater than 2 and can take a value of 4.
[0072] In some embodiments of the present invention, it further includes:
[0073] Adopt a batch storage method for data frequently generated during instant messaging.
[0074] Or, store the message data during instant messaging in separate tables according to the time sequence.
[0075] In some embodiments of the present invention, the database includes a cache database and an underlying database.
[0076] The underlying database is used to store the data generated during instant messaging.
[0077] The cache database is used to cache the data that is frequently queried.
[0078] Create a database index for the fields frequently queried in the underlying database to reduce the response time for querying the underlying database.
[0079] If a query request is initiated, first query the cache database. If the result is not found in the cache database, then query the underlying database and store the query result in the cache database.
[0080] It should be further explained that the underlying database is the database that stores the data generated during the operation of the instant messaging software
[0081] In some embodiments of the present invention, it further includes: loading the service startup hotspot data into the cache database.
[0082] In some embodiments of the present invention, it further includes: the underlying database uses a MySQL database. The MySQL database is a relational database that uses standard SQL language for data operation and management, and can conveniently perform operations such as data addition, deletion, modification, and query.
[0083] Another embodiment of the present invention provides an instant messaging concurrent data processing system. The system architecture diagram is as Figure 2 shown. The system includes a client and a server. The client provides a visual interface for users to use. Users operate the client interface to send requests to the server. The server is installed on the server and is used to receive and process client requests. The main modules of the server include a user module, a message module, and a management module. Among them, the user module mainly provides functions such as user login and user logout. The message module mainly provides functions such as message sending and message receiving. The management module mainly provides functions such as system management and permission control. Among them, the user module and the message module have relatively high requirements for concurrent performance.
[0084] This embodiment can optimize the concurrent performance of the instant messaging software from the following four aspects: operating system, Java virtual machine, database, and business logic, as Figure 3 shown.
[0085] In some embodiments, the concurrent performance of the instant messaging software is improved by tuning the Linux operating system handles.
[0086] Common instant messaging methods are usually implemented through instant messaging software. The instant messaging software is divided into a client and a server, and the client provides a visual interface. The server is used to receive client requests. Most instant messaging software servers are deployed on the Linux operating system. When the number of client users increases, the requirement for the concurrent performance of the server also increases. In the actual production environment, when the concurrency reaches a certain level, the Linux operating system will display the "too many open files" error message (the number of files exceeds the limit), resulting in a concurrent performance bottleneck on the server. This is because the storage format of the Linux operating system is all files. When the instant messaging client communicates with the server, each communication request corresponds to a file, which is called a handle.
[0087] Furthermore, the instant messaging software client communicates with the server through the network. In this embodiment, for the instant messaging network usage scenario, the network configuration of the server operating system kernel is optimized to improve the concurrent performance of the instant messaging software. The default port listening queue length of the Linux operating system is 128. This queue length is insufficient for the high-load scenario of instant messaging that often processes new connections, resulting in the inability of the server connection number in the high-concurrency scenario to meet the requirements of the instant messaging client. The embodiment of the present invention improves the data receiving and sending speed by adjusting the maximum port listening queue length and increasing the maximum value of the socket send and receive buffers. In the high-concurrency scenario of the instant messaging server, a large number of waiting-state TCP connections often occur. Each connection in this state will occupy a local port, with an upper limit of 65535. When a large number of requests from the instant messaging client are sent to the server, an error will occur when establishing a new TCP connection, and an error message will appear: address already in use. The embodiment of the present invention improves the concurrent performance of the instant messaging software under high load by enabling the quick recovery of waiting-type TCP connections and optimizing the memory parameter configuration used by the connections.
[0088] In some embodiments, the concurrent performance of the instant messaging software is improved by adjusting the relevant parameters of the Java virtual machine. The maximum value and the initial value of the Java virtual machine heap space are set to be the same to reduce the loss caused by dynamic heap memory allocation. The size of the thread stack space is increased to avoid stack overflow caused by the high-concurrency scenario of the instant messaging software. The memory space ratio between the young generation and the old generation of the virtual machine is optimized to avoid frequent garbage collection caused by insufficient memory space allocation for old-generation objects. For example, the JDK8 default uses the Parrallel garbage collector, that is, the Parallel Scavenge is used for garbage collection in the young generation area, and the Parallel Old is used for garbage collection in the old generation. The characteristic of this set of configurations is suitable for scenarios that are not sensitive to latency. However, instant messaging is the portal for user-to-user interaction and is very sensitive to latency. Therefore, it is not suitable to use the default garbage collector. In this embodiment, the G1 garbage collector of the Java virtual machine is enabled. In the high-concurrency scenario of instant messaging, the G1 garbage collector can meet the requirements of the garbage object collection pause time as much as possible while achieving high throughput.
[0089] The Java virtual machine is one of the core components of the Java platform. It is a virtual machine that runs Java bytecode on a computer. The Java virtual machine acts as an intermediate layer between Java applications and the underlying operating system.
[0090] In some embodiments, the data querying and storing of the instant messaging software rely on the underlying database. In a high-concurrency scenario, the performance of the instant messaging software is affected by the performance of the database. Therefore, an optimization solution is provided for the database: adding an in-memory database to reduce the number of times the instant messaging software accesses the underlying database. The query process is set such that the query first goes to the cache database for querying. If the cache database does not find the result, then the underlying database is queried, and the query result is stored in the cache database, so that the next query can directly retrieve data from the cache database, reducing the concurrent pressure on the underlying database.
[0091] Furthermore, database indexes are established for the frequently queried fields of the underlying database to reduce the response time of the instant messaging software for querying the database. The frequently queried fields referred to here include user names, user email addresses, organizational structures, and / or group names.
[0092] Furthermore, the data frequently generated by the instant messaging is stored in batches to reduce the occupation of database connection resources. The data frequently generated referred to in the present invention includes the messages sent by users and / or the log information generated by the instant messaging software.
[0093] Furthermore, the message data of the instant messaging software is stored in separate tables in chronological order to reduce the single-table query pressure of the instant messaging software message data.
[0094] In some embodiments, the database adopted by the system is a MySQL database.
[0095] Furthermore, the maximum number of allowed connections limit (max connections parameter) of the MySQL server is adjusted, and the number of pending connection requests accepted by the server (back log parameter) is adjusted to control the size of the backlog request connection stack, further increasing the number of connections of MySQL.
[0096] In a high-concurrency scenario, the MySQL system status variable (connection_errors_max_connections) will be non-zero and keep growing, resulting in continuous failure of instant messaging connection requests due to the inability to obtain a database connection. The above parameters can increase the number of MySQL connections and control the size of the backlog request connection stack.
[0097] Furthermore, complex instant messaging services require associating multiple tables. Adjust the parameter for opening tables in the cache (tableopen ache parameter) to control the number of table caches that can be opened by all SQL statement execution threads. Adjust the thread cache size parameter (thread cache size parameter) to increase the number of MySQL cache client service threads and speed up the connection speed of the instant messaging software to the database. Adjust the innodb lock wait timeout (innodb lock wait timeout parameter) to reduce the time for database transactions to wait for row locks, avoid long-term suspension of database transactions, and increase the quick feedback ability of the instant messaging software. The innodb lock wait timeout parameter is a configuration parameter of the MySQL InnoDB storage engine, which is used to specify the timeout when the InnoDB engine waits for locked resources. This defines the maximum time for a transaction to wait for a locked resource. If this time is exceeded, the transaction will time out and abandon the lock on this resource.
[0098] In some embodiments, the concurrent performance of the instant messaging software is improved by optimizing the business logic of the instant messaging software. In this embodiment, no specific business logic is specified, but three general business logic optimization methods are given.
[0099] When the instant messaging software service starts, load the frequently used hot data into the cache database to avoid all concurrent requests accessing the underlying database when the server just starts, resulting in excessive pressure on the underlying database.
[0100] Change time-consuming requests to asynchronous processing to improve the system response ability.
[0101] Optimize the instant messaging business processing algorithm by leveraging the concurrent programming features of the programming language.
[0102] Furthermore, in some embodiments, the specific configuration solutions for optimizing file handles and network configuration parameters of the Linux operating system for high-concurrency scenarios of instant messaging can be as follows:
[0103] View the file handle limits of the current operating system. Use the cat / proc / sys / fs / file-max command to view the current maximum number of file handles of the system, use the cat / etc / security / limits.conf command to view the maximum number of file handles of a specified user, and use the cat / proc / sys / fs / nr_open command to view the maximum number of file handles of a single process. It should be noted that when setting the handle parameters, the following rules need to be followed: the maximum number of file handles of a single process should not be greater than the maximum number of file handles of the system, and the soft type maximum number of file handles of a specified user cannot exceed the hard type maximum number of file handles.
[0104] This embodiment provides a handle tuning strategy. Use the vim / proc / sys / fs / file-max command to modify the maximum number of handles of the current system to N. Use the vim / etc / security / limits.conf command to modify the maximum number of handles of the root user, where the maximum number of handles of both soft and hard types is set to N. Use the vim / proc / sys / fs / nr_open command to modify the maximum number of handles of a single process to N. This embodiment does not specify a fixed value for N, and N takes a power of 2.
[0105] Network parameter tuning: View the current Linux kernel parameters through the cat / etc / sysctl.conf command, where the parameters starting with the net prefix are network-related parameter configurations, and use the vim / etc / sysctl.conf command to adjust the Linux kernel parameters.
[0106] In some embodiments, adjust the TCP connection listening queue length parameter (net.core.somaxconn), adjust the two TCP receive buffer size parameters net.core.rmem max and net.ipv4.tcp rmem, adjust the two TCP send buffer size parameters net.core.wmem max and net.ipv4.tcp wmem, and enable the TCP wait state fast recycling parameter net.ipv4.tcp tw recycle to 1. This embodiment does not specify the specific values of the parameters. The recommended values can be: the values of net.core.rmem max and net.core.wmem max are 16777216. The values of net.ipv4.tcp_rmem and net.ipv4.tcp wmem are "4096 87380 16777216". The value of net.ipv4.tcp tw recycle is 1.
[0107] In some embodiments, optimize the Java virtual machine for instant messaging software, set the maximum value and the initial value of the heap space to be the same, and reduce the loss caused by dynamic heap memory allocation. Increase the thread stack space size to avoid stack overflow caused by high concurrency in instant messaging scenarios. Optimize the proportion of the young generation space of the virtual machine and increase the proportion of the old generation memory space to adapt to the memory allocation of old generation objects in high concurrency scenarios of instant messaging, and enable the G1 garbage collector.
[0108] The specific operation is to specify the virtual machine running parameters when the instant messaging Java program starts. The specific parameter configuration is as follows:
[0109] JAVA_OPTS: "-Xms -Xmx -Xss -XX:NewRatio -XX:+UseG1GC"
[0110] Among them, -Xms is used to set the initial value of the Java virtual machine heap memory space, generally set to 1 / 4 of the server memory size. -Xmx is used to set the maximum value of the Java virtual machine heap memory space, which is kept consistent with the initial value of the Java virtual machine heap memory space. -Xss is used to set the Java virtual machine thread stack size, with a default of 1024k. In this embodiment, this value is greater than 1024k and can be set to 4096k. -XX:NewRatio is used to specify the ratio of the young generation to the old generation memory space in the Java virtual machine heap memory, with a default of 2, representing a ratio of 1:2 for the young generation to the old generation. In this embodiment, this value is greater than 2 and can be set to 4. -XX:+UseG1GC is used to enable the G1 garbage collector of the Java virtual machine.
[0111] In some embodiments, the database optimization technical solution is as follows:
[0112] 1) Add key indexes, specifically including:
[0113] Create database indexes for fields frequently queried by the underlying database to improve data query efficiency. Taking MySQL as an example, the specific operation is to use the following database command to create an index for the specified field.
[0114] For example: CREATE INDEX index_name ON table_name(column1[ASC|DESC], column2[ASC|DESC],...).
[0115] Among them, CREATE INDEX is the keyword for creating an index, index name specifies the name of the index to be created, and the index name must be unique in the table. table name: specifies the table name (column1, column2,...) specifies the field names to be indexed. ASC and DESC (optional): are used to specify the sorting order of the index. By default, the index is sorted in ascending order (ASC). In this embodiment, the frequently queried fields referred to include user name, user email, and / or organization name.
[0116] 2) Add caches to reduce the number of accesses, specifically including:
[0117] Add an in-memory database as a data buffer layer to reduce the number of accesses of the instant messaging software to the underlying database. When the instant messaging client sends a query request to the instant messaging server, the server first queries the data in the cache database. If the data is not found in the cache database, it queries the underlying database and stores the queried result in the cache database. Figure 4It is a data query flowchart for instant messaging software. In this embodiment, no specific in-memory database product is specified, and the database can be several common in-memory database products such as redis, memcached, or voltdb.
[0118] 3) Frequently generate data and batch it into the database, specifically including:
[0119] The frequently generated data is temporarily stored in a queue, and a certain amount of data is retrieved from the queue at regular intervals and then batch-stored in the database. The frequently generated data referred to in this embodiment is a large amount of data that needs to be stored in the database during the operation of the instant messaging software, including messages and / or logs generated during the operation of the instant messaging software.
[0120] 4) Divide the message data by time, specifically including:
[0121] The message module is one of the core modules of instant messaging. In a high-concurrency scenario, a large amount of message content needs to be stored in a single database table. Storing and querying message content in one table brings performance bottlenecks. This embodiment provides a message table division strategy to divide the message content into tables. The table division rule is in chronological order. When querying and storing messages, first judge the time period and then operate on the corresponding message table. Figure 5 It is a flowchart for querying and storing messages divided by time.
[0122] 5) Optimize the parameters of the database, specifically including:
[0123] Optimize the MySQL database. In this embodiment, for the high-concurrency scenario of instant messaging software, a MySQL optimization method is provided. The specific steps are as follows: Modify the MySQL configuration file, increase the maximum connection parameter (max connections parameter), increase the backlog parameter value. The default value of this parameter is 50+(max connections / 5), which can be appropriately increased according to the machine performance. Increase the table open cache parameter (table open cache parameter) value, and reduce the innodb lock wait timeout parameter (innodb lock wait timeout parameter) value. This embodiment does not specify specific parameter values, and they should be appropriately adjusted according to the machine performance during the actual implementation process.
[0124] In some embodiments, when the service starts, hot data is loaded into the cache database. The cache database is introduced to relieve the pressure on the underlying database in high-concurrency scenarios. Logically, when the instant messaging service starts, hot data that users often use can be pre-loaded into the cache database in advance, preventing all requests from hitting the underlying database when the service just starts and causing the service to crash. For example, when the service starts, the user data logged in in the last 10 days is pre-loaded into the cache to reduce the concurrent pressure when the instant messaging software service starts and improve the performance and concurrent processing ability of the system.
[0125] In some embodiments, time-consuming requests are changed to asynchronous processing to improve the system response ability. There are some time-consuming requests in instant messaging. For example, after the user information is updated, the friend information of the affected users is asynchronously refreshed. Modifying the information and refreshing it to the friend instant messaging client interface is a time-consuming request. Changing this operation to an asynchronous method can improve the system response ability.
[0126] In some embodiments, an optimized algorithm is used for concurrent programming to implement the instant messaging service process. For example, downloading a large file is split into multiple threads for processing, and the start and end positions of the file downloaded by each thread are calculated to implement segmented downloading of the file.
[0127] In summary, the present invention provides an instant messaging concurrent data processing system. The system includes multiple clients and a server running on a Linux operating system. The server is connected to each client, receives concurrent requests, and responds. The server adjusts the maximum listening queue length of the port and the maximum values of the socket send and receive buffers, and / or enables the fast recycling mechanism for waiting-type tcp connections, and / or sets the maximum number of system handles, the maximum number of handles for a specified user, and the maximum number of handles for a single process in the Linux operating system to the same value. The Java virtual machine is used as the intermediate layer between the instant messaging program and the Linux operating system. The initial value and the maximum value of the heap space of the Java virtual machine are set to be the same, the thread stack space is optimized, the memory space ratio of the old generation and the young generation of the Java virtual machine is adjusted, and the G1 garbage collector is configured. The server configures a database for the instant messaging program to query, and the database stores and manages the data of the server. The present invention comprehensively optimizes the system from aspects such as the operating system, the Java virtual machine, and the database, improves the instant messaging concurrent data processing ability, and has a lower cost compared with the existing optimization solutions.
[0128] Correspondingly, the present invention also provides a device. The device includes a computer device, the computer device includes a processor and a memory, computer instructions are stored in the memory, and the processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the device implements the steps of the method described above.
[0129] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the foregoing edge computing server deployment method are implemented. The computer-readable storage medium may be a tangible storage medium, such as a random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, register, floppy disk, hard disk, removable storage disk, CD-ROM, or any other form of storage medium well known in the art.
[0130] Those of ordinary skill in the art should understand that the various exemplary components, systems, and methods described in conjunction with the embodiments disclosed herein can be implemented in hardware, software, or a combination of both. Specifically, whether to implement in hardware or software depends on the specific application and design constraints of the technical solution. A professional technician can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present invention. When implemented in hardware, it can be, for example, an electronic circuit, an application-specific integrated circuit (ASIC), appropriate firmware, a plug-in, a functional card, and so on. When implemented in software, the elements of the present invention are programs or code segments used to execute the required tasks. The program or code segment can be stored in a machine-readable medium or transmitted through a data signal carried in a carrier wave on a transmission medium or a communication link.
[0131] It should be clear that the present invention is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, the detailed description of known methods is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present invention is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order between steps after understanding the spirit of the present invention.
[0132] In the present invention, the features described and / or illustrated for one embodiment can be used in the same or similar manner in one or more other embodiments, and / or combined with the features of other embodiments or replace the features of other embodiments.
[0133] The above are only the preferred embodiments of the present invention and are not used to limit the present invention. For those skilled in the art, various changes and modifications can be made to the embodiments of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. An instant messaging concurrent data processing system, characterized in that, The system includes: Multiple clients; A server, which is connected to each client, receives concurrent requests from each client and responds; the server runs based on the Linux operating system; Wherein, the server sets the maximum listening queue length of the port to a first set value, and sets the maximum value of the socket send and receive buffers to a second set value; and / or, modifies system parameters to enable the fast recycling mechanism for waiting type TCP connections; and / or, sets the maximum number of system handles, the maximum number of handles for a specified user, and the maximum number of handles for a single process of the Linux operating system to the same value; The server uses a Java virtual machine as the middle layer between the instant messaging program and the Linux operating system. The initial value and the maximum value of the heap space of the Java virtual machine are the same. The thread stack space is configured according to a first standard, and the memory space ratio of the old generation to the young generation of the Java virtual machine is specified as a first preset value, and a G1 garbage collector is configured; The server configures a database for the instant messaging program to query, and the database stores and manages the data of the server.
2. The instant messaging concurrent data processing system according to claim 1, characterized in that, The server includes a user module, a message module, and a management module; The user module is used to provide user login and logout functions; The message module is used to provide message sending and receiving functions; The management module is used to execute system management and permission control functions.
3. The instant messaging concurrent data processing system according to claim 1, characterized in that, The first set value is set to be greater than 128; the second set value is configured according to the first set value.
4. The instant messaging concurrent data processing system according to claim 1, characterized in that, Receiving concurrent requests from each client and responding also includes: The server asynchronously processes time-consuming requests among the concurrent requests sent by each client; The time-consuming request refers to a request whose processing time exceeds a set time limit among the concurrent requests received and processed by the server.
5. The instant messaging concurrent data processing system according to claim 1, characterized in that Setting the maximum number of system handles, the maximum number of handles for a specified user, and the maximum number of handles for a single process of the Linux operating system to the same value, and the same value is set to a power of 2; The maximum number of handles of the soft limit type in the maximum number of handles for a specified user does not exceed the maximum number of handles of the hard limit type.
6. The instant messaging concurrent data processing system according to claim 1, wherein Configuring the thread stack space according to the first standard, and the first standard is greater than 1024k; specifying the memory space ratio of the old generation to the young generation of the Java virtual machine as a first preset value, and the first preset value is greater than 2.
7. The instant messaging concurrent data processing system according to claim 1, characterized in that, It also includes: Adopting a batch storage method for the data frequently generated during the instant messaging process; Or, storing the message data during the instant messaging process in separate tables according to the time sequence.
8. The instant messaging concurrent data processing system according to claim 1, wherein The database includes a cache database and a bottom-layer database; The bottom-layer database is used to store the data generated during instant messaging; The cache database is used to cache the frequently queried data; Establishing a database index for the frequently queried fields in the bottom-layer database to reduce the response time for querying the bottom-layer database; If a query request is initiated, first query the cache database; if the cache database does not query the result, then query the bottom-layer database and store the queried result in the cache database.
9. The instant messaging concurrent data processing system according to claim 8, wherein It also includes: Loading the service startup hotspot data into the cache database.
10. The instant messaging concurrent data processing system according to claim 8, wherein It also includes: The underlying database uses a MySQL database.