CN111600799B - Fragment routing method, server and computer storage medium - Google Patents
Fragment routing method, server and computer storage medium Download PDFInfo
- Publication number
- CN111600799B CN111600799B CN202010429890.3A CN202010429890A CN111600799B CN 111600799 B CN111600799 B CN 111600799B CN 202010429890 A CN202010429890 A CN 202010429890A CN 111600799 B CN111600799 B CN 111600799B
- Authority
- CN
- China
- Prior art keywords
- fragment
- target
- user
- identifier
- 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.)
- Active
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L45/00—Routing or path finding of packets in data switching networks
- H04L45/74—Address processing for routing
- H04L45/742—Route cache; Operation thereof
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1097—Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/60—Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
- H04L67/63—Routing a service request depending on the request content or context
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
The embodiment of the application discloses a fragment routing method, a server and a computer storage medium, which are used for solving the technical problem that the data needs to be migrated by an operator because the data stored in fragments reaches the limit. The method of the embodiment of the application comprises the following steps: the method comprises the steps that a server determines idle fragments as default fragments and acquires the corresponding relation between user identifications and fragment identifications, when a target user needs to access the fragments, the server judges whether a target fragment identification corresponding to the user identification of the target user exists in the corresponding relation, if the target user does not exist, the target user is a new user, the server routes an access request to the default fragments, so that the target user can access the default fragments, and as the default fragments are idle fragments comprising idle storage spaces, the data of the new user is not stored in the fragments without the idle storage spaces, so that the data in the fragments without the idle storage spaces are not required to be migrated, the data of the new user can be stored, and the workload of operators is reduced.
Description
Technical Field
The embodiment of the application relates to the field of data processing, in particular to a fragment routing method, a server and a computer storage medium.
Background
The application program manages and stores the data of the application program user by setting the fragments, and when the user needs to request the data, the data request of the user is routed to the designated fragments, so that the user can modify, inquire, acquire the data and execute other operations on the data in the fragments. The data of one user can be stored in only one fragment and cannot be stored in a plurality of fragments; one tile may store data for multiple users.
Because the load of a shard is limited, one shard can only store a certain amount of data, and when more and more users store data in a source shard, the storage pressure of the source shard is increased, which affects the execution performance of the source shard. At this time, an operator is required to migrate data of a part of users of the source shard to the target shard, so as to share the storage pressure of the source shard.
However, if a new user needs to store data, the data of the new user still can be stored in the source fragment, and as new users increase, the data stored in the source fragment eventually reaches the limit, so that the data needs to be migrated again, which undoubtedly increases the workload of the operator.
Disclosure of Invention
The embodiment of the application provides a fragment routing method, a server and a computer storage medium, which are used for solving the technical problem that data needs to be migrated by an operator due to the fact that data stored in fragments reaches the limit.
A first aspect of the embodiments of the present application provides a fragment routing method, which is applied to a server, and the method includes:
determining an idle fragment as a default fragment, wherein the idle fragment is a fragment comprising an idle storage space;
acquiring a corresponding relation between user identifications and fragment identifications, wherein one user identification corresponds to one fragment identification;
receiving an access request of a target user, wherein the access request carries a user identifier of the target user;
judging whether a target fragment identifier corresponding to the user identifier of the target user exists in the corresponding relation;
if so, routing the access request to the fragment corresponding to the target fragment identifier;
if not, the access request is routed to the default fragment.
Preferably, the number of the idle segments is multiple, and the determining the idle segments as default segments includes:
and determining the idle fragment with the largest free storage space in the plurality of idle fragments as the default fragment.
Preferably, the determining the idle segment as the default segment includes:
and newly building the fragments, and determining the newly built fragments as the default fragments.
Preferably, the obtaining the corresponding relationship between the user identifier and the segment identifier includes:
and establishing a routing table comprising the user identification and the fragment identification, wherein the routing table is used for indicating the fragment to which the access request of the user is routed.
Preferably, the method further comprises:
storing the routing table in a database;
the determining whether the corresponding relationship has a target fragment identifier corresponding to the user identifier of the target user includes:
inquiring a target fragment identifier corresponding to the user identifier of the target user in the routing table stored in the database;
if the target fragment identification exists, the access request is routed to the fragment corresponding to the target fragment identification;
and if the target fragment identification does not exist, routing the access request to the default fragment.
Preferably, the method further comprises:
backing up the routing table in a cache;
before the target segment identifier corresponding to the user identifier of the target user is queried in the routing table stored in the database, the method further includes:
inquiring a target fragment identifier corresponding to the user identifier of the target user in the routing table stored in the cache;
if the target fragment identification exists, the access request is routed to the fragment corresponding to the target fragment identification;
and if the target fragment identifier does not exist, executing the step of inquiring the target fragment identifier corresponding to the user identifier of the target user in the routing table stored in the database.
Preferably, if the target fragment identifier does not exist, after the access request is routed to the default fragment, the method further includes:
and establishing a target corresponding relation between the user identification of the target user and the fragment identification of the idle fragment, and writing the target corresponding relation into the database and/or the routing table stored in the cache.
Preferably, the number of the idle segments is multiple, and the determining the idle segments as default segments includes:
determining a target idle fragment of the plurality of idle fragments as the default fragment;
the method further comprises the following steps:
and when the free storage space of the target free fragment is insufficient, changing the configuration of the default fragment, and determining other free fragments except the target free fragment in the plurality of free fragments as default fragments.
A second aspect of an embodiment of the present application provides a server, including:
the device comprises a determining unit, a judging unit and a judging unit, wherein the determining unit is used for determining an idle fragment as a default fragment, and the idle fragment is a fragment comprising an idle storage space;
the device comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring the corresponding relation between user identifications and fragment identifications, and one user identification corresponds to one fragment identification;
a receiving unit, configured to receive an access request of a target user, where the access request carries a user identifier of the target user;
a judging unit, configured to judge whether a target segment identifier corresponding to the user identifier of the target user exists in the correspondence;
a first routing unit, configured to route the access request to a segment corresponding to a target segment identifier when the target segment identifier corresponding to a user identifier of the target user exists;
and the second routing unit is used for routing the access request to the default fragment when the target fragment identifier corresponding to the user identifier of the target user does not exist.
Preferably, the number of the idle segments is multiple, and the determining unit is specifically configured to determine an idle segment with the largest idle storage space among the multiple idle segments as the default segment.
Preferably, the determining unit is specifically configured to newly create a segment, and determine the newly created segment as the default segment.
Preferably, the obtaining unit is specifically configured to establish a routing table including the user identifier and the segment identifier, where the routing table is used to indicate a segment to which an access request of a user is routed.
Preferably, the server further includes:
a storage unit for storing the routing table in a database;
the judging unit is specifically configured to query, in the routing table stored in the database, a target fragment identifier corresponding to a user identifier of the target user, and route, when the target fragment identifier exists, the access request to a fragment corresponding to the target fragment identifier; and when the target fragment identification does not exist, routing the access request to the default fragment.
Preferably, the server further includes:
the backup unit is used for backing up the routing table in a cache;
the judging unit is further configured to query a target segment identifier corresponding to the user identifier of the target user in the routing table stored in the cache, route the access request to a segment corresponding to the target segment identifier when the target segment identifier exists, and execute the step of querying the target segment identifier corresponding to the user identifier of the target user in the routing table stored in the database when the target segment identifier does not exist.
Preferably, the server further includes:
and the establishing unit is used for establishing a target corresponding relation between the user identifier of the target user and the fragment identifier of the idle fragment, and writing the target corresponding relation into the database and/or the routing table stored in the cache.
Preferably, the number of the idle segments is multiple, and the determining unit is specifically configured to determine a target idle segment of the multiple idle segments as the default segment;
the determining unit is further configured to, when the free storage space of the target free segment is insufficient, change the configuration of the default segment, and determine, as the default segment, an idle segment other than the target free segment in the plurality of idle segments.
A third aspect of an embodiment of the present application provides a server, including:
a processor, a memory, an input and output device;
the processor is connected with the memory and the input and output equipment;
the processor is configured to determine an idle segment as a default segment, where the idle segment is a segment including an idle storage space, and obtain a correspondence between user identifiers and segment identifiers, where one user identifier corresponds to one segment identifier;
the input and output equipment is used for receiving an access request of a target user, and the access request carries a user identifier of the target user;
the processor is further configured to determine whether a target segment identifier corresponding to the user identifier of the target user exists in the correspondence, route the access request to a segment corresponding to the target segment identifier when the target segment identifier corresponding to the user identifier of the target user exists, and route the access request to the default segment when the target segment identifier corresponding to the user identifier of the target user does not exist.
A fourth aspect of embodiments of the present application provides a computer storage medium having instructions stored therein, which when executed on a computer, cause the computer to perform the method of the first aspect.
According to the technical scheme, the embodiment of the application has the following advantages:
the server determines the idle fragment as a default fragment and acquires the corresponding relation between the user identifier and the fragment identifier, when a target user needs to access the fragment, the server judges whether a target fragment identifier corresponding to the user identifier of the target user exists in the corresponding relation, if so, the server routes the access request to the fragment corresponding to the target fragment identifier, and the target user can access the fragment corresponding to the target fragment identifier; if the target user is not the new user, the server routes the access request to the default fragment, so that the target user accesses the default fragment, and because the default fragment is an idle fragment comprising an idle storage space, the data of the new user is not stored in the fragment without the idle storage space, so that the data of the new user can be stored without migrating the data in the fragment without the idle storage space, and the workload of operators is reduced.
Drawings
Fig. 1 is a schematic flow chart of a fragment routing method in an embodiment of the present application;
fig. 2 is another schematic flow chart of a fragment routing method in the embodiment of the present application;
FIG. 3 is a schematic structural diagram of a server in an embodiment of the present application;
FIG. 4 is a schematic diagram of another server in the embodiment of the present application;
fig. 5 is another schematic structural diagram of a server in the embodiment of the present application.
Detailed Description
The embodiment of the application provides a fragment routing method, a server and a computer storage medium, which are used for solving the technical problem that data needs to be migrated by an operator due to the fact that data stored in fragments reaches the limit.
Referring to fig. 1, an embodiment of a fragment routing method in the embodiment of the present application includes:
101. determining the idle fragment as a default fragment;
the method of the embodiment can be applied to a server, which may be an application server or a network server (WEB server), or other servers that can provide business services for users and process business data.
The server uses fragmentation to store user data. In order to reasonably use the storage resources of the fragments, the server determines the idle fragments as default fragments, wherein the idle fragments refer to the fragments with idle storage space, and the idle storage space refers to the storage space without user data. The free slice determined as the default slice may be used for storing user data.
102. Acquiring a corresponding relation between a user identifier and a fragment identifier;
in this embodiment, one slice may store data of a plurality of different users, but one user can only store data in one slice, but cannot store data in a plurality of slices respectively. That is, one user may correspond to one tile, and one tile may correspond to one or more users. Therefore, the server may obtain the correspondence between the user identifiers of the multiple users and the segment identifiers of the segments, that is, one user identifier corresponds to the segment identifier of one segment, and the segment identifier of one segment may correspond to the user identifier of one or more users.
Therefore, when the user identifier of a user has a corresponding fragment identifier, data indicating the user is stored in the fragment corresponding to the fragment identifier.
103. Receiving an access request of a target user;
when a target user needs to access a fragment in a server, the target user initiates an access request to the server, and the access request carries a user identifier of the target user, so that the server can receive the access request of the target user.
The target user accessing the fragment may be the target user modifying, querying, acquiring data and performing other operations on the data in the fragment.
104. Judging whether a target fragment identifier corresponding to the user identifier of the target user exists in the corresponding relation, if so, executing the step 105; if not, go to step 106;
after receiving the access request of the target user and the user identifier of the target user, the server determines whether the corresponding relationship obtained in step 102 has the fragment identifier corresponding to the user identifier of the target user, and if yes, executes step 105; if not, go to step 106. For convenience of description, in this embodiment, a segment identifier corresponding to a user identifier of a target user is referred to as a target segment identifier.
105. Routing the access request to the fragment corresponding to the target fragment identifier;
when the server determines that the target fragment identifier exists, it indicates that the target user uses the fragment in the server to store data, and the fragment corresponding to the target user is the fragment corresponding to the target fragment identifier, the server may determine that the target user needs to access the fragment corresponding to the target fragment identifier, so as to route the access request to the fragment corresponding to the target fragment identifier, and further the target user may access the fragment corresponding to the target fragment identifier, for example, modify or query the data of the target user stored in the fragment, or store new user data to the fragment, and so on.
106. Routing the access request to a default fragment;
when the server determines that the target shard identification does not exist, indicating that the target user has not used shards in the server to store data, i.e., indicating that the target user is a new user, the server routes the target user's access request to the default shard so that the target user can access the default shard, e.g., store data in the default shard, or query stored data, etc. Wherein the default shard is the free shard having free storage space in step 101.
In the embodiment, the server determines the idle fragment as a default fragment and acquires the corresponding relation between the user identifier and the fragment identifier, when a target user needs to access the fragment, the server judges whether a target fragment identifier corresponding to the user identifier of the target user exists in the corresponding relation, if so, the server routes the access request to the fragment corresponding to the target fragment identifier, and the target user can access the fragment corresponding to the target fragment identifier; if the target user is not the new user, the server routes the access request to the default fragment, so that the target user accesses the default fragment, and because the default fragment is an idle fragment comprising an idle storage space, the data of the new user is not stored in the fragment without the idle storage space, so that the data of the new user can be stored without migrating the data in the fragment without the idle storage space, and the workload of operators is reduced.
The embodiments of the present application will be described in further detail below on the basis of the aforementioned embodiment shown in fig. 1. Referring to fig. 2, another embodiment of the fragment routing method in the embodiment of the present application includes:
201. determining the idle fragment as a default fragment;
the operation performed in this step is similar to the operation performed in step 101 in the embodiment shown in fig. 1. In this embodiment, the manner in which the server determines the idle segment as the default segment may be that, when there are multiple idle segments, the server selects an idle segment with the largest idle storage space among the multiple idle segments as the default segment, so that it can be ensured that the storage space of the default segment is sufficiently used, and a situation that the storage space is insufficient again after the segment with the smaller idle storage space is used for a short time is avoided.
In addition, the idle segment may be determined as the default segment by newly creating a new segment and determining the newly created segment as the default segment, and because the newly created segment does not store any user data, the idle storage space of the newly created segment is also sufficient to be used for storing user data.
In this embodiment, the default fragment may be configured by an Apollo (Apollo) configuration center, that is, an idle fragment in the server is determined as the default fragment by the Apollo configuration center. After the Apollo configuration center completes configuration, the server may be notified of the configuration of the default shard.
It should be noted that the configuration default partition may also pass through other configuration centers, for example, a Spring Cloud Config center or a Nacos configuration center, which is not limited herein.
In this embodiment, the server may determine the idle segment as the default segment in other manners, for example, determine any idle segment of the idle segments as the default segment, and the present embodiment does not limit the manner in which the idle segment is determined as the default segment.
202. Acquiring a corresponding relation between a user identifier and a fragment identifier;
the operation performed in this step is similar to the operation performed in step 102 in the embodiment shown in fig. 1. In this embodiment, the server may represent the correspondence between the user identifier and the segment identifier in the form of a routing table, that is, a routing table including the user identifier and the segment identifier is established, where the routing table is used to represent a segment to which an access request of a user is routed, that is, a certain segment to which an access request of a certain user is routed. For example, in the routing table, the user id may be represented by dbid, the fragment id may be represented by a shard, two user ids dbid-A, dbid-B are under the dbid item, two fragments shrd-0 and shrd-1 are under the shrd item, dbid-a corresponds to shrd-0, and dbid-B corresponds to shrd-1, and the routing table indicates that the access request of the user of dbid-a should be routed to fragment shrd-0, and the access request of the user of dbid-B should be routed to fragment shrd-1.
It should be noted that the above example is only an exemplary function, and the user identifier and the fragment identifier may be represented by any symbols as long as each user identifier and each fragment identifier can be distinguished.
In this embodiment, the corresponding relationship between the user identifier and the fragment identifier may also be represented without using a form of a routing table, or the corresponding relationship may also be directly represented, which is not limited herein.
203. Receiving an access request of a target user;
the operation performed in this step is similar to the operation performed in step 103 in the embodiment shown in fig. 1, and is not described here again.
204. Inquiring a target fragment identifier corresponding to the user identifier of the target user in a routing table stored in the cache, and if the target fragment identifier exists, executing step 205; if the target fragment identifier does not exist, executing step 206;
in this embodiment, the correspondence between the user identifier and the fragment identifier obtained in step 202 may be stored in a database and/or a cache, and when the correspondence is represented in the form of a routing table, the routing table is stored in the database and/or the cache.
After receiving the access request of the target user and the user identifier of the target user, the server needs to determine whether the corresponding relationship obtained in step 202 has the segment identifier corresponding to the user identifier of the target user, that is, to query the routing table stored in the database for the target segment identifier corresponding to the user identifier of the target user. Because the database may cause a large database processing pressure when processing a plurality of requests, the speed of processing the requests by the database is reduced, and user experience is affected, for this reason, the cache may be used to backup the routing table, and before querying the target fragment identifier from the database, the target fragment identifier corresponding to the user identifier of the target user may be queried in the routing table stored in the cache in advance, if the target fragment identifier can be queried in the cache, step 205 is executed; if the target fragment identifier is not found, step 206 is executed.
The target fragment identification is inquired in the cache in advance, so that the processing pressure of the database can be relieved to a certain extent, and the inquiry speed is improved.
Wherein the cache may be a Redis cache, a Memcached cache, or other type of server cache. When backing up the routing table, a cache structure with the user identifier as key and the fragment identifier as value can be established.
205. Routing the access request to the fragment corresponding to the target fragment identifier;
when the target fragment identifier can be inquired in the cache, the access request is routed to the fragment corresponding to the target fragment identifier, and the target user can access the fragment corresponding to the target fragment identifier.
206. Executing a step of inquiring a target fragment identifier corresponding to the user identifier of the target user in a routing table stored in a database;
when the target fragment identifier is not queried in the cache, possibly because the routing table backed up by the cache is not updated, the target fragment identifier may exist in the routing table stored in the database, and therefore, the target fragment identifier may continue to be queried in the routing table stored in the database at this time.
In this embodiment, if the processing capability of the database is strong and the processing resources are sufficient, the routing table may not be backed up by using the cache, and the target segment identifier may not be queried in the cache in advance, but may be directly queried in the database, which is not limited in this embodiment.
207. Judging whether a target fragment identifier corresponding to the user identifier of the target user exists in the corresponding relation, if so, executing the step 208; if not, go to step 209;
when the target fragment identifier is not queried in the cache, the target fragment identifier needs to be continuously queried in a routing table stored in the database. If the target fragment identifier can be queried in the database, executing step 208; if the target fragment id is not queried in the database, step 209 is performed.
208. Routing the access request to the fragment corresponding to the target fragment identifier;
when the target fragment identifier can be inquired in the database, the access request is routed to the fragment corresponding to the target fragment identifier, and the target user can access the fragment corresponding to the target fragment identifier.
209. Routing the access request to a default fragment;
if the database still cannot inquire the target fragment identification, the target user is indicated that the target user does not use the fragments in the server to store data, namely the target user is indicated as a new user, the server routes the access request of the target user to the default fragment, and therefore the target user can access the default fragment.
In this embodiment, the database may be a relational database or a non-relational database, the relational database may be a PostgreSQL database, a MySQL database, an Oracle database, a MongoDB database, or another relational database, and the preferred database is the PostgreSQL database.
210. Establishing a target corresponding relation between a user identifier of a target user and a fragment identifier of an idle fragment, and writing the target corresponding relation into a database and/or a cache;
after the server routes the access request of the target user to the default fragment, a target correspondence between the user identifier of the target user and the fragment identifier of the idle fragment is established, where the idle fragment in the target correspondence is the idle fragment determined as the default fragment in step 201.
After the server establishes the target corresponding relationship, the target corresponding relationship is written into the database and/or the cache, so that the routing table in the database and/or the cache can update the corresponding relationship represented by the routing table.
In this embodiment, there may be a plurality of idle segments, and an idle segment determined as a default segment among the plurality of idle segments may be referred to as a target idle segment. When the free storage space of the target idle segment is insufficient, the server may change the configuration of the default segment, that is, determine other idle segments of the idle segments except the target idle segment as default segments, and may store the data of the new user by using the other idle segments determined as default segments, so that the configuration of the default segment may be flexibly and dynamically changed.
The fragment routing method in the embodiment of the present application is described above, and a server in the embodiment of the present application is described below with reference to fig. 3, where an embodiment of the server in the embodiment of the present application includes:
a determining unit 301, configured to determine an idle segment as a default segment, where the idle segment is a segment including an idle storage space;
an obtaining unit 302, configured to obtain a correspondence between user identifiers and segment identifiers, where one user identifier corresponds to one segment identifier;
a receiving unit 303, configured to receive an access request of a target user, where the access request carries a user identifier of the target user;
a determining unit 304, configured to determine whether a target segment identifier corresponding to the user identifier of the target user exists in the correspondence;
a first routing unit 305, configured to route, when there is a target segment identifier corresponding to a user identifier of a target user, an access request to a segment corresponding to the target segment identifier;
and the second routing unit 306 is configured to route the access request to the default fragment when the target fragment identifier corresponding to the user identifier of the target user does not exist.
In this embodiment, operations performed by each unit in the server are similar to those described in the embodiment shown in fig. 1, and are not described again here.
In this embodiment, the determining unit 301 determines the idle segment as a default segment, the obtaining unit 302 obtains a correspondence between a user identifier and a segment identifier, when a target user needs to access a segment, the determining unit 304 determines whether a target segment identifier corresponding to the user identifier of the target user exists in the correspondence, if so, the first routing unit 305 routes the access request to the segment corresponding to the target segment identifier, and the target user can access the segment corresponding to the target segment identifier; if the default fragment is the idle fragment including the idle storage space, the data of the new user is not stored in the fragment without the idle storage space, so that the data of the new user can be stored without migrating the data in the fragment without the idle storage space, and the workload of an operator is reduced.
Referring to fig. 4, an embodiment of a server in the embodiment of the present application includes:
a determining unit 401, configured to determine an idle segment as a default segment, where the idle segment is a segment including an idle storage space;
an obtaining unit 402, configured to obtain a correspondence between user identifiers and segment identifiers, where one user identifier corresponds to one segment identifier;
a receiving unit 403, configured to receive an access request of a target user, where the access request carries a user identifier of the target user;
a determining unit 404, configured to determine whether a target segment identifier corresponding to the user identifier of the target user exists in the correspondence;
a first routing unit 405, configured to route, when a target segment identifier corresponding to a user identifier of a target user exists, an access request to a segment corresponding to the target segment identifier;
and the second routing unit 406 is configured to route the access request to the default fragment when the target fragment identifier corresponding to the user identifier of the target user does not exist.
In a preferred embodiment of this embodiment, the number of the idle segments is multiple, and the determining unit 401 is specifically configured to determine an idle segment with the largest idle storage space among the multiple idle segments as a default segment.
In another preferred embodiment of this embodiment, the determining unit 401 is specifically configured to newly create a segment, and determine the newly created segment as a default segment.
In another preferred implementation manner of this embodiment, the obtaining unit 402 is specifically configured to establish a routing table including a user identifier and a segment identifier, where the routing table is used to indicate a segment to which an access request of a user is routed.
In another preferred implementation manner of this embodiment, the server further includes:
a storage unit 407 for storing the routing table in a database;
the determining unit 404 is specifically configured to query, in a routing table stored in the database, a target fragment identifier corresponding to a user identifier of a target user, and route, when the target fragment identifier exists, an access request to a fragment corresponding to the target fragment identifier; and when the target fragment identification does not exist, routing the access request to the default fragment.
In another preferred implementation manner of this embodiment, the server further includes:
a backup unit 408, configured to backup the routing table in the cache;
the determining unit 404 is further configured to query a target segment identifier corresponding to the user identifier of the target user in the routing table stored in the cache, route the access request to the segment corresponding to the target segment identifier when the target segment identifier exists, and execute the step of querying the target segment identifier corresponding to the user identifier of the target user in the routing table stored in the database when the target segment identifier does not exist.
In another preferred implementation manner of this embodiment, the server further includes:
the establishing unit 409 is configured to establish a target correspondence between a user identifier of a target user and a segment identifier of an idle segment, and write the target correspondence into a routing table stored in a database and/or a cache.
In another preferred embodiment of this embodiment, the number of idle segments is multiple, and the determining unit 401 is specifically configured to determine a target idle segment in the multiple idle segments as a default segment;
the determining unit 401 is further configured to, when the free storage space of the target free segment is insufficient, change the configuration of the default segment, and determine, as the default segment, another free segment of the plurality of free segments except the target free segment.
In this embodiment, operations performed by each unit in the server are similar to those described in the embodiment shown in fig. 2, and are not described again here.
Referring to fig. 5, a server in an embodiment of the present application is described below, where an embodiment of the server in the embodiment of the present application includes:
the server 500 may include one or more Central Processing Units (CPUs) 501 and a memory 505, where one or more applications or data are stored in the memory 505.
The server 500 may also include one or more power supplies 502, one or more wired or wireless network interfaces 503, one or more input-output interfaces 504, and/or one or more operating systems, such as Windows Server, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
The central processing unit 501 may perform the operations performed by the server in the embodiments shown in fig. 1 to fig. 2, and details thereof are not repeated herein.
An embodiment of the present application further provides a computer storage medium, where one embodiment includes: the computer storage medium has stored therein instructions that, when executed on a computer, cause the computer to perform the operations performed by the server in the embodiments of fig. 1-2.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed to by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a read-only memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and the like.
Claims (11)
1. A method for fragment routing, applied to a server, the method comprising:
determining an idle fragment as a default fragment, wherein the idle fragment is a fragment comprising an idle storage space;
acquiring a corresponding relation between user identifications and fragment identifications, wherein one user identification corresponds to one fragment identification;
receiving an access request of a target user, wherein the access request carries a user identifier of the target user;
judging whether a target fragment identifier corresponding to the user identifier of the target user exists in the corresponding relation;
if so, routing the access request to the fragment corresponding to the target fragment identifier;
and if not, routing the access request to the default fragment.
2. The fragment routing method according to claim 1, wherein the number of the idle fragments is plural, and the determining the idle fragment as a default fragment comprises:
and determining the idle fragment with the largest free storage space in the plurality of idle fragments as the default fragment.
3. The fragment routing method according to claim 1, wherein the determining idle fragments as default fragments comprises:
and newly building the fragments, and determining the newly built fragments as the default fragments.
4. The fragment routing method according to claim 1, wherein the obtaining the correspondence between the user identifier and the fragment identifier includes:
and establishing a routing table comprising the user identification and the fragment identification, wherein the routing table is used for indicating the fragment to which the access request of the user is routed.
5. The method of claim 4, further comprising:
storing the routing table in a database;
the determining whether the corresponding relationship has a target fragment identifier corresponding to the user identifier of the target user includes:
inquiring a target fragment identifier corresponding to the user identifier of the target user in the routing table stored in the database;
if the target fragment identification exists, the access request is routed to the fragment corresponding to the target fragment identification;
and if the target fragment identification does not exist, routing the access request to the default fragment.
6. The fragment routing method according to claim 5, wherein the method further comprises:
backing up the routing table in a cache;
before the target segment identifier corresponding to the user identifier of the target user is queried in the routing table stored in the database, the method further includes:
inquiring a target fragment identifier corresponding to the user identifier of the target user in the routing table stored in the cache;
if the target fragment identification exists, the access request is routed to the fragment corresponding to the target fragment identification;
and if the target fragment identifier does not exist, executing the step of inquiring the target fragment identifier corresponding to the user identifier of the target user in the routing table stored in the database.
7. The fragment routing method according to claim 6, wherein if the target fragment identifier does not exist, the method further comprises, after routing the access request to the default fragment:
and establishing a target corresponding relation between the user identification of the target user and the fragment identification of the idle fragment, and writing the target corresponding relation into the database and/or the routing table stored in the cache.
8. The fragment routing method according to any one of claims 1 to 7, wherein the number of idle fragments is plural, and the determining idle fragments as default fragments includes:
determining a target idle fragment of the plurality of idle fragments as the default fragment;
the method further comprises the following steps:
and when the free storage space of the target free fragment is insufficient, changing the configuration of the default fragment, and determining other free fragments except the target free fragment in the plurality of free fragments as default fragments.
9. A server, characterized in that the server comprises:
the device comprises a determining unit, a judging unit and a judging unit, wherein the determining unit is used for determining an idle fragment as a default fragment, and the idle fragment is a fragment comprising an idle storage space;
the device comprises an acquisition unit, a fragmentation unit and a processing unit, wherein the acquisition unit is used for acquiring the corresponding relation between user identifications and fragmentation identifications, and one user identification corresponds to one fragmentation identification;
a receiving unit, configured to receive an access request of a target user, where the access request carries a user identifier of the target user;
a judging unit, configured to judge whether a target segment identifier corresponding to the user identifier of the target user exists in the correspondence;
a first routing unit, configured to route the access request to a segment corresponding to a target segment identifier when the target segment identifier corresponding to a user identifier of the target user exists;
and the second routing unit is used for routing the access request to the default fragment when the target fragment identifier corresponding to the user identifier of the target user does not exist.
10. A server, characterized in that the server comprises:
a processor, a memory, an input and output device;
the processor is connected with the memory and the input and output equipment;
the processor is configured to determine an idle segment as a default segment, where the idle segment is a segment including an idle storage space, and obtain a correspondence between user identifiers and segment identifiers, where one user identifier corresponds to one segment identifier;
the input and output equipment is used for receiving an access request of a target user, and the access request carries a user identifier of the target user;
the processor is further configured to determine whether a target segment identifier corresponding to the user identifier of the target user exists in the correspondence, route the access request to a segment corresponding to the target segment identifier when the target segment identifier corresponding to the user identifier of the target user exists, and route the access request to the default segment when the target segment identifier corresponding to the user identifier of the target user does not exist.
11. A computer storage medium having stored therein instructions that, when executed on a computer, cause the computer to perform the method of any one of claims 1 to 8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010429890.3A CN111600799B (en) | 2020-05-20 | 2020-05-20 | Fragment routing method, server and computer storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010429890.3A CN111600799B (en) | 2020-05-20 | 2020-05-20 | Fragment routing method, server and computer storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111600799A CN111600799A (en) | 2020-08-28 |
CN111600799B true CN111600799B (en) | 2022-05-20 |
Family
ID=72182758
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010429890.3A Active CN111600799B (en) | 2020-05-20 | 2020-05-20 | Fragment routing method, server and computer storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111600799B (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113347094B (en) * | 2021-06-22 | 2022-05-20 | 深圳壹账通智能科技有限公司 | Fragment routing method, device, equipment and storage medium |
CN114466004A (en) * | 2022-03-24 | 2022-05-10 | 成都新希望金融信息有限公司 | File transmission method, system, electronic equipment and storage medium |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105975345A (en) * | 2016-05-20 | 2016-09-28 | 江苏得得空间信息科技有限公司 | Video frame data dynamic equilibrium memory management method based on distributed memory |
CN106503010A (en) * | 2015-09-07 | 2017-03-15 | 北京国双科技有限公司 | A kind of method and device of database change write subregion |
CN106980669A (en) * | 2017-03-23 | 2017-07-25 | 珠海格力电器股份有限公司 | Data storage and acquisition method and device |
CN107948293A (en) * | 2017-11-29 | 2018-04-20 | 重庆邮电大学 | One kind is based on MongoDB load balance optimization system and methods |
CN110737663A (en) * | 2019-10-15 | 2020-01-31 | 腾讯科技(深圳)有限公司 | data storage method, device, equipment and storage medium |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105045877B (en) * | 2015-07-20 | 2018-10-12 | 深信服科技股份有限公司 | Database data fragment storage method and device, data query method and apparatus |
CN106502576B (en) * | 2015-09-06 | 2020-06-23 | 中兴通讯股份有限公司 | Migration strategy adjusting method and device |
CN106775470B (en) * | 2016-12-08 | 2020-04-10 | 武汉斗鱼网络科技有限公司 | Data storage method and system |
CN106777225B (en) * | 2016-12-26 | 2021-04-06 | 腾讯科技(深圳)有限公司 | Data migration method and system |
CN110019125B (en) * | 2017-11-27 | 2021-12-14 | 北京京东尚科信息技术有限公司 | Database management method and device |
-
2020
- 2020-05-20 CN CN202010429890.3A patent/CN111600799B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106503010A (en) * | 2015-09-07 | 2017-03-15 | 北京国双科技有限公司 | A kind of method and device of database change write subregion |
CN105975345A (en) * | 2016-05-20 | 2016-09-28 | 江苏得得空间信息科技有限公司 | Video frame data dynamic equilibrium memory management method based on distributed memory |
CN106980669A (en) * | 2017-03-23 | 2017-07-25 | 珠海格力电器股份有限公司 | Data storage and acquisition method and device |
CN107948293A (en) * | 2017-11-29 | 2018-04-20 | 重庆邮电大学 | One kind is based on MongoDB load balance optimization system and methods |
CN110737663A (en) * | 2019-10-15 | 2020-01-31 | 腾讯科技(深圳)有限公司 | data storage method, device, equipment and storage medium |
Non-Patent Citations (1)
Title |
---|
"Server-storage virtualization: Integration and load balancing in data centers";Aameek Singh,等;《SC "08: Proceedings of the 2008 ACM/IEEE Conference on Supercomputing》;20090825;第1-12页 * |
Also Published As
Publication number | Publication date |
---|---|
CN111600799A (en) | 2020-08-28 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111600799B (en) | Fragment routing method, server and computer storage medium | |
CN110019125B (en) | Database management method and device | |
US9489429B2 (en) | Computer system, data management method, and program | |
US20200310859A1 (en) | System and method for an object layer | |
CN104954468A (en) | Resource allocation method and resource allocation device | |
WO2014081869A2 (en) | Distributed caching cluster management | |
CN109933585B (en) | Data query method and data query system | |
CN107368358B (en) | Device and method for realizing migration of virtual machine of client among different hosts | |
US20200409584A1 (en) | Load balancing for scalable storage system | |
US9529772B1 (en) | Distributed caching cluster configuration | |
CN110532123B (en) | Fault transfer method and device of HBase system | |
US11809382B2 (en) | System and method for supporting versioned objects | |
EP3217738A1 (en) | M2m node management method and apparatus, and computer storage medium | |
US20230305869A1 (en) | Dynamic allocation of host devices in bare metal distributed computing environments | |
CN110569225A (en) | Data storage method and system | |
CN116032930A (en) | Network storage method, storage system, data processing unit and computer system | |
CN110196750B (en) | Equipment distribution method and related equipment thereof | |
US11881996B2 (en) | Input and output for target device communication | |
CN111767282A (en) | MongoDB-based storage system, data insertion method and storage medium | |
CN111338778A (en) | Task scheduling method and device, storage medium and computer equipment | |
US10338849B2 (en) | Method and device for processing I/O request in network file system | |
CN112965935A (en) | Data processing method and distributed file system | |
CN115729693A (en) | Data processing method and device, computer equipment and computer readable storage medium | |
CN113687910A (en) | Method, device, equipment and storage medium for managing USB (universal serial bus) equipment in cluster | |
CN112799849A (en) | Data processing method, device, equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |