Resource reservation method and computing device

Through asynchronous delay monitoring tasks and distributed locking mechanism, the problem of resource reservation conflicts under scarcity and high concurrency is solved, resource utilization and user experience are improved, equipment operation costs are reduced, and server performance is improved.

CN119248601APending Publication Date: 2025-01-03XFUSION DIGITAL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411126963.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-16
Publication Date
2025-01-03

AI Technical Summary

Technical Problem

In the scenarios of scarce resources and high concurrency, the existing technology adopts the method of synchronous monitoring of resource reservation tasks, resulting in high equipment load, waste of resources and poor user experience, and may affect the processing efficiency of other tasks and increase operating costs.

Method used

Adopt asynchronous delay monitoring tasks to adjust monitoring tasks according to the execution status of the appointment task to avoid invalid start and queue blockage. Through distributed locks, only one user can make a reservation successfully in each time period. Use Redis database and hash table to record appointments. situation, generate resource occupation and release monitoring tasks.

Benefits of technology

It improves resource utilization, reduces the waste of monitoring resources, alleviates the pressure on server processing tasks, saves equipment operation costs, and improves user appointment experience and server performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119248601A_ABST
    Figure CN119248601A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a resource reservation method and computing equipment, and the method comprises the steps: receiving reservation request information sent by a user, and determining whether the user succeeds in reservation or not; wherein the reservation request information comprises identification information of a target resource requested to be reserved by the user and a target time period; generating an asynchronous delay monitoring task of the reservation task of the user under the condition that the user succeeds in reservation; wherein the asynchronous delay monitoring task is used for starting regularly based on a preset delay parameter so as to monitor the use state of the target resource in a target time period; before the asynchronous delay monitoring task is started, the execution state of the reservation task is obtained, and the asynchronous delay monitoring task is adjusted according to the execution state of the reservation task. According to the resource reservation method provided by the embodiment of the invention, the flexibility of resource reservation can be effectively improved, the waste of monitoring resources is reduced, and the reservation experience of a user is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the technical field of computing devices, and in particular, to a resource reservation method and a computing device. Background Art

[0002] Resource reservation is a technology used to manage and allocate limited resources in high-demand and high-concurrency environments. Resource reservation is widely used in various scenarios, such as hardware equipment reservation, conference room reservation, computing resource reservation, etc.

[0003] When resources are scarce and there are many appointments, there will be scenarios with high concurrency tasks, resulting in multi-task queues. In related technologies, after a resource reservation is successful, a synchronous monitoring method is usually used to monitor the execution status of the appointment task in real time. In this method, since synchronous real-time monitoring requires continuous occupation of device monitoring resources, especially when there are many appointment tasks, it will cause a high device load, which may not only affect the processing efficiency of other tasks, but also cause a waste of device resources, which increases the operating cost of the device and may even affect the user's appointment experience.

[0004] Therefore, how to implement resource reservation more reasonably becomes an urgent problem to be solved. Summary of the invention

[0005] The embodiments of the present application provide a resource reservation method and a computing device, which can effectively improve the flexibility of resource reservation, reduce the waste of monitoring resources, and enhance the user's reservation experience.

[0006] In a first aspect, an embodiment of the present application provides a resource reservation method, the method comprising:

[0007] Receiving reservation request information sent by the user, and determining whether the user's reservation is successful; wherein the reservation request information includes identification information and target time period of the target resource requested by the user for reservation;

[0008] When the user's reservation is successful, an asynchronous delay monitoring task is generated for the user's reservation task; wherein the asynchronous delay monitoring task is used to start regularly based on a preset delay parameter to monitor the usage status of the target resource in the target time period;

[0009] Before starting the asynchronous delay monitoring task, the asynchronous delay monitoring task is obtained and adjusted according to the execution status of the scheduled task.

[0010] Beneficial effects of this embodiment: The embodiment of the present application controls that only one user can successfully make an appointment in each time period, which can not only avoid appointment conflicts but also improve resource utilization; further, the embodiment of the present application adopts asynchronous delay monitoring to monitor the appointment task, so there is no need to continuously monitor the execution status of the appointment task, and the server's monitoring resources will not be continuously occupied, which greatly alleviates the pressure on the server to process tasks and can improve the overall performance of the server; in addition, the embodiment of the present application also automatically adjusts the asynchronous delay monitoring task according to the execution status of the appointment task before starting the asynchronous delay monitoring task, which can not only avoid invalid startup of the monitoring task and queue congestion, but also alleviate the data processing pressure of the device and save equipment operating costs.

[0011] In a possible implementation, receiving reservation request information sent by a user includes:

[0012] Receiving reservation request information sent by a user through a client resource reservation platform; wherein the reservation interface of the client resource reservation platform displays the resources that can be reserved and the time periods that can be reserved.

[0013] The beneficial effect of this implementation method is that by displaying the resources that can be reserved and the time periods that can be reserved in the reservation interface, the user can make a resource reservation by directly clicking on the time periods that can be reserved on the reservation interface, making reservations more convenient and improving the user experience.

[0014] In a possible implementation, determining whether the user's reservation is successful includes:

