CN105630616A - High-concurrency connection achieving method and device - Google Patents
High-concurrency connection achieving method and device Download PDFInfo
- Publication number
- CN105630616A CN105630616A CN201511000789.1A CN201511000789A CN105630616A CN 105630616 A CN105630616 A CN 105630616A CN 201511000789 A CN201511000789 A CN 201511000789A CN 105630616 A CN105630616 A CN 105630616A
- Authority
- CN
- China
- Prior art keywords
- server
- function
- client terminal
- server group
- group
- 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.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/547—Remote procedure calls [RPC]; Web services
- G06F9/548—Object oriented; Remote method invocation [RMI]
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer And Data Communications (AREA)
Abstract
The invention provides a high-concurrency connection achieving method and device. According to the high-concurrency connection achieving method and device, a client-side transfers a function to a server, the client-side can also process other events rather than waiting for a processing result of the server before the server executes the function, and the client-side calls back the function and continues to process the function after the server executes the function, namely asynchronous processing is achieved. The high-concurrency connection between the client-side and the server can be achieved through asynchronous processing.
Description
Technical field
The application relates to computer technology, in particular to the concurrent connection implementation method of height and device.
Background technology
At present, in this speech like sound of Java and PHP, each connection can generate a new thread, each new thread may need the supporting internal memory of 2MB, based on this, have the system of 8GBRAM for one, then maximum in theory concurrent connection number amount is 4000 users. But, along with the growth of customers, if wishing that Web application program supports more users, then more servers just must be added, this can increase the costs such as server cost, flow cost and cost of labor.
Except these cost increase, also having a potential technology problem, namely user may use different servers for each request, and therefore, any sharing resources all must be shared between Servers-all.
Summary of the invention
This application provides high concurrent connection implementation method and device, to realize high concurrent connection, preventing can only by adding the technological deficiency that more servers etc. bring when client increases.
The technical scheme that the application provides comprises:
A kind of high concurrent connection implementation method, comprising:
Client terminal is connected to server group by Common Gateway cmngate; Comprising two or more server in server group, the server in described server group is set up based on Node.js;
The server that client terminal utilizes literal translation formula script language JavaScript to adjust back in the mode of function and server group realizes asynchronous I/O I/O.
A kind of high concurrent connection implement device, comprising:
Connect module, for connecting the clients to server group by Common Gateway cmngate; Comprising two or more server in server group, the server in described server group is set up based on Node.js;
Input/output module, makes the server in client terminal and server group realize asynchronous I/O I/O for the mode utilizing literal translation formula script language JavaScript to adjust back function.
As can be seen from the above technical solutions, in the present invention, client terminal function passes to after server, and before server executes this function, client terminal still can process other events, the not result of only waiting for server, and when server executes function, client terminal adjusts back this function, continues the process of this function, namely achieves asynchronous process. By this asynchronous process, it is possible to what realize between client terminal with server high concurrent is connected.
Accompanying drawing explanation
Fig. 1 is method flow diagram provided by the invention;
Fig. 2 is example structure figure provided by the invention;
Fig. 3 is apparatus structure schematic diagram provided by the invention.
Embodiment
In order to make the object, technical solutions and advantages of the present invention clearly, describe the present invention below in conjunction with the drawings and specific embodiments.
In method provided by the invention, it is possible to realize high concurrent connection, this can be avoided can only by adding the technological deficiency that more servers etc. bring when client increases in background technology.
Below by Fig. 1, method provided by the invention is described:
It is method flow diagram provided by the invention see Fig. 1, Fig. 1. As shown in Figure 1, this flow process can comprise the following steps:
Step 101, client terminal is connected to server group by Common Gateway (cmngate), comprises two or more server in server group, and the server in server group is set up based on Node.js.
Node is a server end JavaScript interpreter, the concept how change server should be worked by it, its target is the application program that helper person builds telescopic in height, writes and can process the connection code that tens thousand of are connected to (only one) physical machine simultaneously.
The advantage of Node.js has:
1), adopt event-driven, Asynchronous Programming, design for network service.
2), the I/O of Node.js unblock pattern process and bring the high-performance under relatively low system resource consumes and outstanding carrying capacity to Node.js, be suitable as very much the middle layer relying on other I/O resource and serve.
3), Node.js light weight is efficient, it is possible to think the perfect solution of the real-time application system under data-intensive distributed deployment environment. Node is applicable to following situation very much: before customer in response end, it is contemplated that may have very high flow, but required server end logic and process are not necessarily a lot.
Server in the present invention is set up based on Node.js, then the server after setting up can realize the above-mentioned advantage of Node.js.
Step 102, the server that client terminal utilizes JavaScript to adjust back in the mode of function and server group realizes asynchronous I/O (I/O).
In the present invention, as a preferred embodiment, the server that client terminal utilizes JavaScript to adjust back in the mode of function and server group realizes asynchronous (I/O) and comprising:
Step a1, the function that I/O is associated by client terminal as parameter by I/O request forwarding to the server in server group.
By step a1, it is achieved that the transmission of function.
Step a2, server receives the function performing described I/O when described I/O asks and asking to carry, client terminal performs described I/O at described server asks to continue during the function carried to perform other process, and adjusts back this function when described server executes described function.
Also namely, in the present invention, client terminal is function passes to after server, and before server executes this function, client terminal still can process other events, not the result of only waiting for server. And when server executes function, client terminal adjusts back this function, continue the process of this function, namely achieve asynchronous process. By this asynchronous process, it is possible to what realize between client terminal with server high concurrent is connected.
Flow process shown in Fig. 1 is described for an embodiment below by Fig. 2:
In fig. 2, for two client terminals, these two client terminals are designated as: client1, client2. As shown in Figure 2, client1, client2 are all connected to server group by cmngate. In fig. 2, client1, client2 are connected, with each of server group, the event launching an operation in the process of Node engine, to trigger, client terminal is follow-up adjusts back function based on event-driven, instead of for each connects generation new OS thread (and for its distribute some supporting internal memories).
In fig. 2, server group has multiple logical server (logisSvr), each logisSvr sets up based on Node.js, it is possible to as the server of the game server of simple web server, weak networking, HTTP server or other functions.
Fig. 2 is for the logisSvr in server group as HTTP server. The citing of following code describes the foundation of HTTP server:
Varhttp=require (" http ");
http.createServer(function(request,response){
Response.writeHead (200, { " Content-Type ": " text/plain " });
Response.write (" HelloWorld ");
Response.end ();
) .listen (8888);
In above-mentioned code, define function createServer, when calling this function createServer, createServer function can return an object, this object has a method being called listen, this method has a numerical parameter, specifies port numbers 8888 port that this HTTP server is monitored.
When client terminal needs to perform I/O, for the client1 Request routing shown in Fig. 2, then:
Route function is carried in route requests as parameter by client1, by the connection of client1 and server group, route requests is sent to server group;
Arbitrary logisSvr in server group processes according to this route requests after receiving route requests, and the Optimization route finally determined for route function is recorded in route function;
After client1 transmission route requests is to server group, client1 may also have other to process, such as URL request etc., in order to not block other process, then client1 is after transmission route requests is to server group, it is possible to continue to perform other process, and when the logisSvr in server group determines Optimization route, call this Optimization route, this achieve the process of asynchronous event.
So far, complete the embodiment shown in Fig. 2 to describe.
Above method provided by the invention is described.
Below device provided by the invention is described:
It is structure drawing of device provided by the invention see Fig. 3, Fig. 3. As shown in Figure 3, this device comprises:
Connect module, for connecting the clients to server group by Common Gateway cmngate; Comprising two or more server in server group, the server in described server group is set up based on Node.js;
Input/output module, makes the server in client terminal and server group realize asynchronous I/O I/O for the mode utilizing literal translation formula script language JavaScript to adjust back function.
Preferably, the mode that described input/output module utilizes literal translation formula script language JavaScript to adjust back function makes the server in client terminal and server group realize asynchronous I/O I/O to comprise:
The function being associated by I/O is carried at during I/O asks as parameter and passes to the server server group from client terminal, so that receiving the function performing described I/O when described I/O asks and asking to carry;
Control client terminal performs described I/O at described server asks to continue during the function carried to perform other process, and triggers client terminal when described server executes described function and adjust back this function.
Preferably, the server in described server group comprises the server of web server, game server, HTTP server or other functions.
Preferably, described client terminal connects, to each of server group, the event launching an operation in the process of Node engine, and to trigger, client terminal is follow-up adjusts back function based on event-driven.
So far, complete the unit describe shown in Fig. 3.
The foregoing is only the better embodiment of the present invention, not in order to limit the present invention, within the spirit and principles in the present invention all, any amendment of making, equivalent replacement, improvement etc., all should be included within the scope of protection of the invention.
Claims (8)
1. one kind high concurrent connection implementation method, it is characterised in that, the method comprises:
Client terminal is connected to server group by Common Gateway cmngate; Comprising two or more server in server group, the server in described server group is set up based on Node.js;
The server that client terminal utilizes literal translation formula script language JavaScript to adjust back in the mode of function and server group realizes asynchronous I/O I/O.
2. method according to claim 1, it is characterised in that, the server that described client terminal utilizes literal translation formula script language javascript to adjust back in the mode of function and server group realizes asynchronous I/O I/O and comprises:
The function that I/O is associated by client terminal as parameter by I/O request forwarding to the server in server group;
Server receives the function performing described I/O when described I/O asks and asking to carry;
Client terminal performs described I/O at described server asks to continue during the function carried to perform other process, and adjusts back this function when described server executes described function.
3. method according to claim 1, it is characterised in that, the server in described server group comprises the server of web server, game server, HTTP server or other functions.
4. method according to claim 1, it is characterised in that, described client terminal connects, to each of server group, the event launching an operation in the process of Node engine, and to trigger, client terminal is follow-up adjusts back function based on event-driven.
5. one kind high concurrent connection implement device, it is characterised in that, this device comprises:
Connect module, for connecting the clients to server group by Common Gateway cmngate; Comprising two or more server in server group, the server in described server group is set up based on Node.js;
Input/output module, makes the server in client terminal and server group realize asynchronous I/O I/O for the mode utilizing literal translation formula script language JavaScript to adjust back function.
6. device according to claim 5, it is characterised in that, the mode that described input/output module utilizes literal translation formula script language JavaScript to adjust back function makes the server in client terminal and server group realize asynchronous I/O I/O to comprise:
The function being associated by I/O is carried at during I/O asks as parameter and passes to the server server group from client terminal, so that receiving the function performing described I/O when described I/O asks and asking to carry;
Control client terminal performs described I/O at described server asks to continue during the function carried to perform other process, and triggers client terminal when described server executes described function and adjust back this function.
7. device according to claim 5, it is characterised in that, the server in described server group comprises the server of web server, game server, HTTP server or other functions.
8. method according to claim 5, it is characterised in that, described client terminal connects, to each of server group, the event launching an operation in the process of Node engine, and to trigger, client terminal is follow-up adjusts back function based on event-driven.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201511000789.1A CN105630616A (en) | 2015-12-28 | 2015-12-28 | High-concurrency connection achieving method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201511000789.1A CN105630616A (en) | 2015-12-28 | 2015-12-28 | High-concurrency connection achieving method and device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN105630616A true CN105630616A (en) | 2016-06-01 |
Family
ID=56045593
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201511000789.1A Pending CN105630616A (en) | 2015-12-28 | 2015-12-28 | High-concurrency connection achieving method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN105630616A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106484548A (en) * | 2016-10-20 | 2017-03-08 | 济南浪潮高新科技投资发展有限公司 | A kind of choreography request response processing method based on asynchronism callback mechanism |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102130953A (en) * | 2011-03-16 | 2011-07-20 | 迈普通信技术股份有限公司 | Embedded web system and interactive method |
CN103902319A (en) * | 2012-12-30 | 2014-07-02 | 青岛海尔软件有限公司 | Hot deployment method based on server-side javascript |
CN104991823A (en) * | 2015-07-02 | 2015-10-21 | 北京京东尚科信息技术有限公司 | Method and device for realizing Javascript multitask mechanism |
-
2015
- 2015-12-28 CN CN201511000789.1A patent/CN105630616A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102130953A (en) * | 2011-03-16 | 2011-07-20 | 迈普通信技术股份有限公司 | Embedded web system and interactive method |
CN103902319A (en) * | 2012-12-30 | 2014-07-02 | 青岛海尔软件有限公司 | Hot deployment method based on server-side javascript |
CN104991823A (en) * | 2015-07-02 | 2015-10-21 | 北京京东尚科信息技术有限公司 | Method and device for realizing Javascript multitask mechanism |
Non-Patent Citations (1)
Title |
---|
王金龙,宋斌,丁锐: "Node.js:一种新的Web应用构建技术", 《现代电子技术》 * |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106484548A (en) * | 2016-10-20 | 2017-03-08 | 济南浪潮高新科技投资发展有限公司 | A kind of choreography request response processing method based on asynchronism callback mechanism |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN113300985B (en) | Data processing method, device, equipment and storage medium | |
CN106657394B (en) | Equipment information acquisition system and method based on Internet of things big data | |
CN113596110B (en) | Cloud primary micro-service platform oriented to heterogeneous cloud | |
CN110633442A (en) | Pushing method and device and electronic equipment | |
CN103379184B (en) | The method and system of Network access | |
CN102624926B (en) | The method and system that ability polymerization is open | |
CN104618164A (en) | Management method for rapid cloud computing platform application deployment | |
Da et al. | Kalimucho: middleware for mobile applications | |
CN103795569A (en) | Server connection method and device based on connection pool | |
CN107689878A (en) | TCP length connection SiteServer LBSs based on name scheduling | |
CN105554085B (en) | A kind of dynamic timeout treatment method and apparatus based on server connection | |
CN111629016A (en) | Control method, device and system | |
CN111770176A (en) | Traffic scheduling method and device | |
CN108259605B (en) | Data calling system and method based on multiple data centers | |
CN111343251A (en) | Message queue service deployment method and device | |
JP6933184B2 (en) | Communication system and bandwidth control method | |
CN111831503A (en) | Monitoring method based on monitoring agent and monitoring agent device | |
CN105630616A (en) | High-concurrency connection achieving method and device | |
CN114168312A (en) | Distributed cluster load balancing method and device and storage medium | |
CN111064666A (en) | Networking method and device | |
CN107508760B (en) | Method for load distribution based on line source IP | |
CN111147389A (en) | TCP long connection server load balancing system and method | |
CN103152428A (en) | Method for carrying out service communication among nodes on cloud platform | |
CN111147603A (en) | Method and device for networking reasoning service | |
CN106227592A (en) | Task call method and task call device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20160601 |
|
RJ01 | Rejection of invention patent application after publication |