CN117827458A - Resource matching method and device, electronic equipment and storage medium - Google Patents

Resource matching method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117827458A
CN117827458A CN202410012479.4A CN202410012479A CN117827458A CN 117827458 A CN117827458 A CN 117827458A CN 202410012479 A CN202410012479 A CN 202410012479A CN 117827458 A CN117827458 A CN 117827458A
Authority
CN
China
Prior art keywords
service
environment
client
identification information
instance
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
CN202410012479.4A
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.)
Guangdong Bozhong Intelligent Technology Investment Co ltd
Original Assignee
Guangdong Bozhong Intelligent Technology Investment 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 Guangdong Bozhong Intelligent Technology Investment Co ltd filed Critical Guangdong Bozhong Intelligent Technology Investment Co ltd
Priority to CN202410012479.4A priority Critical patent/CN117827458A/en
Publication of CN117827458A publication Critical patent/CN117827458A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/505Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the load
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5083Techniques for rebalancing the load in a distributed system

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention discloses a resource matching method, a device, electronic equipment and a storage medium. The resource matching method comprises the following steps: acquiring a service request and identification information sent by a client; determining a service environment corresponding to the client according to the identification information; determining a target service instance of the service environment according to the service request and a preset load rule; responding to the service request sent by the client based on the target service instance. According to the embodiment of the invention, the corresponding service environments are accessed by combining the identification information of the client, the environments are isolated, different clients are divided into different service environments, meanwhile, the target service instance is determined based on the preset load rule, and the service request is processed based on the target service instance, so that the service request can be effectively processed.

Description

Resource matching method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and apparatus for resource matching, an electronic device, and a storage medium.
Background
A distributed system is a system consisting of a set of computer nodes that communicate over a network to coordinate work in order to accomplish a common task. In the current distributed application environment with separated front and back ends, all services, middleware and databases can be deployed on a server, distributed services are connected through registration to the same service registration center, and the distributed services are operated by using a common message queue through load balancing.
However, each service can only provide one version of service, and stability is low when used as a test environment. If a set of environment is redeployed according to service requirements, service, middleware and environment configuration are required to be reconstructed, a great deal of manpower and computing resources are wasted, and the cost is increased. Therefore, how to isolate the service environment and simultaneously perform resource matching becomes a current urgent problem to be solved.
Disclosure of Invention
The invention provides a resource matching method, a device, electronic equipment and a storage medium, which are used for isolating service environments, simultaneously determining service instances corresponding to service requests conveniently and rapidly and ensuring that the service requests can be processed rapidly.
According to an aspect of the present invention, there is provided a resource matching method, wherein the method includes:
acquiring a service request and identification information sent by a client;
determining a service environment corresponding to the client according to the identification information;
determining a target service instance of the service environment according to the service request and a preset load rule;
responding to the service request sent by the client based on the target service instance.
According to another aspect of the present invention, there is provided a resource matching apparatus, wherein the apparatus includes:
the identification information extraction module is used for acquiring the service request and the identification information sent by the client;
the service environment determining module is used for determining the service environment corresponding to the client according to the identification information;
the service instance determining module is used for determining a target service instance of the service environment according to the service request and a preset load rule;
and the service request processing module is used for responding to the service request sent by the client based on the target service instance.
According to another aspect of the present invention, there is provided an electronic apparatus including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the resource matching method of any one of the embodiments of the present invention.
According to another aspect of the present invention, there is provided a computer readable storage medium storing computer instructions for causing a processor to implement the resource matching method according to any of the embodiments of the present invention when executed.
According to the technical scheme, the service request and the identification information sent by the client are obtained, the service environment corresponding to the client is determined according to the identification information, the target service instance of the service environment is determined according to the service request and the preset load rule, the service request sent by the client is responded based on the target service instance, the corresponding service environment is accessed by combining the identification information of the client, the environment is isolated, different clients are divided into different service environments, meanwhile, the target service instance is determined based on the preset load rule, and the service request is processed based on the target service instance, so that the service request can be effectively processed.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the invention or to delineate the scope of the invention. Other features of the present invention will become apparent from the description that follows.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a resource matching method according to a first embodiment of the present invention;
FIG. 2 is a flowchart of another resource matching method according to a second embodiment of the present invention;
FIG. 3 is a timing diagram of a resource match provided in accordance with a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of a resource matching device according to a fourth embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device implementing a resource matching method according to an embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Example 1
Fig. 1 is a flowchart of a resource matching method according to an embodiment of the present invention, where the method may be implemented by a resource matching device, and the resource matching device may be implemented in hardware and/or software, and the resource matching device may be configured in an electronic device, where the method is applicable to a case of matching a target service resource corresponding to a service request in a set of deployment environments. As shown in fig. 1, the method includes:
s110, acquiring a service request and identification information sent by a client.
The client may also be called as a client, and refers to a computer connected to a network, which receives control and management of a server, is the other party receiving service, corresponds to the server, and provides local service for the client. In actual operation, the client may include, but is not limited to, a personal computer (Personal Computer, PC) side and a cell phone side. The service request refers to a service requirement sent by the client, and for example, the service request may be a request of the server to access a page. The identification information refers to information for identifying the client. By way of example, the identification information may include, but is not limited to, an account number, a user's internet protocol (Internet Protocol, IP), an identification number (Identity document, ID), a WeChat openid, an Application (APP) device number, and the like.
In the embodiment of the invention, after the client initiates the service request, the service request can be sent to the gateway, and the gateway can receive the service request initiated by the client and extract the identification information of the client for determining the service environment corresponding to the client. In actual operation, the identification information of the client may include one or more, which is not limited.
S120, determining a service environment corresponding to the client according to the identification information.
The service environment refers to an environment for providing services for the client, and in an actual operation process, the service environment may include, but is not limited to, a gray scale environment, a production environment and a test environment, and correspondingly, different service environments may correspond to different service resources.
In the embodiment of the invention, the service environment corresponding to each client may be preconfigured, and the service environment may be matched according to the identification information, and the service environment successfully matched is used as the service environment corresponding to the client. In an embodiment, the service environment corresponding to the client may be stored in association with the identification information, and the service environment corresponding to the client may be queried according to the identification information. When the service environment cannot be queried according to the identification information, the service environment set by default can be determined as the service environment corresponding to the client.
S130, determining a target service instance of the service environment according to the service request and a preset load rule.
The preset load rule may be a preset rule for distributing the service request to the target service instance. In an actual operation process, the preset load rule may be based on a rib load balancing algorithm. The fabric load balancing algorithm may include a polling policy, a weighting policy, a locale sensitive policy, a random policy, a minimum number of connections policy, etc. The load rule can be customized based on a Ribbon load balancing algorithm to serve as a preset load rule. For example, load balancing may be performed in conjunction with identification information of clients. When the identification information is user IP, determining a service instance corresponding to the client by adopting a region sensitive strategy; when the identification information is an identification number, a polling strategy is adopted or the weight of each service instance is set, and the target service instance corresponding to the client is determined. Meanwhile, the priority of each load rule is set, and the load rule with the set priority is used as a preset load rule.
A service instance refers to the implementation of a service in software, i.e. the instantiation of the service. The target service instance refers to a service instance for a corresponding client request. Different service instances may be attributed to different service environments. The target examples corresponding to different clients can be different, and the target service examples corresponding to the clients can be determined according to a preset load rule.
In the embodiment of the invention, the service instance associated with the service request can be pulled based on the gateway, then the service instance associated with the service environment is determined in each service instance, and the service instance matched with the service request in the service instance associated with the service environment is determined as the target service instance according to the preset load balancing rule. In an actual operation process, there may be a corresponding environment identifier for each service environment, and each service instance may carry a corresponding environment identifier. The service instance associated with the service request can be determined as the service instance to be determined, and the service instance to be determined, which is matched with the service request, is determined as the target service instance according to the preset load rule. In an embodiment, when the service instance to be determined is one, the service instance to be determined may be a target service instance; when the service instances to be determined are multiple, the target load rule can be determined according to the priority in the preset load rule, and the target service instance is determined according to the target load rule.
S140, responding to the service request sent by the client based on the target service instance.
In an embodiment of the invention, a service resource associated with a target service instance may be determined, where the service resource includes: the message queue and the database process the service request sent by the client based on the target service instance and the service resource. In the actual operation process, the service resource corresponding to each target service resource may be preset, an environment identifier of the service environment may be extracted, the service resource associated with the target service instance is searched according to the environment identifier, and the service request sent by the client is processed according to the target service instance and the corresponding service resource.
According to the embodiment of the invention, the service request and the identification information sent by the client are obtained, the service environment corresponding to the client is determined according to the identification information, the target service instance of the service environment is determined according to the service request and the preset load rule, the service request sent by the client is responded based on the target service instance, the corresponding service environment is accessed by combining the identification information of the client, the environment is isolated, different clients are divided into different service environments, meanwhile, the target service instance is determined based on the preset load rule, and the service request is processed based on the target service instance, so that the service request can be processed rapidly.
In an embodiment, before obtaining the service request and the identification information sent by the client, the method further includes:
extracting access identifiers of all service instances and environment identifiers of service environments to which the service instances belong, and uploading the access identifiers and the environment identifiers of the service instances to a service registration center in an associated manner; the access identifier comprises an access address and an access port;
extracting identification information of each initial client, and determining environment identifications corresponding to the identification information based on preset environment configuration rules;
and storing the environment identifier corresponding to each piece of identification information and the identification information in a correlated manner as a dynamic identifier.
The access identifier refers to an identifier of an access service instance, and the access identifier comprises an access address and an access port, and can access the service instance according to the access identifier. The environment identifier is identification information for indicating service environments, and each service environment corresponds to the environment identifier. In one embodiment, the service resources associated with the service instance may be determined according to the identification information. The service registry is used for storing relevant information of the service request.
The preset environment configuration rule refers to a rule for configuring the service environment of each initial client, and the preset environment configuration rule can be a rule generated by user definition according to user requirements. In an embodiment, the preset environment configuration rules may include various environment configuration rules, and for example, a service environment corresponding to the initial client may be configured according to an IP address in the identification information of the initial client; or, a weight can be configured for each service environment, and an initial client corresponding to each service environment is calculated; or, the service environment corresponding to each initial client may be randomly configured. An initial client refers to a client of an initial configuration service environment, and the initial client may be a client existing at a current time, for example.
The dynamic identifier is used for storing the environment identifier and the identifier information, and the corresponding dynamic identifier can be extracted according to the environment identifier to determine the associated stored identifier information; or, the corresponding dynamic identification can be extracted according to the identification information, and the associated stored environment identification can be determined.
In the embodiment of the invention, the service instance belonging to each service environment can be determined, the access address and the access port of each service instance are extracted as the access identifier, the environment identifier of the service environment to which the service instance belongs is determined, and the access identifier of the service instance and the environment identifier of the service environment to which the service instance belongs are associated and uploaded to the service registry so as to facilitate the subsequent determination of the target service instance. The method comprises the steps of extracting identification information of each initial client, determining environment identifications corresponding to the identification information according to preset environment configuration rules, namely configuring service environments corresponding to the initial clients, and storing the environment identifications corresponding to the identification information and the identification information in a correlated mode as dynamic identifications so as to determine the service environments according to the identification information. In an embodiment, the mapping relationship between the Redis configuration client and the service environment may be used as the dynamic identifier.
In an embodiment, after determining the service environment corresponding to the client according to the identification information, the method further includes:
and adding an environment identifier corresponding to the service environment in a request header of the service request.
In the embodiment of the invention, a Header of a hypertext transfer protocol (Hyper Text Transfer Protocol, HTTP) is a block of data area, and is divided into two types, namely a request Header and a response Header, wherein a request Header is carried when a client sends a request to a service area, and a response Header is carried when a server responds to client data. After determining the service environment corresponding to the client according to the identification information, the environment identification corresponding to the service environment can be added into the request header of the service request, so that the service request transmission of the environment identification following the client can be realized.
Example two
Fig. 2 is a flowchart of another resource matching method according to a second embodiment of the present invention, and this embodiment is a further description of a resource matching method based on the foregoing embodiment. As shown in fig. 2, the method includes:
s210, acquiring a service request and identification information sent by a client.
S220, searching the dynamic identification stored in association with the identification information.
In the embodiment of the invention, the dynamic identifier may be an identifier which is formed by associating and storing the environment identifier corresponding to each piece of identification information with the identification information, and the dynamic identifier which is formed by associating and storing the environment identifier and the identification information may be determined by inquiring the dynamic identifier according to the identification information.
S230, determining the service environment corresponding to the environment identifier in the dynamic identifier as the service environment corresponding to the client.
In the embodiment of the invention, after the dynamic identifier is determined, the service environment corresponding to the environment identifier in the dynamic identifier can be determined, and the service environment is used as the service environment corresponding to the client.
S240, when the dynamic identification matched with the identification information does not exist, extracting a default service environment as a service environment corresponding to the client.
The default service environment may be a preset service environment, and exemplary, the default service environment may be a gray scale environment, a production environment, and a test environment.
In the embodiment of the invention, when the corresponding dynamic identifier cannot be queried according to the identifier information, the default service environment can be extracted, and the default service environment is taken as the service environment corresponding to the client.
S250, at least one service instance associated with the service request is extracted.
In an embodiment of the invention, the service instance associated with the service request may be determined based on the gateway pulling the service instance of the registry. In actual operation, the service instance associated with the service request may be one or more.
S260, determining a service instance to be determined carrying an environment identifier of a service environment in at least one service instance, and determining the service instance to be determined matched with the service request as a target service instance according to a preset load rule; the preset load rule comprises a Ribbon load balancing algorithm.
In the embodiment of the invention, the environment identifier corresponding to the service instance associated with the service request can be determined, the service instance carrying the environment identifier of the service environment is determined in the service instance as the service instance to be determined, and the service instance matched with the service request in the service instance associated with the service environment is determined as the target service instance according to the preset load balancing rule. In an embodiment, when the service instance to be determined is one, the service instance to be determined may be a target service instance; when the service instances to be determined are multiple, the target load rule can be determined according to the priority in the preset load rule, and the target service instance is determined according to the target load rule.
S270, searching service resources associated with the target service instance based on the environment identifier corresponding to the service environment; wherein the service resources include: message queues, databases.
Where a service resource refers to a resource for handling a service request.
In the embodiment of the invention, in the dynamic identifier, service resources corresponding to the environment identifier can also be stored. The message queues and databases associated with the target service instance may be queried by the context identification as a service resource associated with the target service instance.
S280, processing the service request sent by the client based on the target service instance and the service resource.
In the embodiment of the invention, after the target service instance and the service resource are determined, the service request sent by the client can be processed according to the target service instance and the service resource.
According to the embodiment of the invention, the service request and the identification information sent by the client are obtained, the dynamic identification stored in association with the identification information is searched, the service environment corresponding to the environment identification in the dynamic identification is determined to be the service environment corresponding to the client, when the dynamic identification matched with the identification information does not exist, the default service environment is extracted to be the service environment corresponding to the client, at least one service instance associated with the service request is extracted, the service instance to be determined carrying the environment identification of the service environment is determined in the at least one service instance, the service instance to be determined matched with the service request is determined according to the preset load rule to be used as the target service instance, the service resource associated with the target service instance is searched based on the environment identification corresponding to the service environment, the service request sent by the client is processed based on the target service instance and the service resource, the target service instance is determined based on the preset load rule, the corresponding service resource is determined to process the service request, meanwhile, the service environment is determined more conveniently according to the identification information and the dynamic identification of the client, and the use experience of the user is improved.
Example III
Fig. 3 is a timing chart of resource matching according to a third embodiment of the present invention, where the embodiment is further optimized and expanded based on the foregoing embodiment, and may be combined with each of the alternative solutions in the foregoing embodiment, and this embodiment takes a case that a service request of a client needs to be processed by a service instance a, and meanwhile, the service instance a needs to schedule a service instance B to process the service request. As shown in fig. 3, the method includes:
the client initiates a service request, the request passes through the gateway, and the gateway can obtain the identification information of the client. The identification information can comprise an account unique identification, a WeChat openid identification, an APP equipment number, a user IP and the like. Meanwhile, the gateway can be matched with the dynamic identification according to the identification information to determine the service environment to be accessed by the client. Meanwhile, the environment identifier of the service request is stored in the request header, and the subsequent request can be transmitted along with the request header. The gateway pulls a service list of the registry, wherein the service list contains all service instances associated with the service request. And selecting a service instance to be determined through a self-defined Ribbon load balancing algorithm, and carrying out request routing of the service instance in a corresponding service environment. In an embodiment, the rib may pull a service list corresponding to the service request from the service registry, such as pulling the identification information (IP address, port and environment identifier) in the 4 service instances of the service a and comparing the environment identifiers of the service requests obtained in the configuration center. And if the test environment identification is compared, acquiring service instances of A services of 2 test environments. In the context identification, it is defined which load balancing is used to route the service instance. If polling is defined, access will be polled in the service instance of the A service for 2 test environments. When the service instance is accessed, the service instance obtains the request environment identifier from the request head to determine the service resources such as the accessed database, the message queue and the like. Meanwhile, if the service instance A needs to schedule the service instance B in the running process, information for accessing other service instances can be generated, a service instance list is obtained, corresponding service requests of the service instance B are made through the fabric load balancing, service resources such as an accessed database, a message queue and the like are determined, and corresponding results are generated in response to the service requests and returned to the client.
In one embodiment, the same message queue may be used by different service environments. Messages may be distributed to message queues based on the context identification of the service request. The same database may be used by different service environments. Under different service environments, table names are different, such as a table user, a test_user under test, and a dev_user under dev environment. When the database is accessed, the table names can be intercepted by using a tangent plane mode and replaced by the table names under the corresponding service environment representation.
Before a client initiates a service request, when a service instance is started, the IP address, the port (access identifier) and the environment identifier of the service instance can be written into a service registry for subsequent selection of service environment access. For example, if a service starts two service instances, IP1: port 1=test, IP2: port 2=dev may be configured. Meanwhile, the client supports multi-terminal identification, including H5, android and IOS. The client identification information may include a login account number, a device number, a WeChat openid, a user IP, etc. The configuration personnel can configure the identification information of the client in the configuration center, so that different environments accessed by the unused client can be realized. For example, account numbers appid=10100001, service=test, mysql=dev, mq=test may be configured. When receiving the service request of the client, the identification information of the client is obtained. If the account number appId of the client is 10100001 in the identification information of the client, configuration service=test, mysql=dev, and mq=test in the configuration center can be obtained. If the identification information of the client is not matched, determining that the client is a default service environment, such as a test environment. Subsequent access to the service instance, an instance of the test environment may be accessed, which when operating the database mysql will access the database of the dev environment, and when operating the message queue will access the test environment.
In this embodiment, by combining the rib with the registry, the same server instance may be configured with different environment configurations, so as to implement environment isolation. The dynamic label configuration uses Redis to configure the mapping relation between the client and the server environment. When a service request is acquired, a service environment to be accessed is determined according to the dynamic identification of the client, the IP address of a service instance corresponding to the environment is obtained through the registry, the service instance is balanced to the corresponding service instance based on the Ribbon load, and then the corresponding service resource is accessed in the service instance according to the dynamic identification. Under the condition of realizing environment isolation, sharing and isolation of the custom resources are realized.
Example IV
Fig. 4 is a schematic structural diagram of a resource matching device according to a fourth embodiment of the present invention. As shown in fig. 4, the apparatus includes: the identification information extraction module 41, the service environment determination module 42, the service instance determination module 43 and the service request processing module 44.
The identification information extraction module 41 is configured to obtain a service request and identification information sent by the client.
The service environment determining module 42 is configured to determine a service environment corresponding to the client according to the identification information.
The service instance determining module 43 is configured to determine a target service instance of the service environment according to the service request and a preset load rule.
The service request processing module 44 is configured to respond to the service request sent by the client based on the target service instance.
According to the embodiment of the invention, the service request and the identification information sent by the client are acquired through the identification information extraction module, the service environment determining module determines the service environment corresponding to the client according to the identification information, the service instance determining module determines the target service instance of the service environment according to the service request and the preset load rule, the service request processing module responds to the service request sent by the client based on the target service instance, accesses the corresponding service environment by combining the identification information of the client, achieves the isolation of the environments, divides different clients into different service environments, determines the target service instance based on the preset load rule, and processes the service request based on the target service instance so as to ensure that the service request can be processed rapidly.
In an embodiment, the resource matching device further includes:
the information uploading module is used for extracting the access identifier of each service instance and the environment identifier of the service environment to which each service instance belongs, and uploading the access identifier and the environment identifier of each service instance to the service registration center in a correlation manner; the access identifier comprises an access address and an access port;
the environment identifier configuration module is used for extracting the identifier information of each initial client and determining the environment identifier corresponding to each identifier information based on a preset environment configuration rule;
and the dynamic identification generation module is used for storing the environment identifications corresponding to the identification information and the identification information in a correlated manner as dynamic labels.
In one embodiment, the service environment determination module 42 includes:
the dynamic identification searching unit is used for searching the dynamic identification stored in association with the identification information;
and the service environment determining unit is used for determining the service environment corresponding to the environment identifier in the dynamic identifier as the service environment corresponding to the client.
In an embodiment, the resource matching device further includes:
and the service environment matching module is used for extracting a default service environment as a service environment corresponding to the client when the dynamic identifier matched with the identifier information does not exist.
In one embodiment, the service instance determination module 43 includes:
a service instance extraction unit for extracting at least one service instance associated with the service request;
the target instance determining unit is used for determining a service instance to be determined carrying the environment identifier of the service environment in at least one service instance, and determining the service instance to be determined matched with the service request as a target service instance according to a preset load rule; the preset load rule comprises a Ribbon load balancing algorithm.
In an embodiment, the resource matching device further includes:
the identification adding module is used for adding the environment identification corresponding to the service environment in the request head of the service request.
In one embodiment, service request processing module 44 includes:
the service resource query unit is used for searching the service resource associated with the target service instance based on the environment identifier corresponding to the service environment; wherein the service resources include: a message queue and a database;
du Wei a request processing unit for processing a service request sent by a client based on a target service instance and a service resource.
The resource matching device provided by the embodiment of the invention can execute the resource matching method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
Example five
Fig. 5 is a schematic structural diagram of an electronic device 10 implementing a resource matching method according to an embodiment of the present invention. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. Electronic equipment may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 5, the electronic device 10 includes at least one processor 11, and a memory, such as a Read Only Memory (ROM) 12, a Random Access Memory (RAM) 13, etc., communicatively connected to the at least one processor 11, in which the memory stores a computer program executable by the at least one processor, and the processor 11 may perform various appropriate actions and processes according to the computer program stored in the Read Only Memory (ROM) 12 or the computer program loaded from the storage unit 18 into the Random Access Memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 may also be stored. The processor 11, the ROM 12 and the RAM 13 are connected to each other via a bus 14. An input/output (I/O) interface 15 is also connected to bus 14.
Various components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, etc.; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, an optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunication networks.
The processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, digital Signal Processors (DSPs), and any suitable processor, controller, microcontroller, etc. The processor 11 performs the various methods and processes described above, such as the resource matching method.
In some embodiments, the resource matching method may be implemented as a computer program tangibly embodied on a computer-readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the resource matching method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the resource matching method in any other suitable way (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for carrying out methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be implemented. The computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) through which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service are overcome.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present invention may be performed in parallel, sequentially, or in a different order, so long as the desired results of the technical solution of the present invention are achieved, and the present invention is not limited herein.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (10)

1. A method for resource matching, comprising:
acquiring a service request and identification information sent by a client;
determining a service environment corresponding to the client according to the identification information;
determining a target service instance of the service environment according to the service request and a preset load rule;
responding to the service request sent by the client based on the target service instance.
2. The method of claim 1, further comprising, prior to the obtaining the service request and the identification information sent by the client:
extracting access identifiers of the service instances and environment identifiers of service environments to which the service instances belong, and uploading the access identifiers of the service instances and the environment identifiers in an associated manner to a service registry; the access identifier comprises an access address and an access port;
extracting identification information of each initial client, and determining environment identifications corresponding to the identification information based on preset environment configuration rules;
and storing the environment identifier corresponding to each piece of identification information and the identification information in a correlated mode as dynamic identifiers.
3. The method according to claim 2, wherein the determining the service environment corresponding to the client according to the identification information includes:
searching the dynamic identification stored in association with the identification information;
and determining the service environment corresponding to the environment identifier in the dynamic identifier as the service environment corresponding to the client.
4. The method as recited in claim 2, further comprising:
and when the dynamic identification matched with the identification information does not exist, extracting a default service environment as the service environment corresponding to the client.
5. The method of claim 1, wherein the determining the target service instance of the service environment according to the service request and a preset load rule comprises:
extracting at least one service instance associated with the service request;
determining a service instance to be determined carrying an environment identifier of the service environment in the at least one service instance, and determining the service instance to be determined matched with the service request as a target service instance according to the preset load rule; the preset load rule comprises a Ribbon load balancing algorithm.
6. The method according to claim 1, further comprising, after determining the service environment corresponding to the client according to the identification information:
and adding an environment identifier corresponding to the service environment in a request header of the service request.
7. The method of claim 1, wherein responding to the service request sent by the client based on the target service instance comprises:
searching a service resource associated with the target service instance based on the environment identifier corresponding to the service environment; wherein the service resources include: a message queue and a database;
and processing the service request sent by the client based on the target service instance and the service resource.
8. A resource matching apparatus, comprising:
the identification information extraction module is used for acquiring the service request and the identification information sent by the client;
the service environment determining module is used for determining the service environment corresponding to the client according to the identification information;
the service instance determining module is used for determining a target service instance of the service environment according to the service request and a preset load rule;
and the service request processing module is used for responding to the service request sent by the client based on the target service instance.
9. An electronic device, the electronic device comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the resource matching method of any one of claims 1-7.
10. A computer readable storage medium storing computer instructions for causing a processor to perform the method of resource matching of any of claims 1-7.
CN202410012479.4A 2024-01-03 2024-01-03 Resource matching method and device, electronic equipment and storage medium Pending CN117827458A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410012479.4A CN117827458A (en) 2024-01-03 2024-01-03 Resource matching method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410012479.4A CN117827458A (en) 2024-01-03 2024-01-03 Resource matching method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117827458A true CN117827458A (en) 2024-04-05