[0015] According to the identification information of the target resource, the reservation status record table of the target resource is searched in the database to determine the reservation status of the target resource in the target time period; wherein the reservation status record table records the reservation status of each reservable time period of the target resource;

[0016] Whether the user's reservation is successful is determined based on the reservation status of the target resource in the target time period.

[0017] The beneficial effects of this implementation method are as follows: the reservation status of each available time period of the target resource is recorded in the reservation record table, and then whether the user's reservation is successful is determined based on the reservation status, which can avoid reservation conflicts and control that only one user will successfully reserve the same resource in the same time period, thereby improving resource utilization.

[0018] In a possible implementation manner, determining whether the user's reservation is successful according to the reservation status of the target resource in the target time period includes:

[0019] Based on the reservation status of the target resource in the target time period, if it is determined that the target resource has not been reserved in the target time period, determining that the user reservation is successful;

[0020] Based on the reservation status of the target resource in the target time period, if it is determined that the target resource has been reserved in the target time period, it is determined that the user reservation has failed.

[0021] The beneficial effects of this implementation method are as follows: determining whether a user can make a successful reservation based on the reservation status of the target time period can avoid reservation conflicts, and only one user will make a successful reservation for the same resource in the same time period, thereby improving resource utilization.

[0022] In a possible implementation, the method further includes:

[0023] When it is determined that the user's reservation is successful, a message indicating that the reservation is successful is sent to the user;

[0024] When it is determined that the user's reservation has failed, information indicating the reservation failure is sent to the user.

[0025] The beneficial effect of this implementation method is that by feeding back the reservation result to the user, the user can be informed of the reservation status, so that the user can make a work plan in advance and better use the target resources in the target time period.

[0026] In a possible implementation, the method further includes:

[0027] When it is determined that the user's reservation is successful, the reservation status record table of the target resource is updated so that the reservation status of the target time period in the reservation status record table is indicated as having been reserved.

[0028] The beneficial effect of this implementation method is that by locking the reserved time period, reservation conflicts can be effectively avoided, so that only one user can successfully reserve the same resource in the same time period.

[0029] In a possible implementation, the distributed cache database is a Redis database; the reservation status record table uses a hash table structure to record the reservation status of each reservable time period of the target resource in a key-value pair manner.

[0030] The beneficial effect of this implementation method is that by using the Redis database and hash table structure, the data processing speed can be improved and reservation conflicts can be effectively avoided.

[0031] In a possible implementation manner, obtaining the execution status of the scheduled task includes:

[0032] Receive the reservation adjustment instruction for the reservation task sent by the user through the client resource reservation platform, and determine the execution status of the reservation task.

[0033] The beneficial effect of this implementation method: Through the above method, the execution status of the scheduled task can be obtained in a timely and accurate manner, so as to adjust the asynchronous delay monitoring task later.

[0034] In one possible implementation, the asynchronous delay monitoring task includes a resource occupation monitoring task and a resource release monitoring task. The resource occupation monitoring task is used to start periodically based on a first preset delay parameter to monitor whether the target resource can be occupied at the beginning of the target time period; the resource release monitoring task is used to start periodically based on a second preset delay parameter to monitor whether the target resource has been released at the end of the target time period.

[0035] The beneficial effects of this implementation method are as follows: monitoring based on asynchronous delayed monitoring tasks will not only not affect the execution of other tasks, but also shorten the task monitoring time due to the delayed processing. There is no need to continuously monitor the execution status of the scheduled tasks, which can greatly alleviate the pressure on the server to process tasks, thereby improving the overall performance of the server.

[0036] In a possible implementation, adjusting the asynchronous delay monitoring task according to the execution status of the scheduled task includes:

[0037] If it is determined based on the execution status of the scheduled task that the scheduled task is cancelled before execution, then the start of the resource occupancy monitoring task and the resource release monitoring task are cancelled;

[0038] If it is determined based on the execution status of the scheduled task that the scheduled task ends early after the start of execution, the start of the resource release monitoring task is canceled.

[0039] The beneficial effects of this implementation method are as follows: before starting the asynchronous delay monitoring task, the asynchronous delay monitoring task can be flexibly adjusted based on the execution status of the scheduled task, which can avoid invalid task startup and monitoring, effectively reduce the probability of task queue congestion, and relieve server pressure.

[0040] In a second aspect, an embodiment of the present application further provides a computing device, the computing device comprising a processor, the processor being connected to a memory;

[0041] The memory stores computer-executable instructions;

[0042] The processor executes the computer-executable instructions stored in the memory to implement the method as described in any one of the first aspects.

[0043] The beneficial effects of this embodiment are as follows: when the processor executes the resource reservation method described in any one of the first aspects, it can control that only one user can successfully make a reservation in each time period, which can not only avoid reservation conflicts but also improve resource utilization; further, since the reservation task is monitored in an asynchronous delayed monitoring manner, there is no need to continuously monitor the execution status of the reservation task, and the server's monitoring resources will not be continuously occupied, which greatly alleviates the pressure on the server to process tasks and can improve the overall performance of the server; in addition, before starting the asynchronous delayed monitoring task, the asynchronous delayed monitoring task is automatically adjusted according to the execution status of the reservation task, which can not only avoid invalid startup of the monitoring task and queue congestion, but also alleviate the data processing pressure of the device and save equipment operating costs. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the following is a brief introduction to the drawings required for use in the embodiments or the related technical descriptions. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0045] Figure 1 A schematic diagram of a resource reservation method provided in an embodiment of the present application;

