CN111614760A - Method and device for balanced distribution access of Internet of things equipment - Google Patents

Method and device for balanced distribution access of Internet of things equipment Download PDF

Info

Publication number
CN111614760A
CN111614760A CN202010433313.1A CN202010433313A CN111614760A CN 111614760 A CN111614760 A CN 111614760A CN 202010433313 A CN202010433313 A CN 202010433313A CN 111614760 A CN111614760 A CN 111614760A
Authority
CN
China
Prior art keywords
access server
hash
hash value
unique identifier
accessed
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
Application number
CN202010433313.1A
Other languages
Chinese (zh)
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.)
Haoyun Technologies Co Ltd
Original Assignee
Haoyun Technologies 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 Haoyun Technologies Co Ltd filed Critical Haoyun Technologies Co Ltd
Priority to CN202010433313.1A priority Critical patent/CN111614760A/en
Publication of CN111614760A publication Critical patent/CN111614760A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • H04L67/1034Reaction to server failures by a load balancer
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/104Peer-to-peer [P2P] networks
    • H04L67/1044Group management mechanisms 
    • H04L67/1048Departure or maintenance mechanisms
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/50Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Signal Processing (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Computer Security & Cryptography (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Computer And Data Communications (AREA)

Abstract

The invention provides a method and a device for balanced distribution access of Internet of things equipment, wherein the method comprises the following steps: acquiring information of equipment to be accessed and an access server; calculating a first hash value of the unique identifier of the access server, performing associated storage on each access server and the first hash value thereof, and constructing a consistent hash ring; calculating a second hash value of the unique identifier of the equipment to be accessed; if the candidate hash value set larger than the second hash value is inquired from the consistent hash ring, selecting the smallest first hash value from the candidate hash value set and establishing a binding relationship with the second hash value; otherwise, selecting the minimum first hash value from the consistent hash ring and establishing a binding relationship with the second hash value; and distributing and accessing the equipment to be accessed to the corresponding access server according to the binding relationship. The invention can enable the equipment to be in stable transition in the process of re-equilibrium distribution, and can not cause large fluctuation of system operation, thereby reducing the reduction of user experience.

Description

Method and device for balanced distribution access of Internet of things equipment
Technical Field
The invention relates to the technical field of Internet of things, in particular to a method and a device for balanced distribution access of Internet of things equipment.
Background
In the internet of things system, each internet of things device needs to connect the device with the network through an access service, can be docked through an SDK or a network protocol, acquires data from the device, sends the data to the internet of things system for calculation, and sends a device control instruction of the upper layer of the system to the device, so that device control is realized. However, since there may be many devices to be accessed in the internet of things system, and a single access service cannot bear the connection of many devices, multiple access services may be extended horizontally in the internet of things system, and at this time, load balancing needs to be performed on the access services.
At present, a device balancing algorithm implemented in an internet of things system is usually an 'equal sharing' mode, when an access service goes offline due to a fault or needs to be newly added, the cost of equal sharing is relatively high, devices originally allocated may appear, and after the balance is completed again, the devices do not belong to the devices, so that the devices need to go offline first and then go online with the newly allocated service, and thus system fluctuation is caused.
Disclosure of Invention
The invention provides a method and a device for balanced distribution access of Internet of things equipment, which aim to solve the problem that the existing balanced distribution scheme of the Internet of things equipment is easy to cause system fluctuation.
In order to solve the technical problem, an embodiment of the present invention provides a method for allocating and accessing internet of things devices in a balanced manner, including:
acquiring information of a plurality of devices to be accessed and information of a plurality of access servers; the information of the equipment to be accessed comprises a unique identifier of the equipment to be accessed, and the information of the access server comprises a unique identifier of the access server;
calculating a first hash value of each unique access server identifier by adopting a preset hash function, performing associated storage on each unique access server identifier and the first hash value thereof through a preset ordered data structure, and constructing a consistent hash ring according to the first hash values stored in the ordered data structure in sequence;
calculating a second hash value of the unique identifier of each device to be accessed by adopting the hash function, and comparing each second hash value with the first hash value in the consistent hash ring one by one;
if the candidate hash value set larger than the second hash value is inquired from the consistent hash ring, selecting the smallest first hash value from the candidate hash value set and establishing a binding relationship with the second hash value;
if the candidate hash value set larger than the second hash value is not inquired from the consistent hash ring, selecting the smallest first hash value from the consistent hash ring and establishing a binding relationship with the second hash value;
and distributing and accessing each device to be accessed to the corresponding access server according to the binding relationship.
Further, the calculating a first hash value of each unique identifier of the access server by using a preset hash function, performing associated storage on each unique identifier of the access server and the first hash value thereof through a preset ordered data structure, and constructing a consistent hash ring according to the first hash values stored in the ordered data structure in sequence specifically includes:
converting each access server into a plurality of access server virtual nodes, and allocating a unique identifier to each access server virtual node;
calculating a first hash value of the unique identifier of each access server virtual node by adopting the hash function;
performing associated storage on the unique identifier of each access server virtual node and the first hash value of the unique identifier of each access server virtual node through a preset ordered data structure;
and constructing a consistent hash ring according to the first hash values stored in the ordered data structure in sequence.
Further, the first hash value is obtained by calculating an access server unique identifier MD5 character string by using the hash function; the access server unique identifier MD5 character string is obtained by calculating the access server unique identifier by adopting an MD5 algorithm;
the second hash value is obtained by calculating the unique identifier MD5 character string of the equipment to be accessed by adopting the hash function; the MD5 character string of the unique identifier of the equipment to be accessed is obtained by calculating the unique identifier of the equipment to be accessed by adopting the MD5 algorithm.
Further, the method for allocating and accessing the internet of things equipment in a balanced manner further comprises the following steps:
when the access server fails, the equipment accessed to the failed access server is distributed and accessed to the next access server according to a preset sequence, and the failed access server is removed from the consistent hash ring.
Further, the method for allocating and accessing the internet of things equipment in a balanced manner further comprises the following steps:
when an access server is newly added, calculating a first hash value of the unique identifier of the newly added access server by adopting the hash function, and inserting the first hash value of the unique identifier of the newly added access server into a corresponding position according to the storage sequence of the ordered data structure;
updating the consistent hash ring according to the ordered data structure after the newly added data, and finding out the next access server of the newly added access server in the consistent hash ring as the access server to be adjusted;
recalculating, comparing and adjusting the binding relationship of the equipment accessed into the access server to be adjusted, and reallocating access to the equipment accessed into the server to be adjusted according to the readjusted binding relationship.
Further, the hash function is a BKDR hash function.
In order to solve the same technical problem, the invention also provides a device for the balanced distribution access of the internet of things equipment, which comprises the following components:
the information acquisition module is used for acquiring information of a plurality of devices to be accessed and information of a plurality of access servers; the information of the equipment to be accessed comprises a unique identifier of the equipment to be accessed, and the information of the access server comprises a unique identifier of the access server;
the hash ring construction module is used for calculating a first hash value of each unique identifier of the access server by adopting a preset hash function, performing associated storage on each unique identifier of the access server and the first hash value of the unique identifier of the access server through a preset ordered data structure, and constructing a consistent hash ring according to the first hash values stored in the ordered data structure in sequence;
the hash value comparison module is used for calculating a second hash value of the unique identifier of each device to be accessed by adopting the hash function and comparing each second hash value with the first hash value in the consistent hash ring one by one;
the first binding module is used for selecting the smallest first hash value from the candidate hash value sets to establish a binding relationship with the second hash value if the candidate hash value sets larger than the second hash value are inquired from the consistent hash ring;
the second binding module is used for selecting the minimum first hash value from the consistent hash ring and establishing a binding relationship with the second hash value if the candidate hash value set larger than the second hash value is not inquired from the consistent hash ring;
and the equipment access module is used for distributing and accessing each equipment to be accessed to the corresponding access server according to the binding relationship.
Further, the hash ring construction module specifically includes:
the node virtual unit is used for converting each access server into a plurality of access server virtual nodes and distributing a unique identifier to each access server virtual node;
the hash calculation unit is used for calculating a first hash value of the unique identifier of each access server virtual node by adopting the hash function;
the associated storage unit is used for storing the unique identifier of each access server virtual node and the first hash value of the unique identifier of each access server virtual node in an associated manner through a preset ordered data structure;
and the hash ring construction unit is used for constructing a consistent hash ring according to the first hash values sequentially stored in the ordered data structure.
Further, the first hash value is obtained by calculating an access server unique identifier MD5 character string by using the hash function; the access server unique identifier MD5 character string is obtained by calculating the access server unique identifier by adopting an MD5 algorithm;
the second hash value is obtained by calculating the unique identifier MD5 character string of the equipment to be accessed by adopting the hash function; the MD5 character string of the unique identifier of the equipment to be accessed is obtained by calculating the unique identifier of the equipment to be accessed by adopting the MD5 algorithm.
Further, the device for accessing internet of things equipment through balanced allocation further comprises a fault adjustment module, configured to:
when the access server fails, the equipment accessed to the failed access server is distributed and accessed to the next access server according to a preset sequence, and the failed access server is removed from the consistent hash ring.
Compared with the prior art, the invention has the following beneficial effects:
the embodiment of the invention provides a method and a device for accessing Internet of things equipment in a balanced distribution manner, wherein the method comprises the following steps: acquiring information of a plurality of devices to be accessed and information of a plurality of access servers; the information of the equipment to be accessed comprises a unique identifier of the equipment to be accessed, and the information of the access server comprises a unique identifier of the access server; calculating a first hash value of each unique access server identifier by adopting a preset hash function, performing associated storage on each unique access server identifier and the first hash value thereof through a preset ordered data structure, and constructing a consistent hash ring according to the first hash values stored in the ordered data structure in sequence; calculating a second hash value of the unique identifier of each device to be accessed by adopting the hash function, and comparing each second hash value with the first hash value in the consistent hash ring one by one; if the candidate hash value set larger than the second hash value is inquired from the consistent hash ring, selecting the smallest first hash value from the candidate hash value set and establishing a binding relationship with the second hash value; if the candidate hash value set larger than the second hash value is not inquired from the consistent hash ring, selecting the smallest first hash value from the consistent hash ring and establishing a binding relationship with the second hash value; and distributing and accessing each device to be accessed to the corresponding access server according to the binding relationship. The invention can solve the problem that the existing balance distribution scheme of the Internet of things equipment is easy to cause system fluctuation, and the balance distribution of the Internet of things equipment is accessed into the access server by utilizing the consistent Hash algorithm, so that the equipment access re-balance distribution process can be in stable transition when the equipment access service of the Internet of things system is failed or newly added, the large fluctuation of the system operation can not be caused, and the reduction of the user experience is reduced.
Drawings
Fig. 1 is a schematic flowchart of a method for allocating and accessing internet of things devices in a balanced manner according to an embodiment of the present invention;
fig. 2 is a schematic diagram of hash ring construction according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of the device balance allocation according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an apparatus for allocating and accessing internet of things devices in a balanced manner according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be described clearly and completely with reference to the accompanying drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, 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 invention.
Referring to fig. 1, an embodiment of the present invention provides a method for allocating and accessing internet of things devices in a balanced manner, including the steps of:
s1, acquiring information of a plurality of devices to be accessed and information of a plurality of access servers; the information of the equipment to be accessed comprises a unique identifier of the equipment to be accessed, and the information of the access server comprises a unique identifier of the access server; the number of the equipment to be accessed and the number of the access servers are at least 1; it is understood that when the number of the access servers is 1, all the access devices may directly access to the access server.
S2, calculating a first hash value of each unique identifier of the access server by adopting a preset hash function, performing associated storage on each unique identifier of the access server and the first hash value thereof through a preset ordered data structure, and constructing a consistent hash ring according to the first hash values stored in the ordered data structure in sequence. Preferably, the hash function is a BKDR hash function. In the embodiment of the present invention, further, the first hash value is obtained by calculating a unique access server identifier MD5 character string using the hash function; the access server unique identifier MD5 character string is obtained by calculating the access server unique identifier by adopting an MD5 algorithm;
the second hash value is obtained by calculating the unique identifier MD5 character string of the equipment to be accessed by adopting the hash function; the MD5 character string of the unique identifier of the equipment to be accessed is obtained by calculating the unique identifier of the equipment to be accessed by adopting the MD5 algorithm.
In the embodiment of the present invention, further, step S2 specifically includes:
s201, converting each access server into a plurality of access server virtual nodes, and distributing a unique identifier to each access server virtual node;
s202, calculating a first hash value of the unique identifier of each access server virtual node by adopting the hash function;
s203, performing associated storage on the unique identifier of each access server virtual node and the first hash value of the unique identifier of each access server virtual node through a preset ordered data structure;
and S204, constructing a consistent hash ring according to the first hash values sequentially stored in the ordered data structure.
S3, calculating a second hash value of the unique identifier of each device to be accessed by adopting the hash function, and comparing each second hash value with the first hash value in the consistent hash ring one by one;
s4, if the candidate hash value set which is larger than the second hash value is inquired from the consistent hash ring, selecting the smallest first hash value from the candidate hash value set to establish a binding relationship with the second hash value;
s5, if the candidate hash value set larger than the second hash value is not inquired from the consistent hash ring, selecting the smallest first hash value from the consistent hash ring to establish a binding relationship with the second hash value;
and S6, distributing and accessing each device to be accessed to the corresponding access server according to the binding relationship.
In the embodiment of the present invention, further, the method for allocating and accessing the internet of things device in a balanced manner further includes the steps of:
and S7, when the access server fails, distributing and accessing the equipment accessed to the failed access server to the next access server according to a preset sequence, and removing the failed access server from the consistent hash ring.
In this embodiment of the present invention, further, the method for allocating and accessing to devices of the internet of things in a balanced manner further includes:
s801, when an access server is newly added, calculating a first hash value of the unique identifier of the newly added access server by adopting the hash function, and inserting the first hash value of the unique identifier of the newly added access server into a corresponding position according to the storage sequence of the ordered data structure;
s802, updating the consistent hash ring according to the ordered data structure after the new data is added, and finding out the next access server of the new access server in the consistent hash ring as the access server to be adjusted;
and S803, recalculating, comparing and adjusting the binding relationship of the equipment accessed into the access server to be adjusted, and reallocating access to the equipment accessed into the server to be adjusted according to the readjusted binding relationship.
It can be understood that the whole equalization process of the scheme of the invention is as follows: the equalization service firstly acquires the equipment information and the access service list, then the equipment is evenly distributed to each access service by adopting a consistent HASH algorithm, and finally the structure is pushed to the access service, and meanwhile, the access service is supported to acquire the equipment list distributed to the user.
It should be noted that the equalization algorithm adopts a consistent HASH algorithm, which is the core of the design, and the advantage of the device equalization allocation realized by the consistent HASH is that when an access service node fails to obtain an added node, the rebalancing process is stable and smooth, the situation that all devices are allocated due to the large-batch failure of the devices originally allocated to other access services is avoided, and the stable access of the devices can be ensured.
Based on the above scheme, in order to better understand the embodiment of the present invention, the following details how to implement the process of device equalization:
1. referring to fig. 2, the consensus has loop was constructed as follows:
firstly, constructing a consistent HASH loop requires identifying a HASH function, which has the following characteristics:
(1) the randomness is high, namely, the output HASH value can be changed greatly as long as the input content is changed a little.
(2) The same input content and the same HASH function result are the same in each calculation
(3) The performance is good, i.e. calculating the HASH value does not take a long time.
Preferably, the HASH function employed by embodiments of the present invention is an open source BKDR HASH function. The range of the result value of the HASH function is 0-232-1。
Then, according to the unique identifier of the access service (access server), the HASH VALUE of each service is calculated through a HASH function, and finally, the HASH VALUEs are stored in an ordered data structure. As a preferred scheme, in order to ensure more balanced allocation, each access service needs to be virtualized into multiple nodes, (default 25 nodes are virtualized, which is a preferred value taken after actual test, and the number of virtual nodes can be designed into a configurable parameter, which is a balance factor of the system and can be adjusted according to actual conditions in a production environment). To this end, the construction of the consensus HASH loop is complete.
As a preferable scheme, in the implementation process, all places where HASH values need to be calculated are subjected to MD5 calculation (tests show that performing HASH calculation after MD5 calculation is more random, which is beneficial to the balanced distribution effect of device access), and then the HASH values are calculated through a BKDR HASH function after MD5 character strings are obtained.
2. Referring to fig. 3, the device equalization allocation process is as follows:
on the basis of a HASH ring constructed according to an access service originally, a HASH value is obtained by performing HASH calculation (by adopting the HASH function determined above) on a unique identifier of a device (to-be-accessed device), a service node (the smallest node if not) which is larger than the HASH value and closest to the HASH value is found in the HASH ring, because the service node is stored through an ordered data structure, the searching mode is that the node closest to the HASH value is found clockwise, after the node is found, the device is distributed to the node to perform class pushing, and after the above operation is performed on each device, load balancing is completed.
When the access service fails, as shown in fig. 3, assuming that the access service B fails, it is only necessary to allocate the device originally allocated to the access service B to the nearest node (access service C) clockwise of B;
when the access service is newly added, if the access service D is newly added, the HASH value of the access service D is calculated to fall between B and C through the HASH function, and then the equipment originally allocated to the access service C is required to be recalculated once;
it will be appreciated that by implementing the present invention, the entire rebalancing process, whether it is a service failure or a new service, does not involve large-area device reallocation and is therefore very smooth and stable.
To facilitate understanding of the inventive arrangements, the following are part of the term interpretation:
the Internet of things system comprises: the system is characterized in that various articles are connected with the internet according to an agreed protocol by information equipment such as radio frequency automatic identification, an infrared sensor, a global positioning system, a laser scanner, an image sensor and the like, so as to exchange and communicate information, thereby realizing intelligent identification, positioning, tracking, monitoring and management.
Device access service (access server): the method has the functions of connecting with equipment through a network, carrying out butt joint through an SDK or a network protocol, obtaining data from the equipment, sending the data to an Internet of things system for calculation, and sending an equipment control instruction of an upper layer of the system to the equipment, thereby realizing equipment control.
Load balancing: the method has the function of distributing the equipment (equipment to be accessed) needing to be accessed to a plurality of access services in a balanced manner, and because the equipment needing to be accessed in the Internet of things system is possibly many and a single access service cannot bear the connection of more equipment, the plurality of access services can be expanded transversely in the Internet of things system, and the balancing service is needed to perform load balancing work at this time.
It should be noted that, in the current device balancing algorithm implemented in the internet of things system, it is usually an "equal sharing" manner, and in this manner, when an access service fails to go offline or an access service needs to be newly added, the cost of equal sharing is relatively high, and devices originally allocated may occur.
The method has the advantages that the fluctuation of equipment rebalancing caused by equipment access service failure/new addition is reduced, and by utilizing the consistent HASH algorithm, when the equipment access service fails or is newly added, the equipment needing rebalancing only needs the service node which is attached to the failure/new addition service in the HASH ring, but not the equipment with large area needs to be redistributed, so that the whole rebalancing process is very smooth.
It should be noted that the above method or flow embodiment is described as a series of acts or combinations for simplicity, but those skilled in the art should understand that the present invention is not limited by the described acts or sequences, as some steps may be performed in other sequences or simultaneously according to the present invention. Further, those skilled in the art will appreciate that the embodiments described in the specification are exemplary embodiments and that no single embodiment is necessarily required by the inventive embodiments.
Referring to fig. 4, in order to solve the same technical problem, the present invention further provides an apparatus for allocating and accessing internet of things devices in a balanced manner, including:
the information acquisition module 1 is used for acquiring information of a plurality of devices to be accessed and information of a plurality of access servers; the information of the equipment to be accessed comprises a unique identifier of the equipment to be accessed, and the information of the access server comprises a unique identifier of the access server;
the hash ring construction module 2 is configured to calculate a first hash value of each unique identifier of the access server by using a preset hash function, perform association storage on each unique identifier of the access server and the first hash value thereof through a preset ordered data structure, and construct a consistent hash ring according to the first hash values sequentially stored in the ordered data structure;
the hash value comparison module 3 is configured to calculate a second hash value of the unique identifier of each device to be accessed by using the hash function, and compare each second hash value with the first hash value in the consistent hash ring one by one;
a first binding module 4, configured to select a smallest first hash value from the candidate hash value sets to establish a binding relationship with the second hash value if the candidate hash value sets larger than the second hash value are queried from the consistent hash ring;
a second binding module 5, configured to select a smallest first hash value from the consistent hash ring to establish a binding relationship with the second hash value if the candidate hash value set larger than the second hash value is not queried from the consistent hash ring;
and the equipment access module 6 is used for distributing and accessing each equipment to be accessed to the corresponding access server according to the binding relationship.
Further, the hash ring building module 2 specifically includes:
the node virtual unit is used for converting each access server into a plurality of access server virtual nodes and distributing a unique identifier to each access server virtual node;
the hash calculation unit is used for calculating a first hash value of the unique identifier of each access server virtual node by adopting the hash function;
the associated storage unit is used for storing the unique identifier of each access server virtual node and the first hash value of the unique identifier of each access server virtual node in an associated manner through a preset ordered data structure;
and the hash ring construction unit is used for constructing a consistent hash ring according to the first hash values sequentially stored in the ordered data structure.
Further, the first hash value is obtained by calculating an access server unique identifier MD5 character string by using the hash function; the access server unique identifier MD5 character string is obtained by calculating the access server unique identifier by adopting an MD5 algorithm;
the second hash value is obtained by calculating the unique identifier MD5 character string of the equipment to be accessed by adopting the hash function; the MD5 character string of the unique identifier of the equipment to be accessed is obtained by calculating the unique identifier of the equipment to be accessed by adopting the MD5 algorithm.
Further, the device for accessing internet of things equipment through balanced allocation further comprises a fault adjustment module, configured to:
when the access server fails, the equipment accessed to the failed access server is distributed and accessed to the next access server according to a preset sequence, and the failed access server is removed from the consistent hash ring.
Further, the device for accessing internet of things equipment in a balanced distribution manner further comprises a newly added service adjusting module, configured to:
when an access server is newly added, calculating a first hash value of the unique identifier of the newly added access server by adopting the hash function, and inserting the first hash value of the unique identifier of the newly added access server into a corresponding position according to the storage sequence of the ordered data structure;
updating the consistent hash ring according to the ordered data structure after the newly added data, and finding out the next access server of the newly added access server in the consistent hash ring as the access server to be adjusted;
recalculating, comparing and adjusting the binding relationship of the equipment accessed into the access server to be adjusted, and reallocating access to the equipment accessed into the server to be adjusted according to the readjusted binding relationship.
It can be understood that the above-mentioned embodiments of the apparatus item correspond to embodiments of a method item of the present invention, and the apparatus for allocating and accessing devices of the internet of things in a balanced manner provided by the embodiments of the present invention can implement a method for allocating and accessing devices of the internet of things in a balanced manner provided by any one of the embodiments of the method item of the present invention.
While the foregoing is directed to the preferred embodiment of the present invention, it will be understood by those skilled in the art that various changes and modifications may be made without departing from the spirit and scope of the invention.

Claims (10)

1. A method for accessing Internet of things equipment in a balanced distribution mode is characterized by comprising the following steps:
acquiring information of a plurality of devices to be accessed and information of a plurality of access servers; the information of the equipment to be accessed comprises a unique identifier of the equipment to be accessed, and the information of the access server comprises a unique identifier of the access server;
calculating a first hash value of each unique access server identifier by adopting a preset hash function, performing associated storage on each unique access server identifier and the first hash value thereof through a preset ordered data structure, and constructing a consistent hash ring according to the first hash values stored in the ordered data structure in sequence;
calculating a second hash value of the unique identifier of each device to be accessed by adopting the hash function, and comparing each second hash value with the first hash value in the consistent hash ring one by one;
if the candidate hash value set larger than the second hash value is inquired from the consistent hash ring, selecting the smallest first hash value from the candidate hash value set and establishing a binding relationship with the second hash value;
if the candidate hash value set larger than the second hash value is not inquired from the consistent hash ring, selecting the smallest first hash value from the consistent hash ring and establishing a binding relationship with the second hash value;
and distributing and accessing each device to be accessed to the corresponding access server according to the binding relationship.
2. The method for performing balanced distribution access on internet-of-things equipment according to claim 1, wherein the step of calculating the first hash value of the unique identifier of each access server by using a preset hash function, the step of storing the unique identifiers of each access server and the first hash values of the unique identifiers of the access servers in an associated manner by using a preset ordered data structure, and the step of constructing a consistent hash ring according to the first hash values sequentially stored in the ordered data structure specifically comprises the steps of:
converting each access server into a plurality of access server virtual nodes, and allocating a unique identifier to each access server virtual node;
calculating a first hash value of the unique identifier of each access server virtual node by adopting the hash function;
performing associated storage on the unique identifier of each access server virtual node and the first hash value of the unique identifier of each access server virtual node through a preset ordered data structure;
and constructing a consistent hash ring according to the first hash values stored in the ordered data structure in sequence.
3. The method for the balanced distribution access of the internet of things equipment according to claim 1, wherein the first hash value is obtained by calculating an access server unique identifier (MD 5) character string by using the hash function; the access server unique identifier MD5 character string is obtained by calculating the access server unique identifier by adopting an MD5 algorithm;
the second hash value is obtained by calculating the unique identifier MD5 character string of the equipment to be accessed by adopting the hash function; the MD5 character string of the unique identifier of the equipment to be accessed is obtained by calculating the unique identifier of the equipment to be accessed by adopting the MD5 algorithm.
4. The method for the balanced access allocation of the internet of things devices according to claim 1, further comprising:
when the access server fails, the equipment accessed to the failed access server is distributed and accessed to the next access server according to a preset sequence, and the failed access server is removed from the consistent hash ring.
5. The method for the balanced access allocation of the internet of things devices according to claim 1, further comprising:
when an access server is newly added, calculating a first hash value of the unique identifier of the newly added access server by adopting the hash function, and inserting the first hash value of the unique identifier of the newly added access server into a corresponding position according to the storage sequence of the ordered data structure;
updating the consistent hash ring according to the ordered data structure after the newly added data, and finding out the next access server of the newly added access server in the consistent hash ring as the access server to be adjusted;
recalculating, comparing and adjusting the binding relationship of the equipment accessed into the access server to be adjusted, and reallocating access to the equipment accessed into the server to be adjusted according to the readjusted binding relationship.
6. The method for the balanced distribution access of the devices of the internet of things according to any one of claims 1 to 5, wherein the hash function is a BKDR hash function.
7. The utility model provides a device with thing networking equipment balanced distribution access which characterized in that includes:
the information acquisition module is used for acquiring information of a plurality of devices to be accessed and information of a plurality of access servers; the information of the equipment to be accessed comprises a unique identifier of the equipment to be accessed, and the information of the access server comprises a unique identifier of the access server;
the hash ring construction module is used for calculating a first hash value of each unique identifier of the access server by adopting a preset hash function, performing associated storage on each unique identifier of the access server and the first hash value of the unique identifier of the access server through a preset ordered data structure, and constructing a consistent hash ring according to the first hash values stored in the ordered data structure in sequence;
the hash value comparison module is used for calculating a second hash value of the unique identifier of each device to be accessed by adopting the hash function and comparing each second hash value with the first hash value in the consistent hash ring one by one;
the first binding module is used for selecting the smallest first hash value from the candidate hash value sets to establish a binding relationship with the second hash value if the candidate hash value sets larger than the second hash value are inquired from the consistent hash ring;
the second binding module is used for selecting the minimum first hash value from the consistent hash ring and establishing a binding relationship with the second hash value if the candidate hash value set larger than the second hash value is not inquired from the consistent hash ring;
and the equipment access module is used for distributing and accessing each equipment to be accessed to the corresponding access server according to the binding relationship.
8. The apparatus for performing balanced distribution access on internet-of-things devices according to claim 7, wherein the hash ring construction module specifically includes:
the node virtual unit is used for converting each access server into a plurality of access server virtual nodes and distributing a unique identifier to each access server virtual node;
the hash calculation unit is used for calculating a first hash value of the unique identifier of each access server virtual node by adopting the hash function;
the associated storage unit is used for storing the unique identifier of each access server virtual node and the first hash value of the unique identifier of each access server virtual node in an associated manner through a preset ordered data structure;
and the hash ring construction unit is used for constructing a consistent hash ring according to the first hash values sequentially stored in the ordered data structure.
9. The apparatus for performing balanced allocation access on internet of things equipment according to claim 7, wherein the first hash value is obtained by calculating an access server unique identifier MD5 character string by using the hash function; the access server unique identifier MD5 character string is obtained by calculating the access server unique identifier by adopting an MD5 algorithm;
the second hash value is obtained by calculating the unique identifier MD5 character string of the equipment to be accessed by adopting the hash function; the MD5 character string of the unique identifier of the equipment to be accessed is obtained by calculating the unique identifier of the equipment to be accessed by adopting the MD5 algorithm.
10. The apparatus for performing balanced distribution access on internet of things devices according to claim 7, further comprising a fault adjustment module configured to:
when the access server fails, the equipment accessed to the failed access server is distributed and accessed to the next access server according to a preset sequence, and the failed access server is removed from the consistent hash ring.
CN202010433313.1A 2020-05-20 2020-05-20 Method and device for balanced distribution access of Internet of things equipment Pending CN111614760A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010433313.1A CN111614760A (en) 2020-05-20 2020-05-20 Method and device for balanced distribution access of Internet of things equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010433313.1A CN111614760A (en) 2020-05-20 2020-05-20 Method and device for balanced distribution access of Internet of things equipment

Publications (1)

Publication Number Publication Date
CN111614760A true CN111614760A (en) 2020-09-01

Family

ID=72205172

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010433313.1A Pending CN111614760A (en) 2020-05-20 2020-05-20 Method and device for balanced distribution access of Internet of things equipment

Country Status (1)

Country Link
CN (1) CN111614760A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022105298A1 (en) * 2020-11-19 2022-05-27 深圳壹账通智能科技有限公司 Node position determination method and apparatus, computer device and storage medium
CN115113997A (en) * 2022-06-17 2022-09-27 云知声智能科技股份有限公司 Task scheduling method and device, electronic equipment and storage medium
CN115208748A (en) * 2021-04-13 2022-10-18 瞻博网络公司 Network controller horizontal scaling for network device configuration session management
CN115297131A (en) * 2022-08-01 2022-11-04 东北大学 Sensitive data distributed storage method based on consistent hash
CN114448850B (en) * 2021-12-21 2023-11-03 天翼云科技有限公司 Dialing control method, electronic equipment and dialing control system

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106503139A (en) * 2016-10-20 2017-03-15 上海携程商务有限公司 Dynamic data access method and system
CN109040212A (en) * 2018-07-24 2018-12-18 苏州科达科技股份有限公司 Equipment access server cluster method, system, equipment and storage medium
WO2019200714A1 (en) * 2018-04-17 2019-10-24 平安科技(深圳)有限公司 Server connection method, computer readable storage medium, terminal device, and apparatus

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106503139A (en) * 2016-10-20 2017-03-15 上海携程商务有限公司 Dynamic data access method and system
WO2019200714A1 (en) * 2018-04-17 2019-10-24 平安科技(深圳)有限公司 Server connection method, computer readable storage medium, terminal device, and apparatus
CN109040212A (en) * 2018-07-24 2018-12-18 苏州科达科技股份有限公司 Equipment access server cluster method, system, equipment and storage medium

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022105298A1 (en) * 2020-11-19 2022-05-27 深圳壹账通智能科技有限公司 Node position determination method and apparatus, computer device and storage medium
CN115208748A (en) * 2021-04-13 2022-10-18 瞻博网络公司 Network controller horizontal scaling for network device configuration session management
CN115208748B (en) * 2021-04-13 2024-10-01 瞻博网络公司 Network controller horizontal scaling for network device configuration session management
CN114448850B (en) * 2021-12-21 2023-11-03 天翼云科技有限公司 Dialing control method, electronic equipment and dialing control system
CN115113997A (en) * 2022-06-17 2022-09-27 云知声智能科技股份有限公司 Task scheduling method and device, electronic equipment and storage medium
CN115297131A (en) * 2022-08-01 2022-11-04 东北大学 Sensitive data distributed storage method based on consistent hash

Similar Documents

Publication Publication Date Title
CN111614760A (en) Method and device for balanced distribution access of Internet of things equipment
KR102376713B1 (en) Composite partition functions
CN102164360B (en) Method and system for configuring and loading network equipment
CN109040212A (en) Equipment access server cluster method, system, equipment and storage medium
CN112261135A (en) Node election method, system, device and equipment based on consistency protocol
EP3442201B1 (en) Cloud platform construction method and cloud platform
US10761869B2 (en) Cloud platform construction method and cloud platform storing image files in storage backend cluster according to image file type
CN109783564A (en) Support the distributed caching method and equipment of multinode
US11025688B1 (en) Automated streaming data platform
CN105376347A (en) IP address allocation method and system
CN110012111B (en) Data service cluster system and data processing method
CN108228272B (en) WEB container generation processing method, equipment and server
EP3349416B1 (en) Relationship chain processing method and system, and storage medium
US10033817B2 (en) Stateless technique for distributing data uploads
CN110086840A (en) Image data recording method, device and computer readable storage medium
CN114564530A (en) Database access method, device, equipment and storage medium
CN109327520B (en) Method and device for establishing connection between terminal and server node
CN114513490B (en) View library cluster
US20210075682A1 (en) Forming groups of nodes for assignment to a system management server
CN112799849A (en) Data processing method, device, equipment and storage medium
CN106470230A (en) Distributed DNS node data consistency synchronization method and apparatus
CN108733805A (en) File interaction method, system, computer equipment and storage medium
CN117909312A (en) Method, apparatus and program product for processing access requests and updating a storage system
CN115955404B (en) Internet of things scene management method, device, equipment and medium
CN118400339B (en) Tenant management method, device, controller 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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20200901