Embodiment
Hereinafter will and combine embodiment to specify the present invention with reference to accompanying drawing.Need to prove that under the situation of not conflicting, embodiment and the characteristic among the embodiment among the application can make up each other.
The flow chart of the communication means of the many instances that provide for preferred embodiment according to the present invention shown in Figure 1.As shown in Figure 1, the communication means of many instances that preferred embodiment of the present invention provides comprises step 101 ~ 103.
Step 101: server initialization network layer instance and Business Logic instance.
Particularly, the mode of said server initialization network layer instance is that behind network layer default instance of said startup of server, said network layer default instance is the next network layer instance (" instantiation " i.e. be " establishment ") of instantiation successively.Detailed process is that behind second network layer instance of network layer default instance instantiation, by the 3rd network layer instance of second network layer examples Exampleization, and the rest may be inferred.The mode of perhaps said server initialization network layer instance is that said server directly starts a network layer default instance and a plurality of network layer instance.
The mode of said server initialization Business Logic instance is that said server is created a plurality of Business Logic example set, and the corresponding one or more said Business Logic example set of a kind of instruction.
Step 102: the network layer default instance of said server receives the connection request that said client is sent; And notify said client with self active user's bearing capacity, said client is confirmed objective network layer instance according to preset strategy and is connected with said objective network layer instance.
Particularly, when server received the connection request that client sends, the network layer default instance of said server was notified said client with self largest user bearing capacity.If the mode of said server initialization network layer instance does, starts a network layer default instance after, said network layer default instance is instantiation next one network layer instance successively.Said preset strategy does; Said client judges whether said network layer default instance active user bearing capacity reaches the largest user bearing capacity; If; After then said client is notified the next network layer instance of said network layer default instance instantiation; Said network layer default instance is the network layer instance objects of said instantiation notice client, and said client resends connection request and gives the said network layer instance of instantiation and connect, and said client is broken off the connection request with said network layer default instance; If not, said client directly connects with said network layer default instance.In this, said network layer instance objects comprises said network layer instance title, address and port numbers.
If the mode of said server initialization network layer instance does; Directly start a network layer default instance and a plurality of network layer instance; Said preset strategy does; Said client judges whether user's bearing capacity of said network layer default instance reaches the largest user bearing capacity, if said client notifies the said network layer default instance network layer instance objects that idleness is higher to send to client.Detailed process does, after said server receives the client notice, by said a plurality of network layer example calculation self idleness and send to the network layer default instance, the network layer instance objects notice client that said network layer default instance is higher with idleness.Said client resends connection request and gives the higher network layer instance of said idleness and establish a communications link, and said client is broken off the connection request with said network layer default instance.If user's bearing capacity of said network layer default instance does not reach the largest user bearing capacity, said client directly connects with said network layer default instance.
Step 103: said server receives the instruction that client is sent; And return the idleness of said Business Logic instance to said client, said client according to the idleness of the corresponding relation of instruction and Business Logic example set and Business Logic instance with said command assignment to corresponding service logical layer instance.
Particularly, in step 101, server has been created a plurality of Business Logic example set, and the corresponding one or more said Business Logic example set of a kind of instruction.After client and server connect, said server will instruct the corresponding relation with the Business Logic example set to send to client and by said client stores.If only corresponding Business Logic example set of a kind of instruction; Client is sent the instruction of carrying said Business Logic example set title after finding said Business Logic example set according to the instruction and the corresponding relation of Business Logic example set to said server.The said instruction of said server parses also finds corresponding service logical layer example set; Business Logic example calculation self idleness and notify said Business Logic example set in the said Business Logic example set; Said Business Logic example set sends to said client with each Business Logic instance idleness, and said client is selected the higher said instruction of Business Logic instance processes of idleness.In present embodiment, the Business Logic instance is directly notified said client after also can calculating self idleness in the said Business Logic example set, and this present invention is not limited.
If the corresponding a plurality of Business Logic example set of a kind of instruction; Client is sent the instruction of carrying said Business Logic example set title after finding a plurality of Business Logic example set according to the corresponding relation of self instructions stored and Business Logic example set to said server.The said instruction of said server parses also finds corresponding a plurality of Business Logic example set; Said a plurality of Business Logic example set calculating self idleness is also notified said client; Said client is selected the higher said instruction of Business Logic instance processes of idleness in the said Business Logic example set after selecting the higher Business Logic example set of idleness.Said client selects the process of the said instruction of Business Logic instance processes similar to the above embodiments, so repeat no more in this.
Wherein, the computational methods of said single instance idleness do, the difference of the largest user bearing capacity of single instance and the current carrying customer volume of said instance, and divided by the largest user bearing capacity of said single instance, the gained merchant is said single instance idleness again.The computational methods of single instance group idleness do; The difference of the largest user bearing capacity summation of all instances and the current carrying customer volume of said all instances summation in the said example set; Said difference is divided by the largest user bearing capacity summation of all instances in the said example set, and the gained merchant is said single instance group idleness.
For example, only start a network layer default instance during as if server initialization network layer instance, and the largest user bearing capacity of said network layer default instance is 50.If a certain moment, said network layer default instance receives behind the connection request that client sends self largest user bearing capacity and active user's bearing capacity notice client.If client judges that said network layer default instance active user bearing capacity has reached 50, and this moment, the network layer default instance did not also have other network layer instance of instantiation.Client is notified network layer instance of said network layer default instance instantiation (promptly; The network layer instance a); And said network layer default instance is with the object notice client of said network layer instance a, and client is sent according to said object and asked to give network layer instance a and connect.
In this, if server is created a plurality of Business Logic example set, and the corresponding Business Logic example set of a kind of instruction.If each Business Logic example set and instruction corresponding relation of client stores is as shown in table 1.
Business Logic example set title |
Comprise instance |
Instruction type |
Business Logic example set 1 |
Business Logic instance 11,12,13 |
Login、Logout |
Business Logic example set 2 |
Business Logic instance 21,22,23 |
AcceptFriend |
Business Logic example set 3 |
Business Logic instance 31,32 |
Text |
Business Logic example set 4 |
Business Logic instance 41,42,43 |
group |
Table 1
If client needs to send the Text instruction to server, said client finds Text according to table 1 and instructs corresponding Business Logic example set 3, and sends the Text that carries Business Logic example set 3 titles and instruct server.Find Business Logic example set 3 after the server parses Text instruction, if Business Logic instance 31, the 32 largest user bearing capacities that Business Logic example set 3 comprises are 100, and this moment, both user's bearing capacities were respectively 35 and 55.Then Business Logic instance 31 calculating self idleness is (100-35)/100=0.65, and Business Logic instance 32 calculating self idleness is (100-55)/100=0.45.Business Logic example set 3 sends to client with the idleness of the Business Logic instance that receives 31,32, and said client selects the higher Business Logic instance of idleness 31 to handle said Text instruction.
On the other hand, if server is created a plurality of Business Logic example set, and the corresponding a plurality of Business Logic example set of a kind of instruction.If each Business Logic example set and instruction corresponding relation of client stores is as shown in table 2.
Table 2
If client needs to send the AcceptFriend instruction to server; Said client finds AcceptFriend according to table 2 and instructs corresponding Business Logic example set B and D; And send the AcceptFriend carry Business Logic example set B and D title and instruct server, find Business Logic example set B and D after the server parses AcceptFriend instruction.If the Business Logic instance largest user bearing capacity summation that Business Logic example set B comprises is 1000; The Business Logic instance largest user bearing capacity summation that Business Logic example set D comprises also is 1000; And the current carrying customer volume summation of all Business Logic instances is 280 among the Business Logic example set B at this moment, and the current carrying customer volume summation of all Business Logic instances is 600 among the Business Logic example set D.Then the idleness of Business Logic example set B is (1000-280)/1000=0.72, and the idleness of Business Logic example set D is (1000-600)/1000=0.4.Client is selected the higher Business Logic example set B of idleness after receiving the idleness of Business Logic example set B and D transmission.Client is notified among the said Business Logic example set B each Business Logic example calculation and is returned self idleness; Wherein each Business Logic example calculation mode is identical among the mode of each Business Logic example calculation self idleness and the last embodiment, so repeat no more in this.Said client is selected the higher said AcceptFriend instruction of Business Logic instance processes of idleness among the Business Logic example set B.In the foregoing description, a plurality of said instances or example set idleness are the highest and equal as if having, and then select one of them instance or example set at random, and this present invention is not limited.
The flow chart of the communication means of the many instances that provide for another preferred embodiment according to the present invention shown in Figure 2.As shown in Figure 2, the communication means of many instances that another preferred embodiment of the present invention provides comprises step 201 ~ 203.
Step 201: server initialization network layer instance and Business Logic instance.
The concrete operations flow process of this step is identical with step 101, so repeat no more in this.
Step 202: when client when said server sends connection request, said server is confirmed objective network layer instance according to preset strategy, said objective network layer instance and said client establish a communications link.
Particularly, if the mode of said server initialization network layer instance does, starts a network layer default instance after, said network layer default instance is instantiation next one network layer instance successively.Said preset strategy does; When client when said server sends connection request; Said network layer default instance receives said connection request; And judge whether self active user's bearing capacity reaches the largest user bearing capacity, if said active user's bearing capacity does not reach the largest user bearing capacity, then said network layer default instance directly connects with said client.If said active user's bearing capacity reaches the largest user bearing capacity; The next network layer instance of then said network layer default instance instantiation; And with the network layer instance objects of said instantiation notice client; Said client resends connection request according to said object and gives said network layer instance, and said network layer instance is set up and is connected with the communication of said client, and said client is broken off and the connection request of said network layer default instance.If the mode of said server initialization network layer instance does; Directly start a network layer default instance and a plurality of network layer instance, said preset strategy does, when client when said server sends connection request; Said network layer default instance receives said connection request; And judge whether self active user's bearing capacity reaches the largest user bearing capacity, if said active user's bearing capacity does not reach the largest user bearing capacity, then said network layer default instance directly connects with said client; If said active user's bearing capacity reaches the largest user bearing capacity; Said network layer default instance sends notice and gives said a plurality of network layer instances, and said a plurality of network layer example calculation self idleness also sends to the network layer default instance, and said network layer default instance is selected the higher network layer instance of idleness; And with the network layer instance objects of said selection notice client; Said client resends connection request according to said object and gives said network layer instance, and said network layer instance is set up and is connected with the communication of said client, and said client is broken off and the connection request of said network layer default instance.
For example, if the mode of server initialization network layer instance is directly start a network layer default instance and a plurality of network layer instance (for example comprising network layer instance m and n), and the largest user bearing capacity of said network layer default instance to be 50.If a certain moment, after said network layer default instance receives the connection request that client sends, judge that self user's bearing capacity has reached 50, then said network layer default instance sends notice and gives said network layer instance m and n.If network layer instance m calculating self idleness is 0.2, network layer instance n calculating self idleness is 0.5.The network layer default instance is selected the higher network layer instance n of idleness after receiving the idleness of network layer instance m and n transmission, and notifies client with the object of said network layer instance n.Client is sent according to said object and is asked to give network layer instance n and connect.In present embodiment, said network layer instance objects comprises said network layer instance title, address and port numbers, in other embodiment, can according to the actual requirements said contents of object be added or delete, and this present invention is not limited.
Step 203: said server receives the instruction that client is sent; And return the idleness of said Business Logic instance to said client, said client according to the idleness of the corresponding relation of instruction and Business Logic example set and Business Logic instance with said command assignment to corresponding service logical layer instance.
The concrete operations flow process of this step is identical with step 103, so repeat no more in this.
The sketch map of the communication system of the many instances that provide for preferred embodiment according to the present invention shown in Figure 3.As shown in Figure 3, the communication system of many instances that preferred embodiment of the present invention provides comprises client 301 and server 302, and said client 301 connects said server 302.Said client 301 is used for sending connection request and instructions to said server 302, and confirms objective network layer instance and connect with said objective network layer instance according to preset strategy; After also being used for idleness that reception server 302 returns said Business Logic instance, according to the idleness of the corresponding relation of instruction and Business Logic example set and Business Logic instance with said command assignment to corresponding service logical layer instance.Said server 302 is used for initialization network layer instance and Business Logic instance, also is used to receive behind the connection request that said client 301 sends to notify said client 301 with active user's bearing capacity of self network layer default instance.Operating process about said system is said with above-mentioned method, so repeat no more in this.
In sum; Communication means and system according to many instances provided by the invention; Behind server initialization network layer instance and the Business Logic instance; The network layer default instance of server receives the connection request of client transmission and with self active user's bearing capacity notice client, client is confirmed objective network layer instance according to preset strategy and connected with said objective network layer instance, fully improved the resource utilization of network layer instance.Server receives instruction that client sends and returns the idleness of said Business Logic instance to said client, client according to the idleness of the corresponding relation of instruction and Business Logic example set and Business Logic instance with said command assignment to corresponding service logical layer instance.So, carry out Business Processing, saved resource overhead by many instances.
The above is merely the preferred embodiments of the present invention, is not limited to the present invention, and for a person skilled in the art, the present invention can have various changes and variation.All within spirit of the present invention and principle, any modification of being done, be equal to replacement, improvement etc., all should be included within protection scope of the present invention.