[0046] Figure 2 A schematic diagram of the architecture of a Celery task mechanism provided in an embodiment of the present application;

[0047] Figure 3 A flowchart of another resource reservation method provided in an embodiment of the present application;

[0048] Figure 4 A schematic diagram of the structure of a resource reservation device provided in an embodiment of the present application;

[0049] Figure 5 A schematic diagram of the structure of a computing device is provided for an embodiment of the present application. DETAILED DESCRIPTION

[0050] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments made by ordinary technicians in this field under the enlightenment of the embodiments belong to the scope of protection of the present application.

[0051] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0052] Glossary:

[0053] RabbitMQ: is an open source message broker software (also known as message-oriented middleware) that implements the Advanced Message Queuing Protocol (AMQP). RabbitMQ is mainly used to implement the sending, receiving and routing of messages in a distributed system, and to help different applications or components communicate asynchronously. In the embodiment of the present application, RabbitMQ provides a task queue function, allowing tasks to queue in the queue and wait to be executed.

[0054] By adopting the resource reservation method, limited resources such as hardware equipment, conference rooms, and server computing resources can be used by more people, thereby improving resource utilization. However, when resources are scarce and there are many people who have made reservations, there will be scenarios with high concurrency tasks, resulting in multi-task queues. In the resource reservation scenario, if no corresponding measures are taken, when multiple users simultaneously grab resources in the same time period, it will cause resource allocation conflicts, resulting in low resource utilization.

[0055] In addition, after the resource reservation is successful, if the synchronous monitoring method is used to monitor the execution status of the reservation task in real time, it is necessary to continuously occupy the device monitoring resources, especially when there are many reservation tasks, which will cause a high device load. If the progress of executing the monitoring task is not enough, the monitoring tasks in the task queue are not executed, which will also cause task congestion, which may not only affect the processing efficiency of other tasks, but also cause a waste of device resources, which increases the operating cost of the equipment and may even affect the user's reservation experience.

[0056] To this end, an embodiment of the present application provides a resource reservation method, and the technical concept is as follows: in order to avoid reservation conflicts and ensure that only one user can successfully reserve the same resource in the same time period, the embodiment of the present application controls that only one user can successfully reserve in each time period through a distributed lock; for a reservation task that has been successfully reserved, the embodiment of the present application also generates two asynchronous delay monitoring tasks for it to monitor resource occupancy and resource release respectively. At the same time, if the execution status of the reservation task changes before the asynchronous delay monitoring task is started, the start of the asynchronous delay monitoring task is also adjusted in advance. In this way, not only can the monitoring resources of the device be avoided from being occupied due to long-term task monitoring, but also the invalid start of the monitoring task and the queue congestion can be avoided, and the data processing pressure of the device can be alleviated, saving the operating cost of the device.

[0057] The technical solution of the present application is described in detail below through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.

[0058] Figure 1 The flowchart of a resource reservation method provided in the embodiment of the present application is shown in FIG. The resource reservation method provided in the embodiment of the present application can be executed by a server for performing resource reservation. Figure 1 The resource reservation method may specifically include the following steps:

[0059] S101, receiving a reservation request message sent by a user, and determining whether the user's reservation is successful.

[0060] The reservation request information includes the identification information of the target resource that the user requests to reserve and the target time period.

[0061] For example, in the embodiment of the present application, the target resource requested by the user for reservation may be all resources that can be reserved, such as equipment resources, server computing resources, conference rooms, etc., and the identification information of the target resource may be information for uniquely identifying the target resource, such as resource ID and resource name. The target time period requested by the user for reservation is the time period during which the user wants to occupy the target resource.

[0062] When a user has a resource usage requirement, he can send a reservation request message to the server that makes resource reservations through the client, and the server can receive the reservation request message sent by the user, and then determine whether the user can make a successful reservation based on the reservation status of the target resource requested by the user in the target time period. It can be understood that in order to avoid reservation conflicts, in the embodiment of the present application, when a user's reservation is successful, it means that only the user has successfully obtained the right to use the target resource in the target time period, that is, only one user can make a successful reservation for the same resource in the same time period.

[0063] In a possible embodiment, receiving the reservation request information sent by the user may include: receiving the reservation request information sent by the user through a client resource reservation platform, wherein the reservation interface of the client resource reservation platform displays the resources that can be reserved and the time periods that can be reserved.

