CN111400063A - Communication method and system for high-concurrency transmission between servers - Google Patents

Communication method and system for high-concurrency transmission between servers Download PDF

Info

Publication number
CN111400063A
CN111400063A CN202010174803.4A CN202010174803A CN111400063A CN 111400063 A CN111400063 A CN 111400063A CN 202010174803 A CN202010174803 A CN 202010174803A CN 111400063 A CN111400063 A CN 111400063A
Authority
CN
China
Prior art keywords
identification information
memory block
shared memory
client
response message
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010174803.4A
Other languages
Chinese (zh)
Other versions
CN111400063B (en
Inventor
邓亚隆
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suzhou Inspur Intelligent Technology Co Ltd
Original Assignee
Suzhou Inspur Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Inspur Intelligent Technology Co Ltd filed Critical Suzhou Inspur Intelligent Technology Co Ltd
Priority to CN202010174803.4A priority Critical patent/CN111400063B/en
Publication of CN111400063A publication Critical patent/CN111400063A/en
Application granted granted Critical
Publication of CN111400063B publication Critical patent/CN111400063B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/544Buffers; Shared memory; Pipes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The application discloses a communication method and a system for high-concurrency transmission between servers, wherein the method comprises the following steps: firstly establishing a shared memory block, secondly adding identification information to be sent by a client, then sending the identified information to a server, correspondingly, the server returns a response message with the identification information according to the identified information to be sent, after receiving the response message, the client server checks the response message until the subprocess disappears after the check is correct, and the process is ended. The system comprises: the device comprises a shared memory block establishing module, an identification module, a sending module, a response module and a checking module. Through the method and the device, the phenomenon of wire stringing in the information transmission process can be avoided, and the accuracy of data transmission is effectively improved.

Description

Communication method and system for high-concurrency transmission between servers
Technical Field
The present application relates to the field of server communication technologies, and in particular, to a communication method and system for high concurrency transmission between servers.
Background
In the field of server communications, high concurrency of messages between servers is often required. Under the condition of high concurrency among servers, how to design a communication mode among server applications so as to improve the fluency and stability of message transmission is an important problem.
At present, when messages are transmitted among servers at high concurrency, a large enterprise generally deploys a plurality of server terminals and client terminals, and F5 hard load balance is erected in the middle to reduce the server load, so that a server cluster can smoothly operate even under high load pressure, and a communication message schematic diagram under a normal communication condition can be shown in fig. 1.
However, due to some reasons of F5 hard load balancing device or server, the server-side message-string situation shown in fig. 2 may be caused, namely: when high concurrency message interaction is carried out, a service A process and a service B process of a client server simultaneously send requests to a server, and when the server simultaneously responds to the A result and the B result, the response result of the A process is transmitted to the B process; the response result of the process B is transmitted to the process A, so that the message in the service deployed on the client server is highly concatenated, and the serious loss of an enterprise can be directly caused under the commercial deployment production environment. Or the case of the load balancing side message string shown in fig. 3 occurs, that is: the server does not disturb the corresponding relation, but when the load balancing hardware processes the message, the message is disordered, so that the service process on the client server receives the transaction failure message but receives the successful response content, otherwise, the process receiving the transaction success receives the failed response content. Therefore, the current communication method causes the message transmission between the server applications to be less accurate.
Disclosure of Invention
The application provides a communication method and a communication system for high-concurrency transmission between servers, which aim to solve the problem that the accuracy of message transmission between server applications is low due to the communication method in the prior art.
In order to solve the technical problem, the embodiment of the application discloses the following technical scheme:
a communication method for high concurrency transmission between servers, the method comprising:
establishing a shared memory block, where the shared memory block is used to store identification information and a file descriptor, where the identification information includes: pid and client server identification, the client server identification being: the client server MAC, the client server machine code and the client server IP;
adding identification information to be sent of the client according to the number of the client servers, and acquiring the identified information to be sent;
sending the identified information to be sent to a server;
the server-side server returns a response message to the server-side server according to the identified information to be sent, wherein the identification information is added in the response message;
and the client server checks the response message according to the current sub-process information and the identification information until the check is correct.
Optionally, the establishing the shared memory block includes:
establishing a header file under a current directory of a client server, wherein the header file is used for recording the ID of a shared memory block;
and establishing a shared memory block according to the acquired command and the set memory space.
Optionally, the adding, according to the number of the client servers, identification information to be sent by the client, and acquiring the identified information to be sent includes:
when the number of the client servers is 1, acquiring the pid of the current sub-process;
determining the shared memory block according to the ID (Identity, Identity number) of the shared memory block recorded in the header file;
writing the pid (Process Identity) of the current sub-Process and the file descriptor into the shared memory block;
and splicing the pid of the current sub-process and the message to be sent, and acquiring the identified message to be sent.
Optionally, the adding, according to the number of the client servers, identification information to be sent by the client, and acquiring the identified information to be sent includes:
when the number of the client servers is more than or equal to 2, acquiring the pid of the current sub-process and the client server identification;
determining the shared memory block according to the ID of the shared memory block recorded in the header file;
writing the pid of the current sub-process, the client server identifier and the file descriptor into the shared memory block;
and splicing the pid of the current sub-process, the client server identifier and the message to be sent, and acquiring the message to be sent after the identifier.
Optionally, the step of the client server verifying the response message according to the current sub-process information and the identification information until the verification is correct includes:
after receiving the response message, the client server extracts identification information according to the content of the response message and defines the extracted identification information as first identification information;
determining the shared memory block according to the ID of the shared memory block recorded in the header file;
judging whether the first identification information is the same as second identification information, wherein the second identification information is identification information in the current sub-process information;
if the first identification information is different from the second identification information, determining an affiliate of the response message according to the first identification information, and sending the response message to the affiliate;
if the first identification information is the same as the second identification information, judging whether the file descriptor corresponding to the identification information of the shared memory block is consistent with the current sub-process file descriptor;
if the file descriptor corresponding to the shared memory block identification information is consistent with the current subprocess file descriptor, judging that the message is not in a string state;
and if the file descriptor corresponding to the identification information of the shared memory block is not consistent with the current subprocess file descriptor, determining the attribution of the response message again according to the first identification information, and sending the response message to the attribution.
Optionally, the determining an owner of the response message according to the first identification information and sending the response message to the owner includes:
determining the position of first identification information in the shared memory block according to the acquired command;
intercepting single block size content defined by the first identification information and the file descriptor to a memory array;
acquiring a file descriptor matched with first identification information from the shared memory block;
and sending the response message to the file descriptor matched with the first identification information.
A communication system for high concurrency transmission between servers, said system comprising:
a shared memory block establishing module, configured to establish a shared memory block, where the shared memory block is used to store identification information and a file descriptor, and the identification information includes: pid and client server identification, the client server identification being: the client server MAC, the client server machine code and the client server IP;
the identification module is used for adding identification information to the information to be sent of the client according to the number of the client servers and acquiring the identified information to be sent;
the sending module is used for sending the information to be sent after the identification to a server;
the response module is used for returning a response message to the server according to the identified information to be sent, and the identification information is added in the response message;
and the checking module is used for checking the response message according to the current subprocess information and the identification information until the checking is correct.
Optionally, the identification module comprises:
the first subprocess acquiring unit is used for acquiring the pid of the current subprocess when the number of the client servers is 1;
a shared memory block determination unit, configured to determine the shared memory block according to the ID of the shared memory block recorded in the header file;
a first writing unit, configured to write the pid of the current sub-process and the file descriptor into the shared memory block;
and the first splicing unit is used for splicing the pid of the current sub-process and the message to be sent, and acquiring the identified message to be sent.
Optionally, the identification module comprises:
the second process obtaining unit is used for obtaining the pid of the current sub-process and the client server identification when the number of the client servers is more than or equal to 2;
a shared memory block determination unit, configured to determine the shared memory block according to the ID of the shared memory block recorded in the header file;
a second writing unit, configured to write the pid of the current sub-process, the client server identifier, and the file descriptor into the shared memory block;
and the second splicing unit is used for splicing the pid of the current sub-process, the client server identifier and the message to be sent, and acquiring the message to be sent after the identifier.
Optionally, the verification module includes:
the identification information extraction unit is used for extracting identification information according to the content of the response message after the client server receives the response message, and defining the extracted identification information as first identification information;
a shared memory block determination unit, configured to determine the shared memory block according to the ID of the shared memory block recorded in the header file;
the first judging unit is used for judging whether the first identification information is the same as second identification information, and the second identification information is identification information in the current sub-process information;
a response message sending unit, configured to determine, according to the first identification information, an affiliate of the response message when the first identification information is different from the second identification information, and send the response message to the affiliate;
and the second judging unit is used for judging whether the file descriptor corresponding to the shared memory block identification information is consistent with the current subprocess file descriptor or not when the first identification information is the same as the second identification information, judging that the message is not in a string state if the file descriptor corresponding to the shared memory block identification information is consistent with the current subprocess file descriptor, and starting the response message sending unit if the message is not in a string state.
The technical scheme provided by the embodiment of the application can have the following beneficial effects:
the application provides a communication method for high concurrency transmission between servers, which mainly improves communication design from the perspective of a client server, and the server only needs to support the corresponding message format of the client. Firstly establishing a shared memory block, secondly adding identification information to be sent by a client, then sending the identified information to a server, correspondingly, the server returns a response message with the identification information according to the identified information to be sent, after receiving the response message, the client server checks the response message until the subprocess disappears after the check is correct, and the process is ended. In the embodiment, the identification information is added in the information sent by the client, and the information is transmitted with the identification information in the transmission process, so that the message can be effectively prevented from being tampered or from being subjected to message crosstalk, and the accuracy of information transmission is improved. In addition, in the embodiment, the client checks the returned information, and only under the condition that the identification information is completely matched with the file descriptor, the client identifies the response message, so that the condition of message sending and line stringing is avoided, and the accuracy of information transmission is further improved.
The present application further provides a communication system for high concurrency transmission between servers, the system comprising: the device comprises a shared memory block establishing module, an identification module, a sending module, a response module and a checking module. Through the setting of the identification module, the message can be prevented from being tampered in the transmission process, and the accuracy of information transmission is improved. The check module is arranged, so that only the information with the identification information and the file descriptor completely identical to the content stored in the shared memory block can be identified and responded by the client, message crosstalk is avoided, and the accuracy and the reliability of information transmission are improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the application.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and together with the description, serve to explain the principles of the application.
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a diagram illustrating a communication message under normal communication conditions;
FIG. 2 is a diagram illustrating communication messages during server-side connection;
FIG. 3 is a schematic diagram of communication messages during a load balancing end connection;
fig. 4 is a schematic flowchart illustrating a communication method for high concurrency transmission between servers according to an embodiment of the present disclosure;
fig. 5 is a schematic flowchart of a method for verifying a response message in an embodiment of the present application;
fig. 6 is a schematic structural diagram of a communication system with high concurrency transmission between servers according to an embodiment of the present application.
Detailed Description
In order to make those skilled in the art better understand the technical solutions in the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
For a better understanding of the present application, embodiments of the present application are explained in detail below with reference to the accompanying drawings.
Example one
Referring to fig. 4, fig. 4 is a schematic flowchart illustrating a communication method for high concurrency transmission between servers according to an embodiment of the present disclosure. As shown in fig. 4, the communication method for high concurrency transmission between servers in this embodiment mainly includes the following steps:
s1: and establishing a shared memory block, wherein the shared memory block is used for storing the identification information and the file descriptor. Wherein the identification information includes: pid and client server identification, the client server identification being: client server MAC, client server machine code, and client server IP.
The communication method in this embodiment occurs between the client server and the server. The identification information and the file descriptor stored in the shared memory block are unique identification information, and when the client server only has one server, the identification information is pid; when there are two or more servers in the client server, the identification information includes a pid and a client server identification. Wherein, the client server identification is a whole: the combination information of the client server MAC + the client server machine code + the client server IP, and pid is the ID of the sub-process.
Specifically, the method for establishing a shared memory block in this embodiment includes:
s11: and establishing a header file under the current directory of the client server, wherein the header file is used for recording the ID of the shared memory block.
The method in this embodiment may be implemented by programming in C language. Taking C language as an example, an open function is called first to establish a header file named shm _ test.h under the current directory of the client server, so as to store and record the ID of the shared memory block, so that all processes running on the client server can access the shared memory block. In the following detailed embodiments of the present invention, the C language is taken as an example to describe the related communication method, but the present invention is not limited to the C language, and other language forms such as java language or python language may also be adopted.
S12: and establishing a shared memory block according to the acquired command and the set memory space.
The shared memory block can be established by calling a shmget command, the capacity of the shared memory block can be calculated according to the actual concurrency, the pid is 5 bits at most, and the file descriptor established by the socket is 5 bits at most. After the shared memory block with the size required by the test is established, the return value id of the shmlet is written into the global variable defined in the header file shm _ test.h.
S2: and adding identification information to the information to be sent of the client according to the number of the client servers, and acquiring the identified information to be sent.
There are two implementations of step S2 depending on the number of client servers. The first method is applicable to a case where the client has only 1 server, and specifically includes the following steps:
s201: and acquiring the pid of the current sub-process.
S202: and determining the shared memory block according to the ID of the shared memory block recorded in the header file.
S203: and writing the pid and the file descriptor of the current sub-process into the shared memory block.
S204: and splicing the pid of the current sub-process and the message to be sent, and acquiring the identified message to be sent.
As can be seen from the above steps S201 to S204, a getpid function is called to obtain a pid of a current sub-process, the pid may be used as a unique identifier of a process, after the pid is obtained, a shmat is called to be located in a shared memory block according to an id recorded in a shm _ test.h, a return value is addr, a file descriptor established by the sub-process pid and a socket is written into the shared memory block addr, and a combination of the pid and socket file descriptors may uniquely identify that a process has completed message transmission and waits for a response. And finally. And splicing the pid with the message content to be sent, and sending the pid to a server from the client server.
The second mode is suitable for the condition that the number of the client servers is more than or equal to 2, and specifically comprises the following processes:
s211: and acquiring the pid and the client server identification of the current sub-process.
S212: and determining the shared memory block according to the ID of the shared memory block recorded in the header file.
S213: and writing the pid, the client server identifier and the file descriptor of the current sub-process into the shared memory block.
S214: and splicing the pid of the current sub-process, the client server identifier and the message to be sent, and acquiring the message to be sent after the identifier.
The second mode is the same as the first mode in operation process, except that the obtained identification information includes not only the pid of the current sub-process but also the client server identification of the current sub-process, that is: and the combined information of MAC + machine code + IP. And finally, splicing the pid, the client server identification and the message content to be sent.
As can be seen from fig. 4, in this embodiment, after the identified message to be sent is obtained, step S3 is executed: and sending the identified information to be sent to a server.
S4: and the server-side server returns a response message to the server-side server according to the identified information to be sent, wherein the identification information is added in the response message.
After receiving the request message of the client server, the server acquires the pid from the request message, splices the pid with the message to be returned to the client server, and then returns the pid to the client server. Of course, if the client includes two or more servers, the server may also obtain the client server identifier from the request message.
S5: and the client server checks the response message according to the current subprocess information and the identification information until the check is correct.
Specifically, in this embodiment, a process of verifying the response message by the client server may be shown in fig. 5. As can be seen from fig. 5, step S5 includes the following processes:
s51: and after receiving the response message, the client server extracts the identification information according to the content of the response message, and defines the extracted identification information as first identification information.
When the client only has one server, the extracted first identification information is pid; when the client has 2 or more servers, the first identification information is the combined information of pid + client server MAC, client server machine code and client server IP.
S52: and determining the shared memory block according to the ID of the shared memory block recorded in the header file.
S53: and judging whether the first identification information is the same as the second identification information, wherein the second identification information is the identification information in the current sub-process information.
If the first identification information is not the same as the second identification information, go to step S54: and determining the attribution of the response message according to the first identification information, and sending the response message to the attribution.
Specifically, step S54 includes the following process:
s541: and determining the position of the first identification information in the shared memory block according to the acquired command.
S542: and intercepting the single block size content defined by the first identification information and the file descriptor to the memory array.
The information of pid, file descriptor, MAC, IP and machine code has fixed maximum length in the server, and the user can customize the information according to the user requirement. Such as: the maximum length of the first identification information and the file descriptor can be about 120 bits, and the length of 150 characters can be defined to meet the requirement. The memory array in this embodiment is equivalent to a temporary space with a user-defined size, which is created in the server memory by the programming language control device, and is used for storing data acquired from the shared memory block, where the data is used for judgment. When the process disappears, the zero temporary space is automatically released.
S543: and acquiring the file descriptor matched with the first identification information from the shared memory block.
S544: and sending the response message to the file descriptor matched with the first identification information.
If the first identification information is the same as the second identification information, step S55 is performed: and judging whether the file descriptor corresponding to the identification information of the shared memory block is consistent with the current sub-process file descriptor.
If the file descriptor corresponding to the identifier information of the shared memory block is consistent with the current sub-process file descriptor, execute step S56: it is determined that the message is not concatenated.
And if the file descriptor corresponding to the identification information of the shared memory block is not consistent with the current sub-process file descriptor, returning to the step S54, determining the owner of the response message according to the first identification information again, and sending the response message to the owner.
Taking the client as an example with only one server, it can be seen from the above steps S51-S56 that the client server extracts the pid according to the message content after receiving the response message. And then according to the id recorded in the shm _ test.h, calling a shmat function to locate to a shared memory block, wherein the return value is addr, calling a getpid function to compare whether the extracted pid is the same as the current process pid, if the pid comparison result is different, finding the position of the pid in the shared memory block addr according to a function strst, intercepting the single block size content defined by pid + file descriptor + MAC + machine code + IP into a memory array, acquiring the socket file descriptor corresponding to the pid from the shared memory, sending the received response message not belonging to the process to the acquired socket file descriptor, and continuing to suspend the recev to continue blocking the monitoring message. In this embodiment, the intercepted shared memory block is covered, so that it is possible to avoid occurrence of a corresponding error between the pid and the file descriptor after the pid is repeatedly used after the process is died, which is beneficial to improving the accuracy of data transmission.
If the pid comparison results are the same, the subsequent code logic is continued, i.e.: and comparing whether the socket file descriptor corresponding to the pid in the shared memory block is consistent with the current process file descriptor, if the socket file descriptor is consistent, indicating that the message is not in series connection, and if the communication transmission is normally finished, eliminating the communication subprocess of the client. If the comparison of the socket file descriptors is inconsistent, according to the method, the received response message send which does not belong to the process is sent to the socket file descriptor corresponding to the pid in the shared memory, and the recording function blocking monitoring is continuously suspended until the received response message comparison result is successful, and the client communication subprocess disappears.
Certainly, when a single client application deploys communication, that is, when the number of client servers is 1, the content combination of the local machine MAC + machine code + IP does not need to be stored and compared, and only the pid and the file descriptor need to be compared; when the multi-client application is deployed, the content combination of the native MAC + machine code + IP needs to be stored and compared. Therefore, when the multiple clients are deployed, the F5 hard load balancing hardware equipment is prevented from transmitting the response of the B client server to the A client server, and the accuracy of data transmission is improved.
The communication method of the embodiment can be realized by adopting C language and socket communication, and the improvement of the communication process mainly comprises the design of three executable files a, b and C and a shm _ test.h header file. Before pretesting, the client server calls an executable file c to establish a shared memory block; before sending information to a server side server, a client side server calls an executable file a for adding identification information to be sent of a client side and acquiring the identified information to be sent; after receiving the response message of the server side server, the client side server calls the executable file b for verifying the response message, receives the response message after the verification is successful, and otherwise, suspends the process and searches the owner of the current information again until the matching correct process is finished.
Example two
Referring to fig. 6 based on the embodiments shown in fig. 4 and fig. 5, fig. 6 is a schematic structural diagram of a communication system with high concurrency transmission between servers according to an embodiment of the present application. As shown in fig. 6, the communication system for high concurrency transmission between servers in this embodiment includes: the device comprises a shared memory block establishing module, an identification module, a sending module, a response module and a checking module.
The shared memory block establishing module is configured to establish a shared memory block, where the shared memory block is configured to store identification information and a file descriptor, and the identification information includes: pid and client server identification, the client server identification being: client server MAC, client server machine code, and client server IP. And the identification module is used for adding identification information to the information to be sent of the client according to the number of the client servers and acquiring the identified information to be sent. And the sending module is used for sending the information to be sent after the identification to the server side server. And the response module is used for returning a response message to the server according to the identified information to be sent, and the identification information is added in the response message. And the checking module is used for checking the response message according to the current subprocess information and the identification information until the checking is correct.
Further, the identification module in this embodiment has two structures according to the number of the client servers. The first identification module comprises: the device comprises a first subprocess acquisition unit, a shared memory block determination unit, a first write-in unit and a first splicing unit. The first sub-process obtaining unit is configured to obtain the pid of the current sub-process when the number of the client servers is 1. And a shared memory block determination unit, configured to determine the shared memory block according to the ID of the shared memory block recorded in the header file. And the first writing unit is used for writing the pid and the file descriptor of the current sub-process into the shared memory block. And the first splicing unit is used for splicing the pid of the current sub-process and the message to be sent, and acquiring the identified message to be sent.
The second identification module comprises: the second process obtaining unit, the shared memory block determining unit, the second writing unit and the second splicing unit. And the second process obtaining unit is used for obtaining the pid of the current sub-process and the client server identifier when the number of the client servers is more than or equal to 2. And a shared memory block determination unit, configured to determine the shared memory block according to the ID of the shared memory block recorded in the header file. And the second writing unit is used for writing the pid, the client server identifier and the file descriptor of the current sub-process into the shared memory block. And the second splicing unit is used for splicing the pid of the current sub-process, the client server identifier and the message to be sent, and acquiring the message to be sent after the identifier.
The verification module comprises: the device comprises an identification information extraction unit, a shared memory block determination unit, a first judgment unit, a response message sending unit and a second judgment unit. The identification information extracting unit is used for extracting the identification information according to the content of the response message after the client server receives the response message, and defining the extracted identification information as the first identification information. A shared memory block determination unit, configured to determine a shared memory block according to the ID of the shared memory block recorded in the header file; and the first judging unit is used for judging whether the first identification information is the same as second identification information, and the second identification information is identification information in the current sub-process information. And the response message sending unit is used for determining the attribution of the response message according to the first identification information when the first identification information is different from the second identification information, and sending the response message to the attribution. And the second judging unit is used for judging whether the file descriptor corresponding to the shared memory block identification information is consistent with the current subprocess file descriptor or not when the first identification information is the same as the second identification information, judging that the message is not in a string state if the file descriptor corresponding to the shared memory block identification information is consistent with the current subprocess file descriptor, and starting the response message sending unit if the message is not in a string state.
The working principle and working method of the communication system with high concurrent transmission between servers in this embodiment have been explained in detail in the embodiments shown in fig. 4 and fig. 5, and are not described herein again.
The above description is merely exemplary of the present application and is presented to enable those skilled in the art to understand and practice the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A communication method for high concurrency transmission between servers is characterized by comprising the following steps:
establishing a shared memory block, where the shared memory block is used to store identification information and a file descriptor, where the identification information includes: pid and client server identification, the client server identification being: the client server MAC, the client server machine code and the client server IP;
adding identification information to be sent of the client according to the number of the client servers, and acquiring the identified information to be sent;
sending the identified information to be sent to a server;
the server-side server returns a response message to the server-side server according to the identified information to be sent, wherein the identification information is added in the response message;
and the client server checks the response message according to the current sub-process information and the identification information until the check is correct.
2. The method according to claim 1, wherein the establishing the shared memory block comprises:
establishing a header file under a current directory of a client server, wherein the header file is used for recording the ID of a shared memory block;
and establishing a shared memory block according to the acquired command and the set memory space.
3. The communication method for high concurrency transmission between servers according to claim 1, wherein the adding identification information to the information to be sent of the client according to the number of the client servers and obtaining the identified information to be sent comprises:
when the number of the client servers is 1, acquiring the pid of the current sub-process;
determining the shared memory block according to the ID of the shared memory block recorded in the header file;
writing the pid of the current sub-process and the file descriptor into the shared memory block;
and splicing the pid of the current sub-process and the message to be sent, and acquiring the identified message to be sent.
4. The communication method for high concurrency transmission between servers according to claim 1, wherein the adding identification information to the information to be sent of the client according to the number of the client servers and obtaining the identified information to be sent comprises:
when the number of the client servers is more than or equal to 2, acquiring the pid of the current sub-process and the client server identification;
determining the shared memory block according to the ID of the shared memory block recorded in the header file;
writing the pid of the current sub-process, the client server identifier and the file descriptor into the shared memory block;
and splicing the pid of the current sub-process, the client server identifier and the message to be sent, and acquiring the message to be sent after the identifier.
5. The communication method for high concurrency transmission between servers according to claim 1, wherein the client server checks the response message according to the current sub-process information and the identification information until the check is correct, comprising:
after receiving the response message, the client server extracts identification information according to the content of the response message and defines the extracted identification information as first identification information;
determining the shared memory block according to the ID of the shared memory block recorded in the header file;
judging whether the first identification information is the same as second identification information, wherein the second identification information is identification information in the current sub-process information;
if the first identification information is different from the second identification information, determining an affiliate of the response message according to the first identification information, and sending the response message to the affiliate;
if the first identification information is the same as the second identification information, judging whether the file descriptor corresponding to the identification information of the shared memory block is consistent with the current sub-process file descriptor;
if the file descriptor corresponding to the shared memory block identification information is consistent with the current subprocess file descriptor, judging that the message is not in a string state;
and if the file descriptor corresponding to the identification information of the shared memory block is not consistent with the current subprocess file descriptor, determining the attribution of the response message again according to the first identification information, and sending the response message to the attribution.
6. The method according to claim 5, wherein the determining the owner of the response message according to the first identification information and sending the response message to the owner comprises:
determining the position of first identification information in the shared memory block according to the acquired command;
intercepting single block size content defined by the first identification information and the file descriptor to a memory array;
acquiring a file descriptor matched with first identification information from the shared memory block;
and sending the response message to the file descriptor matched with the first identification information.
7. A communication system for high concurrency transmission between servers, said system comprising:
a shared memory block establishing module, configured to establish a shared memory block, where the shared memory block is used to store identification information and a file descriptor, and the identification information includes: pid and client server identification, the client server identification being: the client server MAC, the client server machine code and the client server IP;
the identification module is used for adding identification information to the information to be sent of the client according to the number of the client servers and acquiring the identified information to be sent;
the sending module is used for sending the information to be sent after the identification to a server;
the response module is used for returning a response message to the server according to the identified information to be sent, and the identification information is added in the response message;
and the checking module is used for checking the response message according to the current subprocess information and the identification information until the checking is correct.
8. The communication system of claim 7, wherein the identification module comprises:
the first subprocess acquiring unit is used for acquiring the pid of the current subprocess when the number of the client servers is 1;
a shared memory block determination unit, configured to determine the shared memory block according to the ID of the shared memory block recorded in the header file;
a first writing unit, configured to write the pid of the current sub-process and the file descriptor into the shared memory block;
and the first splicing unit is used for splicing the pid of the current sub-process and the message to be sent, and acquiring the identified message to be sent.
9. The communication system of claim 7, wherein the identification module comprises:
the second process obtaining unit is used for obtaining the pid of the current sub-process and the client server identification when the number of the client servers is more than or equal to 2;
a shared memory block determination unit, configured to determine the shared memory block according to the ID of the shared memory block recorded in the header file;
a second writing unit, configured to write the pid of the current sub-process, the client server identifier, and the file descriptor into the shared memory block;
and the second splicing unit is used for splicing the pid of the current sub-process, the client server identifier and the message to be sent, and acquiring the message to be sent after the identifier.
10. The communication system for high concurrency transmission between servers as claimed in any one of claims 7 to 9, wherein said checking module comprises:
the identification information extraction unit is used for extracting identification information according to the content of the response message after the client server receives the response message, and defining the extracted identification information as first identification information;
a shared memory block determination unit, configured to determine the shared memory block according to the ID of the shared memory block recorded in the header file;
the first judging unit is used for judging whether the first identification information is the same as second identification information, and the second identification information is identification information in the current sub-process information;
a response message sending unit, configured to determine, according to the first identification information, an affiliate of the response message when the first identification information is different from the second identification information, and send the response message to the affiliate;
and the second judging unit is used for judging whether the file descriptor corresponding to the shared memory block identification information is consistent with the current subprocess file descriptor or not when the first identification information is the same as the second identification information, judging that the message is not in a string state if the file descriptor corresponding to the shared memory block identification information is consistent with the current subprocess file descriptor, and starting the response message sending unit if the message is not in a string state.
CN202010174803.4A 2020-03-13 2020-03-13 Communication method and system for high-concurrency transmission between servers Active CN111400063B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010174803.4A CN111400063B (en) 2020-03-13 2020-03-13 Communication method and system for high-concurrency transmission between servers

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010174803.4A CN111400063B (en) 2020-03-13 2020-03-13 Communication method and system for high-concurrency transmission between servers

Publications (2)

Publication Number Publication Date
CN111400063A true CN111400063A (en) 2020-07-10
CN111400063B CN111400063B (en) 2022-05-31

Family

ID=71430774

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010174803.4A Active CN111400063B (en) 2020-03-13 2020-03-13 Communication method and system for high-concurrency transmission between servers

Country Status (1)

Country Link
CN (1) CN111400063B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112948437A (en) * 2021-03-03 2021-06-11 苏州合数科技有限公司 Big data high-concurrency down-global frequency control system and method
CN113297211A (en) * 2021-03-03 2021-08-24 苏州合数科技有限公司 Big data high-concurrency crowd portrait storage and orientation system and method
CN113347151A (en) * 2021-04-28 2021-09-03 厦门海迈科技股份有限公司 Data interaction method based on socket shared memory

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102340489A (en) * 2010-07-20 2012-02-01 阿里巴巴集团控股有限公司 Data transmission method between servers and servers
CN106790348A (en) * 2016-11-11 2017-05-31 北京百卓网络技术有限公司 The files passe and method for down loading and system of distributed system
CN109309730A (en) * 2018-10-31 2019-02-05 北京国信宏数科技有限责任公司 A kind of believable document transmission method and system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102340489A (en) * 2010-07-20 2012-02-01 阿里巴巴集团控股有限公司 Data transmission method between servers and servers
CN106790348A (en) * 2016-11-11 2017-05-31 北京百卓网络技术有限公司 The files passe and method for down loading and system of distributed system
CN109309730A (en) * 2018-10-31 2019-02-05 北京国信宏数科技有限责任公司 A kind of believable document transmission method and system

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112948437A (en) * 2021-03-03 2021-06-11 苏州合数科技有限公司 Big data high-concurrency down-global frequency control system and method
CN113297211A (en) * 2021-03-03 2021-08-24 苏州合数科技有限公司 Big data high-concurrency crowd portrait storage and orientation system and method
CN112948437B (en) * 2021-03-03 2023-12-19 苏州合数科技有限公司 Global frequency control system and method under high concurrency of big data
CN113297211B (en) * 2021-03-03 2023-12-22 苏州合数科技有限公司 Crowd portrait storage and orientation system and method under high concurrency of big data
CN113347151A (en) * 2021-04-28 2021-09-03 厦门海迈科技股份有限公司 Data interaction method based on socket shared memory
CN113347151B (en) * 2021-04-28 2023-04-28 厦门海迈科技股份有限公司 Data interaction method based on socket shared memory

Also Published As

Publication number Publication date
CN111400063B (en) 2022-05-31

Similar Documents

Publication Publication Date Title
CN111400063B (en) Communication method and system for high-concurrency transmission between servers
CN110719199B (en) Network automatic testing and fault positioning method and device
CN105260318A (en) Automatic testing method and device based on web pages
CN110989922B (en) Distributed data storage method and system
CN106547658B (en) Automatic testing method and device
CN111711533B (en) Fault diagnosis method, fault diagnosis device, electronic device and storage medium
CN111447245A (en) Authentication method, authentication device, electronic equipment and server
CN111400246B (en) Asynchronous file import method, device, computer equipment and storage medium
CN113315943A (en) Conference information transmission method, system, computer equipment and storage medium
CN113608692A (en) Method, system, equipment and medium for verifying data consistency of storage system
CN113076251A (en) Test method and device
CN112383402A (en) Dual idempotent verification method and server
CN108900337B (en) Fault recovery method, server, client and system for metadata service
CN112631839A (en) Method, device and equipment for realizing data backup
CN113271337B (en) Method and device for subscribing computer message
CN113810463B (en) Method and system for configuring delivery CDN server
EP4344259A1 (en) Session binding relationship processing method and apparatus, electronic device, and readable medium
CN113472850B (en) Link data acquisition method, device, system, electronic equipment and storage medium
CN111130941B (en) Network error detection method and device and computer readable storage medium
US10742802B2 (en) Methods and devices for verifying a communication number
CN114491653A (en) Data content tamper-proof system, method and device
US10268418B1 (en) Accessing multiple data snapshots via one access point
CN111597477A (en) Cache cluster optimization method, equipment and storage medium
CN108768673B (en) Method and device for ending charging
CN114900339B (en) Intrusion detection method, intrusion detection system, intrusion detection equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant