CN112506647A - Method, system, device and storage medium for load balancing of stateful servers - Google Patents
Method, system, device and storage medium for load balancing of stateful servers Download PDFInfo
- Publication number
- CN112506647A CN112506647A CN202011301122.6A CN202011301122A CN112506647A CN 112506647 A CN112506647 A CN 112506647A CN 202011301122 A CN202011301122 A CN 202011301122A CN 112506647 A CN112506647 A CN 112506647A
- Authority
- CN
- China
- Prior art keywords
- server
- game
- redis
- game resource
- idle
- 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
- 238000000034 method Methods 0.000 title claims abstract description 49
- 238000004590 computer program Methods 0.000 claims description 16
- 238000012545 processing Methods 0.000 claims description 5
- 238000010586 diagram Methods 0.000 description 14
- 230000026676 system process Effects 0.000 description 4
- 241000412611 Consul Species 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 2
- 230000005540 biological transmission Effects 0.000 description 2
- 238000004422 calculation algorithm Methods 0.000 description 2
- 102220229125 rs563306322 Human genes 0.000 description 2
- 230000001360 synchronised effect Effects 0.000 description 2
- 238000013461 design Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000002688 persistence Effects 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
Images
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/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5083—Techniques for rebalancing the load in a distributed system
-
- A—HUMAN NECESSITIES
- A63—SPORTS; GAMES; AMUSEMENTS
- A63F—CARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
- A63F13/00—Video games, i.e. games using an electronically generated display having two or more dimensions
- A63F13/30—Interconnection arrangements between game servers and game devices; Interconnection arrangements between game devices; Interconnection arrangements between game servers
- A63F13/35—Details of game servers
- A63F13/352—Details of game servers involving special game server arrangements, e.g. regional servers connected to a national server or a plurality of servers managing partitions of the game world
-
- 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/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5027—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
-
- A—HUMAN NECESSITIES
- A63—SPORTS; GAMES; AMUSEMENTS
- A63F—CARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
- A63F2300/00—Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game
- A63F2300/50—Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game characterized by details of game servers
- A63F2300/53—Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game characterized by details of game servers details of basic data processing
- A63F2300/531—Server assignment
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Multimedia (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Hardware Redundancy (AREA)
Abstract
The application relates to a method, a system, a device and a storage medium for load balancing of a stateful server, wherein the method for load balancing of the stateful server comprises the following steps: the method comprises the steps of obtaining an idle server in a back-end server, wherein the idle server is a first server, distributing game resources to the first server through a setex instruction of the redis, then connecting the game resources to the first server for service, continuing the first server through the binding relationship between the redis and the game resources within a preset interval time, and finally, under the condition that the game resources are not continued for a preset time in the redis, the binding relationship between the first server and the game resources is expired, and redistributing the game resources. By the method and the system, the problems that when game resources are distributed in the stateful server, load distribution is uneven, a single-point fault occurs in the system, and dynamic expansion of the server is difficult are solved.
Description
Technical Field
The present application relates to the field of computers, and more particularly, to methods, systems, apparatus, and storage media for stateful server load balancing.
Background
There are two important basic assumptions for a server program, namely whether the server is based on a stateful request or a stateless request, where the game server is typically a stateful server. The stateful server maintains state information for each connection at the server, which may reproduce the context from locally stored information when it receives a request sent by each connection. Thus, the client can easily use the default information, and the server can easily perform state management. For example, after a game user logs in, the server can obtain previous game registration information of the game user according to the user name; and in the subsequent processing, the server can easily find the history information of the user.
In the related art, one of the load balancing methods of the stateful server is a hash method, however, dynamic capacity expansion is difficult to achieve in this method, and the problem of uneven load distribution exists; another way is to load distribute through a central server, but there is a problem of single point of failure of the server.
Aiming at the problems of uneven load distribution, single-point failure of a system and difficulty in dynamic capacity expansion of a server when game resources are distributed in a stateful server in the related art, an effective solution is not provided.
Disclosure of Invention
The embodiment of the application provides a method, a system, a device and a storage medium for load balancing of a stateful server, and at least solves the problems that when game resources are distributed in the stateful server in the related art, the load distribution is uneven, a single-point fault occurs in the system, and dynamic expansion of the server is difficult.
In a first aspect, an embodiment of the present application provides a method for load balancing of stateful servers, where the method includes:
acquiring an idle server in a back-end server, wherein the idle server is a first server;
allocating game resources to the first server through a setex instruction of the redis;
connecting the game resource to the first server for service, and in a preset interval time, continuing the first server through the binding relationship between the redis and the game resource;
and when the preset time in the redis not expired, the binding relationship between the first server and the game resources is expired, and the game resources are redistributed.
In some of these embodiments, prior to connecting the game resource to the first server for servicing, the method includes:
and obtaining the current server of the game resource through a get instruction of the redis, wherein the server is a second server.
In some embodiments, the obtaining idle servers in the backend server includes:
acquiring the ID of the idle server stored in the redis;
the service discovery protocol locates to the idle server via the ID.
In some of these embodiments, the expiration of the binding relationship of the first server to the game resource comprises:
and when the first server is down or the game player logs out, the binding relationship between the first server and the game resource is expired.
In a second aspect, an embodiment of the present application provides a system for load balancing of stateful servers, where the system includes:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring an idle server in a back-end server, and the idle server is a first server;
the allocation module is used for allocating game resources to the first server through a setex instruction of the redis;
a timing renewal module, configured to connect the game resource to the first server for service, and within a preset interval time, the first server renews a renewal through a binding relationship between the redis and the game resource;
and the redistribution module is used for redistributing the game resources when the binding relationship between the first server and the game resources is expired under the condition that the preset time in the redis is not expired.
In some of these embodiments, the allocation module is further to, prior to connecting the game resource to the first server for servicing,
and obtaining the current server of the game resource through a get instruction of the redis, wherein the server is a second server.
In some embodiments, the obtaining module is further configured to obtain an ID of the idle server stored in the redis;
the service discovery protocol locates to the idle server via the ID.
In some embodiments, the reallocation module is further configured to, in the event that the first server is down or a game player logs off, expire the binding of the first server to the game resource.
In a third aspect, an embodiment of the present application provides an electronic apparatus, including a memory and a processor, where the memory stores a computer program, and the processor is configured to execute the computer program to perform the method for load balancing of stateful servers described in any one of the foregoing.
In a fourth aspect, an embodiment of the present application provides a storage medium, where a computer program is stored in the storage medium, where the computer program is configured to, when running, execute any one of the methods for load balancing of stateful servers described above.
Compared with the related art, the method for balancing the load of the stateful server provided by the embodiment of the application obtains the idle server in the back-end server, the idle server is the first server, the game resource is distributed to the first server through the setex instruction of the redis, then the game resource is connected to the first server for service, the first server is continued through the binding relationship between the redis and the game resource within the preset interval time, and finally the game resource is redistributed after the binding relationship between the first server and the game resource expires under the condition that the game resource is not continued through the preset time in the redis, so that the problems that the load distribution is uneven, the system has a fault and the server is difficult to dynamically expand a single point when the game resource is distributed in the stateful server are solved, the dynamic load balancing of the game resource and the dynamic expansion of the server are realized, a single point of failure of the system is removed.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the application and not to limit the application. In the drawings:
FIG. 1 is a schematic diagram of an application environment of a method for stateful server load balancing according to an embodiment of the present application;
FIG. 2 is a flow diagram of a stateful server load balancing method according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a dynamically allocated backend server according to an embodiment of the present application;
FIG. 4 is a block diagram of a stateful server load balancing system according to an embodiment of the present application;
fig. 5 is an internal structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be described and illustrated below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments provided in the present application without any inventive step are within the scope of protection of the present application. Moreover, it should be appreciated that in the development of any such actual implementation, as in any engineering or design project, numerous implementation-specific decisions must be made to achieve the developers' specific goals, such as compliance with system-related and business-related constraints, which may vary from one implementation to another.
Reference in the specification to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the specification. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of ordinary skill in the art will explicitly and implicitly appreciate that the embodiments described herein may be combined with other embodiments without conflict.
Unless defined otherwise, technical or scientific terms referred to herein shall have the ordinary meaning as understood by those of ordinary skill in the art to which this application belongs. Reference to "a," "an," "the," and similar words throughout this application are not to be construed as limiting in number, and may refer to the singular or the plural. The present application is directed to the use of the terms "including," "comprising," "having," and any variations thereof, which are intended to cover non-exclusive inclusions; for example, a process, method, system, article, or apparatus that comprises a list of steps or modules (elements) is not limited to the listed steps or elements, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus. Reference to "connected," "coupled," and the like in this application is not intended to be limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. Reference herein to "a plurality" means greater than or equal to two. "and/or" describes an association relationship of associated objects, meaning that three relationships may exist, for example, "A and/or B" may mean: a exists alone, A and B exist simultaneously, and B exists alone. Reference herein to the terms "first," "second," "third," and the like, are merely to distinguish similar objects and do not denote a particular ordering for the objects.
The method for balancing the load of the stateful server provided by the present application can be applied to the application environment shown in fig. 1, where fig. 1 is a schematic diagram of an application environment of a method for balancing the load of the stateful server according to an embodiment of the present application, and as shown in fig. 1, a system of the application environment includes a server 10 and a smart terminal device 11, where the server 10 obtains a free server in a backend server, the free server is a first server, then allocates a game resource to the first server through a setex instruction of redis, then connects the game resource to the first server for service, and within a preset interval time, the first server continues to be in a binding relationship with the game resource through redis, and finally, in a case that there is no continuation time after the preset time in the redis, the binding relationship between the first server and the game resource expires, and the game resource applied to the smart terminal device 11 is reallocated, the problems that when game resources are distributed in a server with a state, load distribution is uneven, a single-point fault occurs in the system, and dynamic expansion of the server is difficult are solved, dynamic load balance of the game resources is achieved, dynamic expansion of the server is achieved, and the single-point fault of the system is eliminated.
Fig. 2 is a flowchart of a load balancing method for a stateful server according to an embodiment of the present application, and as shown in fig. 2, the flowchart includes the following steps:
step S201, acquiring an idle server in the back-end servers, where the idle server is a first server, and optionally, assuming that there are 3 servers that can serve at the back-end, in this embodiment, a relatively idle server in the 3 back-end servers is selected, and the idle server is the first server. Compared with the prior art that a hash mode is adopted for load balancing distribution, the embodiment can directly add a back-end server outside to realize dynamic capacity expansion of the server;
step S202, game resources are distributed to a first server through a setex instruction of the redis, wherein the redis is a key value pair storage database which comprises various data structures, a supporting network, a memory base and optional persistence, in addition, the setex instruction of the redis is used for appointing timeout in a redis key, and character string values of the key are set, namely appointing key set values and the expiration time thereof, for example, setex A60S, wherein A represents game resources, S represents the first server, and 60 represents the expiration time of 60 seconds. Fig. 3 is a schematic diagram of dynamically allocating a backend server according to an embodiment of the present application, and as shown in fig. 3, optionally, in this embodiment, game resources a, such as players, meetings, and the like, are allocated to a first server S through a setxa 60S instruction of redis. In the embodiment, game resources are allocated to the first server through the redis cluster, and compared with the situation that a single point fault is generated when load resources are allocated through a central server in the prior art, the problem of the single point can be effectively avoided through the redis cluster, namely when a master node and a slave node have faults, the slave node can replace a fault master node to perform service;
step S203, connecting the game resource to a first server for service, and within a preset interval time, continuing the first server through a binding relationship between the redis and the game resource, optionally, in this embodiment, after the game resource is notified by the system and allocated to the first server, the game resource is connected to the first server for service, and at intervals of a period of time, for example, 30 seconds, the first server will continue the service through the binding relationship between the redis and the game resource a;
step S204, when the preset time in the redis is not expired, the binding relationship between the first server and the game resource expires, and the game resource is reallocated, optionally, in this embodiment, when the preset 60 second expiration time in the redis is not expired, the binding relationship between the first server S and the game resource a expires, and at this time, the game resource a is reallocated to another server. In the embodiment, an atomic operation is realized through the lua script of the redis, that is, the game resources are dynamically allocated, so that the dynamic load balance of the resources can be realized.
Through the steps S201 to S204, compared with the prior art, the problem that the dynamic expansion of the server is difficult and the load distribution is uneven when the stateful server realizes the load balance in a hash manner; and load distribution is performed through one central server, so that the problem of single-point failure of the server can exist. In this embodiment, an idle server in the backend server is obtained, where the idle server is the first server, the game resources are then allocated to the first server by the setex instruction of the redis, then connecting the game resource to a first server for service, and in a preset interval time, the first server continues for a period through the binding relationship between the redis and the game resource, and finally, under the condition that the period is not continued after the preset time in the redis, when the binding relationship between the first server and the game resource is expired, the game resource applied to the intelligent terminal device 11 is redistributed, thereby solving the problem that when the game resource is distributed in the stateful server, the problems of uneven load distribution, single-point failure of the system and difficulty in dynamic capacity expansion of the server are solved, dynamic load balance of game resources is realized, dynamic capacity expansion of the server is realized, and the single-point failure of the system is eliminated.
In some embodiments, before the game resource is connected to a first server for service, a server where the game resource is currently located is always obtained through a get instruction of redis, where the server is a second server, the get instruction of redis is used for obtaining a value of a specified key, and if the key does not exist, nil is returned; if the key stores a value other than the string type, an error is returned, e.g., get A refers to the second server where game resource A is currently located. Optionally, because concurrent operation is performed, that is, when an account of one game player logs in on two terminal devices, the game resource a (player account) at this time is allocated to a second server, which is different from the first server, before the game resource a is connected to the first server for service, the second server where the game resource a is currently located needs to be always obtained through a get a instruction of redis, which is beneficial to being connected to the second server where the game resource a is actually located in subsequent resource connection.
In some embodiments, obtaining a free server in the backend server comprises: and acquiring the ID of the idle server stored in the redis, and positioning the idle server by a service discovery protocol through the ID, wherein the service discovery protocol is various, such as Consul, Zookeeper, Etcd, Eureka and the like. Optionally, the system process obtains an ID of the idle server stored in the redis, and the service discovery protocol locates the obtained idle server through the ID by using a load balancing algorithm such as a polling method, a random sending method, a hash method, a minimum connection number, a weight, and the like. In addition, as long as the system process is started, the newly added back-end server can be obtained through the service discovery protocol.
In some embodiments, the expiration of the binding relationship of the first server to the game resource comprises: and when the first server is down or the game player logs out, the binding relationship between the first server and the game resources is expired. Optionally, when the server goes down or the game player account logs out, the binding relationship between the server and the game resources may expire, and the game resources may be reallocated.
It should be noted that the steps illustrated in the above-described flow diagrams or in the flow diagrams of the figures may be performed in a computer system, such as a set of computer-executable instructions, and that, although a logical order is illustrated in the flow diagrams, in some cases, the steps illustrated or described may be performed in an order different than here.
The present embodiment further provides a system for load balancing of a stateful server, where the system is used to implement the foregoing embodiments and preferred embodiments, and details of the system that have been already described are omitted. As used hereinafter, the terms "module," "unit," "subunit," and the like may implement a combination of software and/or hardware for a predetermined function. Although the means described in the embodiments below are preferably implemented in software, an implementation in hardware, or a combination of software and hardware is also possible and contemplated.
Fig. 4 is a block diagram of a stateful server load balancing structure according to an embodiment of the present application, and as shown in fig. 4, the system includes an obtaining module 41, an allocating module 42, a timing renewal module 43, and a reallocating module 44:
an obtaining module 41, configured to obtain an idle server in a backend server, where the idle server is a first server; the allocation module 42 is used for allocating the game resources to the first server through the setex instruction of the redis; a timing renewal module 43, configured to connect the game resource to the first server for service, and within a preset interval, the first server renews a renewal through a binding relationship between the redis and the game resource; and the redistribution module 44 is configured to, when the preset time in the redis is not expired, cause the binding relationship between the first server and the game resource to expire, and redistribute the game resource.
Compared with the prior art that the acquisition module 41 performs load balancing distribution by adopting a hash mode, the module of the embodiment can be directly externally added with a back-end server to realize dynamic capacity expansion of the server; the allocation module 42 allocates the game resources to the first server through the redis cluster, and compared with the prior art that a single point fault is generated when load resources are allocated through a central server, the problem of the single point can be effectively avoided through the redis cluster, that is, when a master node and a slave node have a fault, the slave node can replace a fault master node to perform service; the timing renewal module 43 may be configured to connect the game resource to the first server for service after the game resource is informed by the system to be allocated to the first server, and the first server may renew the game resource a through a binding relationship between redis and the game resource a at an interval of time, for example, 30 seconds; the redistribution module 44 implements an atomic operation through the lua script of the redis, that is, dynamically distributes the game resources, and can implement dynamic load balancing of the resources. The whole system solves the problems of uneven load distribution, single-point fault of the system and difficulty in dynamic expansion of the server when game resources are distributed in the stateful server, realizes dynamic load balance of the game resources and dynamic expansion of the server, and removes the single-point fault of the system.
In some embodiments, the allocating module 42 is further configured to, before the game resource is connected to a first server for serving, always obtain, by a get instruction of redis, a server where the game resource is currently located, where the get instruction of redis is used to obtain a value of a specified key, and if the key does not exist, return to nil; if the key stores a value other than the string type, an error is returned, e.g., get A refers to the second server where game resource A is currently located. Optionally, because concurrent operation is performed, that is, when an account of one game player logs in on two terminal devices, the game resource a (player account) at this time is allocated to a second server, which is different from the first server, before the game resource a is connected to the first server for service, the second server where the game resource a is currently located needs to be always obtained through a get a instruction of redis, which is beneficial to being connected to the second server where the game resource a is actually located in subsequent resource connection.
In some embodiments, the obtaining module 41 is further configured to obtain an ID of an idle server stored in the redis, and the service discovery protocol locates to the idle server through the ID, where the service discovery protocol is many, for example, Consul, Zookeeper, Etcd, Eureka, and the like. Optionally, the system process obtains an ID of the idle server stored in the redis, and the service discovery protocol locates the obtained idle server through the ID by using a load balancing algorithm such as a polling method, a random sending method, a hash method, a minimum connection number, a weight, and the like. In addition, as long as the system process is started, the newly added back-end server can be obtained through the service discovery protocol.
In some embodiments, the redistribution module 44 is further configured to, in the event that the first server is down or the game player logs out, expire the binding relationship between the first server and the game resource, and optionally, in the event that the server is down or the game player account logs out, expire the binding relationship between the server and the game resource, and reallocate the game resource.
The present invention will be described in detail with reference to the following application scenarios.
The invention aims to provide a method and a system for load balancing of a stateful server, wherein the flow steps of the technical scheme for load balancing of the stateful server in the embodiment comprise the following steps:
s1, when game resource A needs to apply for a server with state, first, a first server S which is idle in a back-end server is obtained through a service discovery protocol;
s2, trying to bind the game resource A to a first server S through the setex A60S of the redis, and then always obtaining a second server where the game resource A is actually located through the get A of the redis, wherein the second server is not necessarily the first server due to the existence of concurrent operation;
s3, the game resource A is informed to be distributed to the first server S, and then the game resource A is connected to the first server S for service;
s4, when the game resource A is served on the first server S, the first server S will carry out timing renewal through the binding relationship between the redis and the game resource A at intervals of 30 seconds;
s5, when the period does not expire after 60 seconds, the binding data of the game resource A will expire, and the resource A will perform the load distribution again through the above steps, wherein, in general, if the server SS goes down or the game player logs out, the binding relationship will expire.
The present embodiment also provides an electronic device comprising a memory having a computer program stored therein and a processor configured to execute the computer program to perform the steps of any of the above method embodiments.
Optionally, the electronic apparatus may further include a transmission device and an input/output device, wherein the transmission device is connected to the processor, and the input/output device is connected to the processor.
In addition, in combination with the method for load balancing of the stateful server in the foregoing embodiment, the embodiment of the present application may provide a storage medium to implement. The storage medium having stored thereon a computer program; the computer program, when executed by a processor, implements any of the methods of stateful server load balancing in the above embodiments.
In one embodiment, fig. 5 is a schematic diagram of an internal structure of an electronic device according to an embodiment of the present application, and as shown in fig. 5, an electronic device is provided, where the electronic device may be a server, and the internal structure diagram may be as shown in fig. 5. The electronic device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the electronic device is configured to provide computing and control capabilities. The memory of the electronic equipment comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the electronic device is used for storing data. The network interface of the electronic device is used for connecting and communicating with an external terminal through a network. The computer program is executed by a processor to implement a method of stateful server load balancing.
Those skilled in the art will appreciate that the configuration shown in fig. 5 is a block diagram of only a portion of the configuration associated with the present application, and does not constitute a limitation on the electronic device to which the present application is applied, and a particular electronic device may include more or less components than those shown in the drawings, or may combine certain components, or have a different arrangement of components.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
It should be understood by those skilled in the art that various features of the above-described embodiments can be combined in any combination, and for the sake of brevity, all possible combinations of features in the above-described embodiments are not described in detail, but rather, all combinations of features which are not inconsistent with each other should be construed as being within the scope of the present disclosure.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.
Claims (10)
1. A method for stateful server load balancing, the method comprising:
acquiring an idle server in a back-end server, wherein the idle server is a first server;
allocating game resources to the first server through a setex instruction of the redis;
connecting the game resource to the first server for service, and in a preset interval time, continuing the first server through the binding relationship between the redis and the game resource;
and when the preset time in the redis not expired, the binding relationship between the first server and the game resources is expired, and the game resources are redistributed.
2. The method of claim 1, wherein prior to connecting the game resource to the first server for servicing, the method comprises:
and obtaining the current server of the game resource through a get instruction of the redis, wherein the server is a second server.
3. The method of claim 1, wherein obtaining a free server in the backend server comprises:
acquiring the ID of the idle server stored in the redis;
the service discovery protocol locates to the idle server via the ID.
4. The method of claim 1, wherein the expiration of the binding relationship of the first server to the game resource comprises:
and when the first server is down or the game player logs out, the binding relationship between the first server and the game resource is expired.
5. A system for stateful server load balancing, the system comprising:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring an idle server in a back-end server, and the idle server is a first server;
the allocation module is used for allocating game resources to the first server through a setex instruction of the redis;
a timing renewal module, configured to connect the game resource to the first server for service, and within a preset interval time, the first server renews a renewal through a binding relationship between the redis and the game resource;
and the redistribution module is used for redistributing the game resources when the binding relationship between the first server and the game resources is expired under the condition that the preset time in the redis is not expired.
6. The system of claim 5, wherein the allocation module is further configured to, prior to connecting the game resource to the first server for servicing,
and obtaining the current server of the game resource through a get instruction of the redis, wherein the server is a second server.
7. The system of claim 5,
the obtaining module is further configured to obtain an ID of the idle server stored in the redis;
the service discovery protocol locates to the idle server via the ID.
8. The system of claim 5,
the redistribution module is further configured to, when the first server is down or a game player logs out, expire the binding relationship between the first server and the game resource.
9. An electronic device comprising a memory and a processor, wherein the memory has stored therein a computer program, and the processor is configured to execute the computer program to perform the method of stateful server load balancing of any of claims 1 to 4.
10. A storage medium having a computer program stored thereon, wherein the computer program is arranged to perform the method of stateful server load balancing of any one of claims 1 to 4 when executed.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011301122.6A CN112506647A (en) | 2020-11-19 | 2020-11-19 | Method, system, device and storage medium for load balancing of stateful servers |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011301122.6A CN112506647A (en) | 2020-11-19 | 2020-11-19 | Method, system, device and storage medium for load balancing of stateful servers |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112506647A true CN112506647A (en) | 2021-03-16 |
Family
ID=74959916
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011301122.6A Pending CN112506647A (en) | 2020-11-19 | 2020-11-19 | Method, system, device and storage medium for load balancing of stateful servers |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112506647A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113190546A (en) * | 2021-05-26 | 2021-07-30 | 成都新希望金融信息有限公司 | Eureka service control method, system and readable storage medium |
CN113254159A (en) * | 2021-06-16 | 2021-08-13 | 腾讯科技(成都)有限公司 | Migration method and device of stateful service, computer equipment and storage medium |
CN114567636A (en) * | 2022-01-20 | 2022-05-31 | 银盛通信有限公司 | Million-level concurrent renewal method based on mobile resale system |
Citations (14)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101309278A (en) * | 2008-06-27 | 2008-11-19 | 腾讯科技(深圳)有限公司 | Method and system for storing encrypt data on customer |
CN102611709A (en) * | 2012-03-31 | 2012-07-25 | 奇智软件(北京)有限公司 | Access control method and system for third party resources |
CN103546524A (en) * | 2012-07-17 | 2014-01-29 | 人人游戏网络科技发展(上海)有限公司 | Method and equipment for dynamic load balancing of game servers |
CN103873457A (en) * | 2012-12-17 | 2014-06-18 | 人人游戏网络科技发展(上海)有限公司 | Method and equipment for balancing loads among game servers |
US20150072792A1 (en) * | 2013-07-22 | 2015-03-12 | Empire Technology Development Llc | Game load management |
CN107147730A (en) * | 2017-06-02 | 2017-09-08 | 北京畅游天下网络技术有限公司 | Game scene management method and scene management server |
CN110166529A (en) * | 2019-04-16 | 2019-08-23 | 平安普惠企业管理有限公司 | It keeps logging in state method, apparatus, equipment and storage medium |
CN110327621A (en) * | 2019-04-24 | 2019-10-15 | 上海恺英网络科技有限公司 | For the matched method and apparatus of network game client |
CN110381078A (en) * | 2019-07-29 | 2019-10-25 | 迈普通信技术股份有限公司 | Determination method, apparatus, electronic equipment and the storage medium that token renews |
CN110417719A (en) * | 2019-02-26 | 2019-11-05 | 腾讯科技(深圳)有限公司 | It logs in state and renews method, login method, device, server and terminal |
CN111131445A (en) * | 2019-12-23 | 2020-05-08 | 互联网域名系统北京市工程研究中心有限公司 | DHCP cluster scheduling method and DHCP cluster system |
CN111427668A (en) * | 2020-04-15 | 2020-07-17 | 成都成信高科信息技术有限公司 | Virtual resource automatic management method in cloud computing environment |
CN111530074A (en) * | 2020-04-21 | 2020-08-14 | 上海莉莉丝科技股份有限公司 | Game server system and data processing method of game server |
CN111905362A (en) * | 2020-08-19 | 2020-11-10 | 网易(杭州)网络有限公司 | Game guild loading method and server |
-
2020
- 2020-11-19 CN CN202011301122.6A patent/CN112506647A/en active Pending
Patent Citations (14)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101309278A (en) * | 2008-06-27 | 2008-11-19 | 腾讯科技(深圳)有限公司 | Method and system for storing encrypt data on customer |
CN102611709A (en) * | 2012-03-31 | 2012-07-25 | 奇智软件(北京)有限公司 | Access control method and system for third party resources |
CN103546524A (en) * | 2012-07-17 | 2014-01-29 | 人人游戏网络科技发展(上海)有限公司 | Method and equipment for dynamic load balancing of game servers |
CN103873457A (en) * | 2012-12-17 | 2014-06-18 | 人人游戏网络科技发展(上海)有限公司 | Method and equipment for balancing loads among game servers |
US20150072792A1 (en) * | 2013-07-22 | 2015-03-12 | Empire Technology Development Llc | Game load management |
CN107147730A (en) * | 2017-06-02 | 2017-09-08 | 北京畅游天下网络技术有限公司 | Game scene management method and scene management server |
CN110417719A (en) * | 2019-02-26 | 2019-11-05 | 腾讯科技(深圳)有限公司 | It logs in state and renews method, login method, device, server and terminal |
CN110166529A (en) * | 2019-04-16 | 2019-08-23 | 平安普惠企业管理有限公司 | It keeps logging in state method, apparatus, equipment and storage medium |
CN110327621A (en) * | 2019-04-24 | 2019-10-15 | 上海恺英网络科技有限公司 | For the matched method and apparatus of network game client |
CN110381078A (en) * | 2019-07-29 | 2019-10-25 | 迈普通信技术股份有限公司 | Determination method, apparatus, electronic equipment and the storage medium that token renews |
CN111131445A (en) * | 2019-12-23 | 2020-05-08 | 互联网域名系统北京市工程研究中心有限公司 | DHCP cluster scheduling method and DHCP cluster system |
CN111427668A (en) * | 2020-04-15 | 2020-07-17 | 成都成信高科信息技术有限公司 | Virtual resource automatic management method in cloud computing environment |
CN111530074A (en) * | 2020-04-21 | 2020-08-14 | 上海莉莉丝科技股份有限公司 | Game server system and data processing method of game server |
CN111905362A (en) * | 2020-08-19 | 2020-11-10 | 网易(杭州)网络有限公司 | Game guild loading method and server |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113190546A (en) * | 2021-05-26 | 2021-07-30 | 成都新希望金融信息有限公司 | Eureka service control method, system and readable storage medium |
CN113190546B (en) * | 2021-05-26 | 2023-03-14 | 成都新希望金融信息有限公司 | Method and system for managing and controlling Eureka service and readable storage medium |
CN113254159A (en) * | 2021-06-16 | 2021-08-13 | 腾讯科技(成都)有限公司 | Migration method and device of stateful service, computer equipment and storage medium |
CN113254159B (en) * | 2021-06-16 | 2022-10-21 | 腾讯科技(成都)有限公司 | Migration method and device of stateful service, computer equipment and storage medium |
CN114567636A (en) * | 2022-01-20 | 2022-05-31 | 银盛通信有限公司 | Million-level concurrent renewal method based on mobile resale system |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112506647A (en) | Method, system, device and storage medium for load balancing of stateful servers | |
CN108206852B (en) | Session-based service instance management method and device under micro-service framework | |
CN108667748B (en) | Method, device, equipment and storage medium for controlling bandwidth | |
CN1754146B (en) | System and method for server load balancing and server affinity | |
CN108173774B (en) | Client upgrading method and system | |
US8099402B2 (en) | Distributed data storage and access systems | |
CN108881512B (en) | CTDB virtual IP balance distribution method, device, equipment and medium | |
CN109379448B (en) | File distributed deployment method and device, electronic equipment and storage medium | |
JP2009301581A (en) | Method of assigning task, data processing system, client data processing node, and machine-readable storage medium | |
CN111092921B (en) | Data acquisition method, device and storage medium | |
CN107105013B (en) | File processing method, server, terminal and system | |
CN105612539B (en) | Producer system partitioning among leasing agent systems | |
CN107579924B (en) | Flow allocation method and device | |
CN113037522A (en) | Container unit management method and related equipment | |
CN111666131A (en) | Load balancing distribution method and device, computer equipment and storage medium | |
CN113900774B (en) | Virtual machine control method and device of cloud operating system and storage medium | |
CN111163140A (en) | Method, apparatus and computer readable storage medium for resource acquisition and allocation | |
CN112865993A (en) | Method and device for switching slave nodes in distributed master-slave system | |
EP3672203A1 (en) | Distribution method for distributed data computing, device, server and storage medium | |
CN114168312A (en) | Distributed cluster load balancing method and device and storage medium | |
CN115640146A (en) | Back-end service calling method and device, electronic equipment and program product | |
CN109257201B (en) | License sending method and device | |
CN111309467A (en) | Task distribution method and device, electronic equipment and storage medium | |
CN115037753B (en) | Message notification method and system | |
CN108833492B (en) | Method, device, client and system for improving server calling accuracy |
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 |