[0064] Exemplarily, in order to facilitate users to know the resources that can be booked and make resource reservations, the reservation interface of the client resource reservation platform can be set to display the resources that can be booked and the time period that can be booked. In this way, the user can directly click on the time period that can be booked on the reservation interface to make resource reservations, which is more convenient and the user experience will be better. For example, for the equipment resources that can be booked, they can be subdivided into 24 hours a day on the reservation interface, counted in hours, and each hour is a time period that can be booked when it is not booked by other users. Of course, the time period that can be booked can also be set according to the actual situation. For example, the equipment resources may need to be maintained in some time periods and cannot be used, so it can be set as a time period that cannot be booked. In actual applications, the time period displayed in the reservation interface can only include the time period that can still be booked at present, or it can include all time periods that can be booked, and then different colors are used to identify the time periods that are currently booked and not booked. The embodiment of the present application does not limit this.

[0065] When the user clicks on the available time slot that the user wants to reserve on the reservation interface of the client resource reservation platform, the client resource reservation platform will send a reservation request message to the server, and correspondingly, the server will receive the reservation request message sent by the user through the client resource reservation platform. After the server receives the reservation request message sent by the user, it parses the reservation request message and can determine the identification information and target time slot of the target resource requested by the user, and then determines whether the user can make a successful reservation based on the reservation status of the target resource requested by the user in the target time slot.

[0066] In a possible embodiment, determining whether the user's reservation is successful may include:

[0067] S1. According to the identification information of the target resource, the reservation status record table of the target resource is searched in the database to determine the reservation status of the target resource in the target time period. The reservation status record table records the reservation status of each reservable time period of the target resource.

[0068] Optionally, the database may be a Redis database; the reservation status record table uses a hash table structure to record the reservation status of each reservable time period of the target resource in a key-value pair manner.

[0069] S2. Determine whether the user's reservation is successful based on the reservation status of the target resource in the target time period.

[0070] Exemplarily, in order to achieve that only one user can make a successful reservation for the same resource in the same time period, the embodiment of the present application is based on the method of distributed lock. In the database of the server, the identification information of the resource, such as the resource name, is used as the table name to create a reservation record table for each resource that can be reserved, which is used to record the reservation status of each time period that can be reserved for the resource. Optionally, the database can be a Redis database, and each reservation record table can use a hash table structure. The key in the table represents the time period, and the value represents whether the time period has been reserved. For example, the value is "true" to indicate that it has been reserved, and the value is "false" to indicate that it has not been reserved. In this way, when determining whether the user has made a successful reservation, the server can directly find the reservation record table of the target resource in the Redis database based on the identification information of the target resource, so as to quickly determine the reservation status of the target resource in the target time period, and then determine whether the user can make a successful reservation based on the reservation status of the target resource in the target time period. Based on this method, not only can it be clear whether each time period has been reserved, but also reservation conflicts can be avoided, and the data processing efficiency is also high enough.

[0071] In addition, in some possible embodiments, the reservation status recorded in the reservation status record table may also record other information according to actual needs in addition to whether the time period has been reserved, such as: the resource reserver / reservation user, the current status of the resource (whether it is being used, whether it has been reserved, whether it has been released in advance, whether it has been released upon expiration, etc.), the startup status of the corresponding asynchronous delay monitoring task (whether it has been started), and other information. The embodiments of the present application do not impose any restrictions on this. By recording the reservation status in detail, the actual reservation status can be more clearly known.

[0072] In a possible embodiment, step S2, determining whether the user's reservation is successful according to the reservation status of the target resource in the target time period, may include:

[0073] S21. Based on the reservation status of the target resource in the target time period, if it is determined that the target resource is not reserved in the target time period, it is determined that the user's reservation is successful.

[0074] S22: Based on the reservation status of the target resource in the target time period, if it is determined that the target resource has been reserved in the target time period, it is determined that the user reservation has failed.

[0075] Exemplarily, the server can search for the value corresponding to the target time period at the current moment in the reservation status record table of the target resource. If the value corresponding to the current moment is "false", it means that the target resource has not been reserved in the target time period and the user can make a reservation. At this time, the server can determine that the user's reservation is successful; if the value corresponding to the current moment is "true", it means that the target resource has been reserved in the target time period and the user cannot make a reservation. At this time, the server can determine that the user's reservation has failed.

[0076] In a possible embodiment, when it is determined that the user's reservation is successful, the server may send a message indicating that the reservation is successful to the user; when it is determined that the user's reservation is unsuccessful, the server may send a message indicating that the reservation is unsuccessful to the user. By feeding back the reservation result to the user, the user can be informed of the reservation status, so that the work plan can be made in advance and the target resources can be better used in the target time period.

[0077] In a possible embodiment, when it is determined that the user has made a successful reservation, the server may also update the reservation status record table of the target resource, so that the reservation status of the target time period in the reservation status record table is indicated as having been reserved. By locking the reserved time period, reservation conflicts can be effectively avoided, so that only one user can make a successful reservation for the same resource in the same time period.

[0078] S102: When the user's reservation is successful, an asynchronous delayed monitoring task for the user's reservation task is generated.

[0079] Among them, the asynchronous delay monitoring task is used to start regularly based on preset delay parameters to monitor the usage status of the target resource in the target time period.

[0080] For example, after determining that the user's reservation is successful, in the embodiment of the present application, the server will also generate an asynchronous delay monitoring task for the user's reservation task. The asynchronous delay monitoring task will be started regularly based on the preset delay parameters to monitor the usage status of the target resource in the target time period.