Family

ID=90509620

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410012479.4A Pending CN117827458A (en) 2024-01-03 2024-01-03 Resource matching method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117827458A (en)

Similar Documents

Publication Publication Date Title
CN114389969B (en) Method and device for testing client, electronic equipment and storage medium
CN112532723B (en) Account management method, cloud management layer, equipment and medium
CN114461407A (en) Data processing method, data processing device, distribution server, data processing system, and storage medium
JP6501924B2 (en) Method and server for canceling alert
CN116545905A (en) Service health detection method and device, electronic equipment and storage medium
CN117827458A (en) Resource matching method and device, electronic equipment and storage medium
CN113901370B (en) Certificate deployment method, device, electronic equipment and storage medium
CN113726881B (en) Communication connection establishment method, related device and computer readable storage medium
CN115277568B (en) Data transmission method, device, equipment and storage medium
CN114401267B (en) Cloud application login method, device, equipment, medium and program product
CN116306407B (en) Verification method, device, equipment and storage medium of Network On Chip (NOC)
CN115037803B (en) Service calling method, electronic equipment and storage medium
CN116939228B (en) Distributed processing method, device and equipment for remote sensing image and storage medium
CN115525415B (en) Data processing method, device, equipment and medium
CN117251769B (en) Abnormal data identification method, device, equipment and medium based on monitoring component
CN116886775A (en) External exposure method and device, cluster deployment system and storage medium
CN117806702A (en) Target software acquisition method and device, electronic equipment and storage medium
CN116668532A (en) Data communication method, device, electronic equipment and storage medium
CN117651078A (en) Data transmission method and device, electronic equipment and storage medium
CN111147509A (en) Network isolation method, device, server and storage medium
CN115766260A (en) Method, device, equipment and storage medium for generating network access white list
CN115422129A (en) Session processing method, device, electronic equipment and storage medium
CN117294597A (en) Network card binding configuration method, device, equipment and medium
CN116107878A (en) Remote debugging method, device, equipment and storage medium
CN117596288A (en) Message transmission method and device, electronic 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