A kind of resource allocation methods and device
Technical field
The present invention relates to field of computer technology, more particularly to a kind of resource allocation methods and device.
Background technology
When user is to cloud computing platform application resource, cloud computing platform creates according to the application of user includes multiple resources
Service Instance, then by the resource allocation in Service Instance give user use.Wherein, Service Instance can include virtual machine,
Web service, MySQL database etc..
But in cloud computing platform, the establishment of Service Instance needs the regular hour, this results in user and provided in application
, it is necessary to wait for a period of time during source, if other situations are run into, such as:Network condition is bad, concurrently larger etc., the stand-by period
Also to extend.
The deficiencies in the prior art are:
In current cloud computing platform, user applies for that the time that resource needs wait is longer, can so cause Consumer's Experience
It is poor.
The content of the invention
The embodiment of the present invention proposes a kind of resource allocation methods and device, applies for resource to solve user in the prior art
Need the technical problem that the time waited is longer.
The embodiments of the invention provide a kind of resource allocation methods, including:
A number of Service Instance is pre-created in the resource pool of cloud computing platform, each Service Instance includes more
Individual resource;
Receive the resource bid request of user;
Matching meets the Service Instance of user resources application request from the Service Instance being pre-created, and by described in
Resource allocation in Service Instance gives the user.
The embodiments of the invention provide a kind of resource allocation device, including:
Module is pre-created, for being pre-created a number of Service Instance in the resource pool of cloud computing platform, each
Service Instance includes multiple resources;
Receiving module, the resource bid for receiving user are asked;
Distribute module, the service of user resources application request is met for being matched from the Service Instance being pre-created
Example, and give the resource allocation in the Service Instance to the user.
Have the beneficial effect that:
Apply for the problem of resource needs time for waiting longer for user in the prior art, the embodiment of the present invention by
One or more Service Instances are pre-created in resource pool, multiple resources are included in each Service Instance, due in resource pool
Prestored the Service Instance created, thus can receive user resource bid ask when quick response, will
Meet that the resource allocation in the Service Instance of user resources application request to user, shortens the stand-by period, improves user's body
Test.
Brief description of the drawings
The specific embodiment of the present invention is described below with reference to accompanying drawings, wherein:
Fig. 1 shows the schematic flow sheet that resource allocation methods are implemented in the embodiment of the present invention;
Fig. 2 shows resource pool configuration diagram in the embodiment of the present invention;
Fig. 3 shows thread operation schematic diagram of the embodiment of the present invention;
Fig. 4 shows the structural representation of resource allocation device in the embodiment of the present invention.
Embodiment
In order that technical scheme and advantage are more clearly understood, below in conjunction with accompanying drawing to the exemplary of the present invention
Embodiment is described in more detail, it is clear that and described embodiment is only the part of the embodiment of the present invention, rather than
The exhaustion of all embodiments.And in the case where not conflicting, the feature in embodiment and embodiment in this explanation can be mutual
It is combined.
The embodiment of the present invention proposes a kind of resource allocation methods and device, is illustrated below.
Fig. 1 shows the schematic flow sheet that resource allocation methods are implemented in the embodiment of the present invention, as illustrated, this method can
To comprise the following steps:
Step 101, a number of Service Instance, each Service Instance are pre-created in the resource pool of cloud computing platform
Include multiple resources;
Step 102, the resource bid request for receiving user;
Step 103, matching meets the Service Instance of user resources application request from the Service Instance being pre-created, and will
Resource allocation in the Service Instance gives the user.
Cloud computing platform (or claiming cloud platform, cloud service system etc.), can be cloud computing platform of increasing income, such as
AbiCloud, Hadoop etc., or commercialization cloud computing platform, such as Microsoft, the cloud platform of Google companies.
By taking the cloud computing platform of enterprises as an example, the situation using Service Instance as virtual machine illustrates below.
When cloud computing platform initializes, a number of virtual machine is pre-created by keeper, every virtual machine includes
There are a number of resource, such as internal memory, hard disk, processor.Developer or tester are logging in cloud computing platform
Afterwards, the virtual machine of type of virtual machine, such as four core 16G needed can be selected on cloud computing platform, can also be to required
Resource selects one by one, such as 4 CPU, 16G hard disk, 2G internal memories;After cloud computing platform receives the request of user, from advance
The virtual machine of user's request can be met by being matched in the virtual machine of establishment, and resource is provided the user using the virtual machine.
In cloud computing platform running, frequency and quantity, user concurrent amount, network condition for being applied according to user etc.
Factor, utilize the virtual machine quantity in the continuous adjustresources ponds of operation such as establishment, deletion and each money in every virtual machine
Source quantity, while quick response user asks, by the maximization of utility of resource pool.
Due in actual use, according to business and the difference of concrete scene, using the use of cloud computing platform resource
Family also differs to the demand of resource, therefore, most common user resources demand can be combined when being pre-created Service Instance,
The Service Instance of Common resources demand can be met by creating.In the embodiment of the present invention, the quantity of the Service Instance being pre-created with
And the resource quantity that Service Instance is included, can voluntarily be set by keeper, the present invention to the particular number that is pre-created not
It is restricted.
The embodiments of the invention provide one can be created in advance in system initialization with the resource pool of adaptive change
Multiple Service Instances are built, user can match Service Instance and by Service Instance after filing an application from existing Service Instance
Resource allocation to user, so as to reduce period of reservation of number, improve Consumer's Experience;Also, due to the embodiment of the present invention
In correspond to multiple resources under a Service Instance, therefore, the technical scheme provided using the embodiment of the present invention can meet should
The requirement that multiple resources are worked simultaneously.
In implementation, the resource allocation methods may further include:
Timing scan the Resources list, record has resource pool information, Service Instance information and resource information in the Resources list;
Judge in the Resources list with the presence or absence of the resource pool, Service Instance and/or resource for meeting preparatory condition;
When the resource pool, Service Instance and/or resource that meet preparatory condition being present, calling corresponding thread to perform and specifying
Operation.
Wherein, resource pool information, for describing the information of resource pool, title, type of resource pool etc. can be included;
Service Instance information, for describing the state of Service Instance, seizure condition, title, creation time etc. in resource pool;
Resource information, for describing the information such as the state of resource, the type of resource, IP address, CPU sizes.
Resource pool framework in the embodiment of the present invention includes resource pool, Service Instance, resource these three objects, resource pool bag
Containing multiple Service Instances, Service Instance includes multiple resources, and the embodiment of the present invention by recording resource respectively in the Resources list
Pond information, Service Instance information and resource information, resource allocation operations are carried out according to the information of these objects so as to realize.
Fig. 2 shows resource pool configuration diagram in the embodiment of the present invention, as shown in the figure, it is assumed that resource pool includes resource pool
A, resource pool B..., and include Service Instance 1,2...M in resource pool A, further, the resource that Service Instance 1 is included can
Think resource 1,2 ... N.
Wherein, the resource quantity that each resource pool includes Service Instance quantity, each Service Instance include may each be
It is identical or differ, and in cloud service system running can be with dynamic change.
Wherein, the resource in resource pool can be processor, disk, hard disk, internal memory, the network switch, network router
Etc..
In order to realize constantly dynamic allocation of resources, can be realized in the embodiment of the present invention by the fixed cycle operator of thread
This purpose.Fig. 3 shows the schematic flow sheet of thread of embodiment of the present invention operation, as illustrated, thread running can
To comprise the following steps:
Step 301, timing scan the Resources list;
Step 302, judge whether to meet preparatory condition;
If there is resource pool, the Service Instance/resource for meeting preparatory condition, then step 303 is performed;
If there is no resource pool, the Service Instance/resource for meeting preparatory condition, then step 301 is performed;
Step 303, call corresponding threading operation.
Threading operation can include creating, renewal, inquiry, deletion action, the object of threading operation can be resource pool or
Person's Service Instance, can also be resource, the invention is not limited in this regard.
The embodiment of the present invention is by thread timing scan the Resources list, so as to judge in the Resources list with the presence or absence of satisfaction
Resource pool, Service Instance and/or the resource of preparatory condition, and call corresponding thread to perform when meeting preparatory condition and specify behaviour
Make, can dynamic adjustresources pond, Service Instance and/or resource etc. in cloud computing platform running.
In implementation, judge whether to meet the resource pool of preparatory condition, Service Instance and/or resource, can include:
Judge whether the quantity in current available resource pond, Service Instance and/or resource in the Resources list is less than to be pre-created
Quantity;
When the resource pool, Service Instance and/or resource that meet preparatory condition being present, calling corresponding thread to perform and specifying
Operation, can include:
When the quantity of current available resource pond, Service Instance and/or resource is less than the quantity being pre-created, call virtual
Change establishment interface establishing resource pond, Service Instance and/or the resource of layer;Wherein, the resource pool of establishment, Service Instance or resource
Quantity can be the difference between the quantity and current available number being pre-created.
In the embodiment of the present invention, system can be according to the situation of Service Instance application, adjustment, completion Service Instance and its money
Source, such as:The Service Instance being pre-created includes M resource, and the currently allocated resource used to user is N number of, then
System creates M-N resource, to supply the number of resources that the Service Instance is possessed to ensure effective utilization of resource allocation
Amount;Or P Service Instance has been pre-created, and active user's application occupies Q Service Instance, then system is in order to protect
Card user is normally carried out Service Instance request operation, Service Instance is correspondingly created, to supply the quantity of Service Instance.
Wherein, the speed of system creation resource pool, Service Instance or resource, the cycle that can be applied according to user and frequency
Etc. being determined or set, the invention is not limited in this regard.
Call the quantity for creating interface establishing resource pond, Service Instance or resource can also be according to present application frequency, number
The quantity that the factors such as amount redefine, such as, in the case where coincidence is higher, establishment interface can be called to be created that most
Resource pool, Service Instance or the resource of amount, to ensure to meet user's request.
In implementation, the resource allocation methods may further include:
When the state of resource pool, Service Instance and/or resource is unavailable, resource pool, service are regularly re-created in fact
Example and/or resource;
When number of retries reaches preset value, terminate to retry.
The embodiment of the present invention can timing scan the Resources list, for the resource pool in down state, Service Instance or
Resource can first be attempted to recover, and when retrying repeatedly or reaching still unsuccessful after threshold value, terminate to retry.
Due to the resource-constrained of cloud service system, the embodiment of the present invention can also adopt for timely and effectively Resource recovery
Implemented with following manner.
In implementation, when giving the resource allocation of Service Instance to the user, it may further include:Establish the resource
With the incidence relation of the user;The resource allocation methods may further include:
Receive the request that user deletes resource;
The incidence relation of the resource and the user is released, the resource is stored in wait in resource pool and deletes thread
Delete;
It whether there is resource to be deleted using thread timing scan is deleted, and call and delete when resource to be deleted be present
Resource interface deletes the resource.
The embodiment of the present invention can call phase by being timed scanning to the Resources list after finding resource to be deleted
The thread answered is deleted.Wherein, resource to be deleted can be Service Instance service life arrived and user do not have it is follow-up
The resource of behavior is renewed, system can reclaim the resource automatically and be discharged.
In the prior art, when user will delete resource, after cloud computing platform receives the deletion resource request of user, need
Call thread to delete the resource, and deleting resource needs the regular hour, particularly run into network condition it is bad or
The larger situation of concurrency, the time that user needs to wait can be longer, causes Consumer's Experience bad.
And the technical scheme provided using the embodiment of the present invention, due to established when allocating resources to user resource with
The incidence relation of user, therefore when receiving the deletion resource request of user, it is only necessary to release the pass of the user and the resource
Connection relation (for example can be unoccupied by the status modifier of the resource), resource to be deleted is stored in resource pool i.e.
Can, it is to be deleted without user etc.;Subsequently by thread timing scan resource, deletion resource is recalled when resource to be deleted be present
Interface deletes resource, eliminates the time of the resource to be deleted such as user compared with prior art, substantially reduces user's deletion
Stand-by period during resource, improve Consumer's Experience.
Based on same inventive concept, the embodiment of the present invention also proposed a kind of resource allocation device, the realization of these equipment
Principle is similar to a kind of resource allocation methods, and specific implementation is referred to the implementation of method, repeats part and repeats no more.
Fig. 4 shows the structural representation of resource allocation device in the embodiment of the present invention, as illustrated, can include:
Module 401 is pre-created, for being pre-created a number of Service Instance in the resource pool of cloud computing platform, often
Individual Service Instance includes multiple resources;
Receiving module 402, the resource bid for receiving user are asked;
Distribute module 403, meet user resources application request for being matched from the Service Instance being pre-created
Service Instance, and give the resource allocation in the Service Instance to the user.
In implementation, the resource allocation device may further include:
Scan module, for timing scan the Resources list, record has resource pool information, Service Instance in described the Resources list
Information and resource information;
Judge module, for the resource pool, Service Instance and/or resource for judging whether to meet preparatory condition;
Execution module, for when the resource pool, Service Instance and/or resource that meet preparatory condition be present, calling corresponding
Thread perform assigned operation.
In implementation, judge module can be used for judging current available resource pond in described the Resources list, Service Instance and/or
Whether the quantity of resource is less than the quantity being pre-created;
Processing module, which can be used for being less than in the quantity of current available resource pond, Service Instance and/or resource, to be pre-created
Quantity when, call establishment interface establishing resource pond, Service Instance and/or the resource of virtualization layer;Wherein, the money of the establishment
The quantity in source pond, Service Instance or resource is the difference being pre-created between quantity and current available number.
In implementation, execution module can be further used for the state in the resource pool, Service Instance and/or resource as not
When available, the resource pool, Service Instance and/or resource are regularly re-created, when number of retries reaches preset value, terminates weight
Examination.
In implementation, receiving module can be further used for receiving the request that user deletes resource;Distribute module can enter one
Walk for when by the resource allocation in Service Instance to the user, establishing the incidence relation of the resource and the user;
The resource allocation device may further include:
Memory module, for releasing the incidence relation of the resource and the user, the resource is stored in the money
Waited in the pond of source and delete thread deletion;
Removing module, it whether there is resource to be deleted using the deletion thread timing scan, and it is to be deleted existing
Resource when call and delete resource interface and delete the resource.
For the ease of the implementation of the present invention, illustrated below with example.
The embodiment of the present invention is by defining different classes, to realize scheme that the embodiment of the present invention is provided, class it is specific
Content is as follows:
1) a resource pool management class is defined
In resource pool management class, define and resource pool is created, changed, is inquired about, deletes interface;
2) a Service Instance management class is defined
In Service Instance manages class, define establishment to Service Instance, modification, inquiry, delete interface;
3) a resource management class is defined
In resource management class, define establishment to resource, modification, inquiry, delete interface;
4) thread class of an establishing resource is defined
The interface of the establishment virtual machine of virtualization layer is called in timing
5) thread class of a more new resources is defined
The virtual machine creating progress interface of virtualization layer is called in timing, and state renewal resource information is returned according to interface;
6) thread class of a renewal Service Instance is defined
Timing updates the state of Service Instance;
7) thread class of a deletion resource is defined
Timing, which is called, deletes resource interface;
8) thread class for re-creating resource is defined
Timing retries the virtual machine for creating failure, and reaching number of retries will terminate to retry.
Can be with parallel work-flow, that is, the scheme that the embodiment of the present invention is provided can support multithreading between above-mentioned thread
Operation.In cloud service system running, Mobile state can be entered to resource pool, Service Instance, resource etc. by these threads
Adjustment, such as:Service Instance is created in Service Instance deficiency, reclaimed in time when resource does not use, be in generation modification
Operation etc. is updated in time, to realize effective utilization of resource.
The resource pool of cloud service system is defined in the embodiment of the present invention, ensure that cloud computing platform to resource
Effectively management and the quick response to user's operation, responded with solving cloud computing platform resource bid in the prior art, deleting
The technical problem such as utilize not yet in effect compared with slow, resource.
For convenience of description, each several part of apparatus described above is divided into various modules with function or unit describes respectively.
Certainly, each module or the function of unit can be realized in same or multiple softwares or hardware when implementing of the invention.
It should be understood by those skilled in the art that, embodiments of the invention can be provided as method, system or computer program
Product.Therefore, the present invention can use the reality in terms of complete hardware embodiment, complete software embodiment or combination software and hardware
Apply the form of example.Moreover, the present invention can use the computer for wherein including computer usable program code in one or more
The computer program production that usable storage medium is implemented on (including but is not limited to magnetic disk storage, CD-ROM, optical memory etc.)
The form of product.
The present invention is the flow with reference to method according to embodiments of the present invention, equipment (system) and computer program product
Figure and/or block diagram describe.It should be understood that can be by every first-class in computer program instructions implementation process figure and/or block diagram
Journey and/or the flow in square frame and flow chart and/or block diagram and/or the combination of square frame.These computer programs can be provided
The processors of all-purpose computer, special-purpose computer, Embedded Processor or other programmable data processing devices is instructed to produce
A raw machine so that produced by the instruction of computer or the computing device of other programmable data processing devices for real
The device for the function of being specified in present one flow of flow chart or one square frame of multiple flows and/or block diagram or multiple square frames.
These computer program instructions, which may be alternatively stored in, can guide computer or other programmable data processing devices with spy
Determine in the computer-readable memory that mode works so that the instruction being stored in the computer-readable memory, which produces, to be included referring to
Make the manufacture of device, the command device realize in one flow of flow chart or multiple flows and/or one square frame of block diagram or
The function of being specified in multiple square frames.
These computer program instructions can be also loaded into computer or other programmable data processing devices so that counted
Series of operation steps is performed on calculation machine or other programmable devices to produce computer implemented processing, so as in computer or
The instruction performed on other programmable devices is provided for realizing in one flow of flow chart or multiple flows and/or block diagram one
The step of function of being specified in individual square frame or multiple square frames.
Although preferred embodiments of the present invention have been described, but those skilled in the art once know basic creation
Property concept, then can make other change and modification to these embodiments.So appended claims be intended to be construed to include it is excellent
Select embodiment and fall into having altered and changing for the scope of the invention.