[0081] In a possible embodiment, in the embodiment of the present application, the asynchronous delay monitoring task may include a resource occupation monitoring task and a resource release monitoring task. The resource occupation monitoring task is used to be started regularly based on a first preset delay parameter to monitor whether the target resource can be occupied at the beginning of the target time period; the resource release monitoring task is used to be started regularly based on a second preset delay parameter to monitor whether the target resource has been released at the end of the target time period.

[0082] It can be understood that the target time period has a start time and an end time. After the server generates the corresponding resource occupancy monitoring task and resource release monitoring task for each successfully scheduled appointment task, the resource occupancy monitoring task and the resource release monitoring task can be temporarily stored in the task queue, and each asynchronous delay monitoring task can be identified by the task ID. When the preset delay parameter is reached, the resource occupancy monitoring task and the resource release monitoring task will automatically start. Among them, the embodiment of the present application does not limit the specific values ​​of the preset delay parameters. For example, the first preset delay parameter corresponding to the resource occupancy monitoring task can be two minutes before the start time of the target time period, and the second preset delay parameter corresponding to the resource release monitoring task can be two minutes before the end time of the target time period. Of course, the preset delay parameters can also be set to other values ​​according to actual needs. Taking this as an example, when the time reaches two minutes before the start time of the target time period, the resource occupation monitoring task is started to monitor whether the target resource can be occupied at the start time of the target time period. After determining whether the target resource can be occupied at the start time of the target time period, the resource occupation monitoring task is considered to be completed. In other words, the resource occupation monitoring task can actually be executed for only two minutes. Similarly, when the time reaches two minutes before the end time of the target time period, the resource release monitoring task is started to monitor whether the target resource has been released at the end time of the target time period. After determining whether the target resource has been released at the end time of the target time period, the resource release monitoring task is considered to be completed. In other words, the resource release monitoring task can actually be executed for only two minutes.

[0083] Compared with other tasks that need to continuously monitor the target resources after the task reservation is successful, the embodiment of the present application is based on asynchronous delayed monitoring tasks for monitoring, which not only will not affect the execution of other tasks, but also because of the delay processing, it only needs to be started based on the preset delay parameters, which shortens the task monitoring time and no longer requires continuous monitoring of the usage status of the target resources, which can greatly alleviate the pressure of the server to process tasks, thereby improving the overall performance of the server.

[0084] S103: Before starting the asynchronous delay monitoring task, obtain and adjust the asynchronous delay monitoring task according to the execution status of the scheduled task.

[0085] For example, the asynchronous delay monitoring task will not be started until the scheduled delay parameter is reached. Before that, the execution status of the task successfully scheduled by the user may change. For example, the user may cancel the scheduled task, or the target time period scheduled by the user may change, or the user may end the use of the target resource in advance, etc. In order to reduce unnecessary task startups, the server can obtain and adjust the asynchronous delay monitoring task according to the execution status of the scheduled task before starting the asynchronous delay monitoring task. The adjustment measures may include but are not limited to canceling the original asynchronous delay monitoring task, generating a new monitoring task, or modifying the startup parameters of the existing monitoring task.

[0086] In a possible embodiment, obtaining the execution status of the scheduled task may include:

[0087] Receive the reservation adjustment instruction for the reservation task sent by the user through the client resource reservation platform, and determine the execution status of the reservation task.

[0088] For example, after a user successfully reserves a task, if the user wants to cancel the reservation task, or wants to change the target time period of the reservation, or wants to end the use of the target resources ahead of schedule, etc., the user can send a reservation adjustment instruction to the reservation task through the client resource reservation platform. After the adjustment is successful, the execution status of the reservation task will change accordingly, and accordingly, the server that makes the resource reservation can determine the new execution status of the reservation task.

[0089] In a possible embodiment, adjusting the asynchronous delay monitoring task according to the execution status of the scheduled task may include:

[0090] S10: If it is determined based on the execution status of the scheduled task that the scheduled task is cancelled before execution, the start of the resource occupation monitoring task and the resource release monitoring task is cancelled.

[0091] S20: If it is determined based on the execution status of the scheduled task that the scheduled task ends prematurely after the start of execution, the start of the resource release monitoring task is canceled.

[0092] Exemplarily, before starting the asynchronous delay monitoring task, if the server determines that the scheduled task is canceled before execution based on the execution status of the scheduled task, the start of the resource occupation monitoring task and the resource release monitoring task can be directly canceled; if the server determines that the scheduled task ends early after the start of execution based on the execution status of the scheduled task, the start of the resource release monitoring task can be canceled, thereby avoiding invalid task startup and monitoring. Exemplarily, when canceling the start of the asynchronous delay monitoring task, the corresponding task in the task queue can be found based on the ID of the asynchronous delay monitoring task, and it can be deleted, and the deleted monitoring task will not be started again. By deleting useless monitoring tasks in a timely manner, these deleted useless monitoring tasks will not occupy the storage space of the task queue, thereby effectively avoiding the blockage of monitoring tasks in the task queue, and can also effectively alleviate the task processing pressure of the server.

[0093] Optionally, if before starting the asynchronous delay monitoring task, the server determines that the user's reservation time period has changed, the server may also automatically change the corresponding reservation delay parameters so that the corresponding asynchronous delay monitoring task is started at the corresponding time, and so on. The server may automatically adjust the startup of the asynchronous delay monitoring task according to the actual status of the reservation task after the execution status is changed.

[0094] In an embodiment of the present application, before starting the asynchronous delay monitoring task, the server can automatically adjust the asynchronous delay monitoring task according to the actual execution status of the scheduled task. Compared with the fixed monitoring tasks in the related technology, the solution of the embodiment of the present application is more flexible and practical, and can better meet the actual needs of users.

[0095] Optionally, in a possible embodiment, the asynchronous delay monitoring task of the embodiment of the present application can be implemented by the Celery task mechanism. When the asynchronous delay monitoring task of the embodiment of the present application is implemented by the Celery task mechanism, the number of worker nodes (workers) for task processing can be determined by the number of server cores. Generally, the number of processes started is consistent with the number of cores of the server CPU by default. Of course, the concurrency parameter (concurrency) can also be configured according to demand to limit the high concurrency number and avoid a large number of tasks being blocked.

[0096] Figure 2 A schematic diagram of the architecture of a Celery task mechanism provided in an embodiment of the present application. Figure 2 , Figure 2The architecture of asynchronous delay monitoring is implemented using the Celery task mechanism. After the user successfully reserves the target resource through the client resource reservation platform, the message queue can be used to distribute the asynchronous delay monitoring task corresponding to the reservation task for the user's successful reservation task. The asynchronous delay monitoring tasks that are delayed will be placed in the queue (such as RabbitMQ, Redis, etc.). When the asynchronous delay monitoring tasks corresponding to each reservation task are to be executed, the worker process (workers) will take out the corresponding monitoring task from the queue and execute it. When the asynchronous delay monitoring task is canceled / released in advance, the worker process (workers) will delete the corresponding monitoring task from the queue. In addition, since the Celery task mechanism can provide a tracking mechanism for task results, after executing the asynchronous delay monitoring task, the execution result of the monitoring task can be obtained and saved. Optionally, the execution result of the monitoring task can be saved in the database of the reservation task so that the server knows the execution status of the monitoring task corresponding to the reservation task.

[0097] The Celery task mechanism can realize the processing of distributed and asynchronous monitoring tasks through the collaborative work of components such as message brokers, task queues, work nodes, and result storage. It has high flexibility and practicality and can meet the needs of executing asynchronous delay monitoring tasks in the embodiments of the present application. Of course, the asynchronous delay monitoring tasks in the embodiments of the present application can also be completed in other ways, and the embodiments of the present application do not limit this.

[0098] The resource reservation method provided by the embodiment of the present application includes: receiving reservation request information sent by a user, and determining whether the user's reservation is successful; wherein the reservation request information includes identification information and a target time period of the target resource requested by the user for reservation, and a successful reservation indicates that only the user has successfully obtained the right to use the target resource within the target time period; if the user's reservation is successful, an asynchronous delay monitoring task for the user's reservation task is generated; wherein the asynchronous delay monitoring task is used to start based on preset delay parameters to monitor the execution status of the reservation task; before starting the asynchronous delay monitoring task, the asynchronous delay monitoring task is adjusted according to the execution status of the reservation task. Compared with the related technology, the embodiment of the present application controls that only one user can make a successful appointment in each time period, which can not only avoid appointment conflicts but also improve resource utilization; further, the embodiment of the present application adopts asynchronous delay monitoring to monitor the appointment task, so there is no need to continuously monitor the execution status of the appointment task, and the server's monitoring resources will not be continuously occupied, which greatly alleviates the pressure on the server to process tasks and can improve the overall performance of the server; in addition, the embodiment of the present application also automatically adjusts the asynchronous delay monitoring task according to the execution status of the appointment task before starting the asynchronous delay monitoring task, which can not only avoid invalid startup of the monitoring task and queue congestion, but also alleviate the data processing pressure of the device and save equipment operating costs.

[0099] Figure 3 A flowchart of another resource reservation method provided in an embodiment of the present application. Figure 3 The resource reservation method provided in the embodiment of the present application may specifically include the following steps:

[0100] S301: receiving reservation request information sent by a user through a client resource reservation platform.

[0101] The reservation request information includes the identification information of the target resource that the user requests to reserve and the target time period. A successful reservation indicates that only the user successfully obtains the right to use the target resource within the target time period.

[0102] S302: According to the identification information of the target resource, the reservation status record table of the target resource is searched in the database to determine the reservation status of the target resource in the target time period.

[0103] S303: Determine whether the user's reservation is successful based on the reservation status of the target time period.

[0104] If yes, execute steps S304 and S305, or directly execute step S307; if no, execute step S306.

[0105] S304: Send information indicating successful reservation to the user.

[0106] S305: Update the reservation status record table of the target resource.

[0107] S306: Send a message to the user indicating that the reservation has failed.

[0108] Among them, steps S304 to S306 may be optional steps.

[0109] S307: Generate a resource occupancy monitoring task and a resource release monitoring task for the user's scheduled task.

[0110] S308: Before starting the resource occupancy monitoring task, determine whether the scheduled task has been cancelled.

[0111] If yes, execute step S309, if no, execute step S310.

[0112] S309: Cancel the start of the resource occupation monitoring task and the resource release monitoring task.

[0113] S310: Before starting the resource release monitoring task, determine whether the scheduled task is terminated early after the start of execution.

[0114] If yes, execute step S311, if no, execute step S312.

[0115] S311. Cancel the start of the resource release monitoring task.

[0116] S312: When the reservation delay parameter is reached, the resource release monitoring task is started.

[0117] It should be noted that the specific implementation process of the above steps can refer to the description of the previous embodiment and will not be repeated here.

[0118] Compared with the related technology, the embodiment of the present application controls that only one user can make a successful appointment in each time period, which can not only avoid appointment conflicts but also improve resource utilization; further, the embodiment of the present application adopts asynchronous delay monitoring to monitor the appointment task, so there is no need to continuously monitor the execution status of the appointment task, and the server's monitoring resources will not be continuously occupied, which greatly alleviates the pressure on the server to process tasks and can improve the overall performance of the server; in addition, the embodiment of the present application also automatically adjusts the asynchronous delay monitoring task according to the execution status of the appointment task before starting the asynchronous delay monitoring task, which can not only avoid invalid startup of the monitoring task and queue congestion, but also alleviate the data processing pressure of the device and save equipment operating costs.

[0119] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.

[0120] Figure 4 This is a schematic diagram of the structure of a resource reservation device provided in an embodiment of the present application. Figure 4 As shown, the resource reservation device 40 provided in the embodiment of the present application includes a processing unit 401 , a generating unit 402 and an adjusting unit 403 .

[0121] The processing unit 401 is used to receive the reservation request information sent by the user and determine whether the user's reservation is successful; wherein the reservation request information includes the identification information of the target resource and the target time period requested by the user.

[0122] The generating unit 402 is used to generate an asynchronous delay monitoring task for the user's reservation task when the user's reservation is successful; wherein the asynchronous delay monitoring task is used to start regularly based on preset delay parameters to monitor the usage status of the target resource in the target time period.

[0123] The adjustment unit 403 is used to obtain and adjust the asynchronous delay monitoring task according to the execution status of the scheduled task before starting the asynchronous delay monitoring task.

[0124] In one implementation, the processing unit 401 is specifically configured to:

[0125] Reservation request information sent by a user through a client resource reservation platform is received; wherein the reservation interface of the client resource reservation platform displays the resources that can be reserved and the time periods that can be reserved.

[0126] In one implementation, the processing unit 401 is further specifically configured to:

[0127] According to the identification information of the target resource, the reservation status record table of the target resource is searched in the database to determine the reservation status of the target resource in the target time period; wherein the reservation status record table records the reservation status of each reservable time period of the target resource;

[0128] Determine whether the user's reservation is successful based on the reservation status of the target resource in the target time period.

[0129] In one implementation, the processing unit 401 is further specifically configured to:

[0130] Based on the reservation status of the target resource in the target time period, if it is determined that the target resource is not reserved in the target time period, it is determined that the user's reservation is successful;

[0131] Based on the reservation status of the target resource in the target time period, if it is determined that the target resource has been reserved in the target time period, it is determined that the user reservation has failed.

[0132] In one implementation, the processing unit 401 is further specifically configured to:

[0133] When it is determined that the user's reservation is successful, the reservation status record table of the target resource is updated so that the reservation status of the target time period in the reservation status record table is indicated as having been reserved.

[0134] In one implementation, the database is a Redis database; the reservation status record table uses a hash table structure to record the reservation status of each reservable time period of the target resource in a key-value pair manner.

[0135] In one implementation, the processing unit 401 is further configured to:

[0136] Receive the reservation adjustment instruction for the reservation task sent by the user through the client resource reservation platform, and determine the execution status of the reservation task.

[0137] In one implementation, the asynchronous delay monitoring task includes a resource occupation monitoring task and a resource release monitoring task. The resource occupation monitoring task is used to start periodically based on a first preset delay parameter to monitor whether the target resource can be occupied at the beginning of a target time period; the resource release monitoring task is used to start periodically based on a second preset delay parameter to monitor whether the target resource has been released at the end of the target time period.

[0138] In one implementation, the adjusting unit 403 is specifically configured to:

[0139] If it is determined based on the execution status of the scheduled task that the scheduled task is cancelled before execution, the start of the resource occupancy monitoring task and the resource release monitoring task is cancelled;

[0140] If it is determined based on the execution status of the scheduled task that the scheduled task ends prematurely after the start of execution, the start of the resource release monitoring task is canceled.

[0141] The device provided in this embodiment can be used to execute the method of the above embodiment. Its implementation principle and technical effect are similar and will not be described in detail here.

[0142] It should be noted that it should be understood that the division of the various modules of the above device is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software called by processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software called by processing elements, and some modules can be implemented in the form of hardware. In addition, it can also be stored in the memory of the above device in the form of program code, and the functions of the above data processing modules can be called and executed by a processing element of the above device. The implementation of other modules is similar. In addition, all or part of these modules can be integrated together, or they can be implemented independently. The processing element here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.

[0143] Figure 5 A schematic diagram of the structure of a computing device is provided for an embodiment of the present application. Figure 5 As shown, the computing device 50 includes a processor 501, and the processor 501 is connected to a memory 502. The computing device can be an electronic device with resource reservation capability, such as a server, a computer, a notebook, a desktop computer or a mobile phone.

[0144] The memory 502 is used to store computer-executable instructions. The memory 502 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.

[0145] The processor 501 is used to execute the computer-executable instructions stored in the memory 502 to implement the network configuration method described in the aforementioned method embodiment. The processor 501 may be a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application.

[0146] The computing device 50 may further include a communication interface 503, so as to communicate and interact with an external device through the communication interface 503. The external device may be, for example, a server or other computing devices.

[0147] In specific implementation, if the communication interface 503, the memory 502 and the processor 501 are implemented independently, the communication interface 503, the memory 502 and the processor 501 can be connected to each other through a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc., but it does not mean that there is only one bus or one type of bus.

[0148] Optionally, in a specific implementation, if the communication interface 503, the memory 502 and the processor 501 are integrated on a chip, the communication interface 503, the memory 502 and the processor 501 can communicate through an internal interface.

[0149] The computing device provided in this embodiment can execute the resource reservation method in the above method embodiment, and its beneficial effects are similar, which will not be described again here.

[0150] An embodiment of the present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the resource reservation method provided by any of the aforementioned method embodiments.

[0151] An embodiment of the present application also provides a computer program product, including a computer program, which is used to implement the resource reservation method provided by the aforementioned method embodiment when executed by a processor.

[0152] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.

[0153] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the embodiments of the present application, rather than to limit them. Although the embodiments of the present application have been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein by equivalents. These modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A resource reservation method, characterized in that: The method comprises: Receive reservation request information sent by the user, and determine whether the user's reservation is successful; wherein the reservation request information includes the identification information and target time period of the target resource requested by the user for reservation; When the user's reservation is successful, an asynchronous delay monitoring task is generated for the user's reservation task; wherein the asynchronous delay monitoring task is used to start regularly based on a preset delay parameter to monitor the usage status of the target resource in the target time period; Before starting the asynchronous delay monitoring task, the asynchronous delay monitoring task is obtained and adjusted according to the execution status of the scheduled task.

2. The method according to claim 1, characterized in that Receive reservation request information sent by users, including: Reservation request information sent by a user through a client resource reservation platform is received; wherein the reservation interface of the client resource reservation platform displays resources that can be reserved and time periods that can be reserved.

3. The method according to claim 1, characterized in that Determine whether the user's reservation is successful, including: According to the identification information of the target resource, the reservation status record table of the target resource is searched in the database to determine the reservation status of the target resource in the target time period; wherein the reservation status record table records the reservation status of each reservable time period of the target resource; Whether the user's reservation is successful is determined based on the reservation status of the target resource in the target time period.

4. The method according to claim 3, characterized in that Determining whether the user's reservation is successful according to the reservation status of the target resource in the target time period includes: Based on the reservation status of the target resource in the target time period, if it is determined that the target resource has not been reserved in the target time period, determining that the user reservation is successful; Based on the reservation status of the target resource in the target time period, if it is determined that the target resource has been reserved in the target time period, it is determined that the user reservation has failed.

5. The method according to claim 4, characterized in that The method further comprises: When it is determined that the user's reservation is successful, the reservation status record table of the target resource is updated so that the reservation status of the target time period in the reservation status record table is indicated as having been reserved.

6. The method according to claim 3, characterized in that The database is a Redis database; the reservation status record table uses a hash table structure to record the reservation status of each reservable time period of the target resource in a key-value pair manner.

7. The method according to claim 1, characterized in that The obtaining the execution status of the scheduled task includes: Receive the reservation adjustment instruction for the reservation task sent by the user through the client resource reservation platform, and determine the execution status of the reservation task.

8. The method according to any one of claims 1 to 7, characterized in that The asynchronous delay monitoring task includes a resource occupancy monitoring task and a resource release monitoring task, and the resource occupancy monitoring task is used to start regularly based on a first preset delay parameter to monitor whether the target resource can be occupied at the start time of the target time period; The resource release monitoring task is used to be started regularly based on a second preset delay parameter to monitor whether the target resource has been released at the end of the target time period.

9. The method according to claim 8, characterized in that According to the execution status of the scheduled task, adjusting the asynchronous delay monitoring task includes: If it is determined based on the execution status of the scheduled task that the scheduled task is cancelled before execution, then the start of the resource occupancy monitoring task and the resource release monitoring task are cancelled; If it is determined based on the execution status of the scheduled task that the scheduled task ends early after the start of execution, the start of the resource release monitoring task is canceled.

10. A computing device, characterized in that The computing device includes a processor connected to a memory; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 9.