Architecture for providing on-demand and background processing

Embodiments are directed to providing schedule-based processing using web service on-demand message handling threads and to managing processing threads based on estimated future workload. In an embodiment, a web service platform receives a message from a client that is specified for schedule-based, background handling. The web service platform includes an on-demand message handling service with processing threads that are configured to perform on-demand message processing. The web service platform loads the on-demand message handling service including the on-demand message handling threads. The web service platform implements the on-demand message handling service's threads to perform background processing on the received client message. The client messages specified for background handling are thus handled as service-initiated on-demand tasks.

BACKGROUND

Computers have become highly integrated in the workforce, in the home, in mobile devices, and many other places. Computers can process massive amounts of information quickly and efficiently. Software applications designed to run on computer systems allow users to perform a wide variety of functions including business applications, schoolwork, entertainment and more. Software applications are often designed to perform specific tasks, such as word processor applications for drafting documents, or email programs for sending, receiving and organizing email.

In many cases, software applications are designed to interact with other software applications or other computer systems. For example, web browsers may interact with web servers to request and receive data which is presented to a user. These web servers may be configured to provide web services. Such web services are typically designed to provide interactive or on-demand processing. As such, the web services fail to provide schedule-based, background processing.

BRIEF SUMMARY

Embodiments described herein are directed to providing schedule-based processing using web service on-demand message handling threads and to managing processing threads based on estimated future workload. In one embodiment, a web service platform receives a message from a client that is specified for schedule-based, background handling. The web service platform includes an on-demand message handling service with processing threads that are configured to perform on-demand message processing. The web service platform loads the on-demand message handling service including the on-demand message handling threads. The web service platform implements the on-demand message handling service's threads to perform background processing on the received client message. The client messages specified for background handling are thus handled as service-initiated on-demand tasks.

In another embodiment, a web service platform receives a message from a client that is specified for schedule-based, background handling. The web service platform includes an on-demand message handling service with non-terminating processing threads that are configured to perform on-demand message processing. The non-terminating on-demand message handling threads implement one-way messages to propel a polling loop that polls for background processing work items. The web service platform loads the on-demand message handling service including the on-demand message handling threads. The web service platform implements the on-demand message handling service's threads to perform background processing on the received client message. The client messages specified for background handling are thus handled as service-initiated on-demand tasks. The web service platform also estimates a future workload for the web service platform based on at least one of current and past polling loop activity and suspends background processing based on the estimated future workload.

DETAILED DESCRIPTION

Embodiments described herein are directed to providing schedule-based processing using web service on-demand message handling threads and to managing processing threads based on estimated future workload. In one embodiment, a web service platform receives a message from a client that is specified for schedule-based, background handling. The web service platform includes an on-demand message handling service with processing threads that are configured to perform on-demand message processing. The web service platform loads the on-demand message handling service including the on-demand message handling threads. The web service platform implements the on-demand message handling service's threads to perform background processing on the received client message. The client messages specified for background handling are thus handled as service-initiated on-demand tasks.

In another embodiment, a web service platform receives a message from a client that is specified for schedule-based, background handling. The web service platform includes an on-demand message handling service with non-terminating processing threads that are configured to perform on-demand message processing. The non-terminating on-demand message handling threads implement one-way messages to propel a polling loop that polls for background processing work items. The web service platform loads the on-demand message handling service including the on-demand message handling threads. The web service platform implements the on-demand message handling service's threads to perform background processing on the received client message. The client messages specified for background handling are thus handled as service-initiated on-demand tasks. The web service platform also estimates a future workload for the web service platform based on at least one of current and past polling loop activity and suspends background processing based on the estimated future workload.

The following discussion now refers to a number of methods and method acts that may be performed. It should be noted, that although the method acts may be discussed in a certain order or illustrated in a flow chart as occurring in a particular order, no particular ordering is necessarily required unless specifically stated, or required because an act is dependent on another act being completed prior to the act being performed.

FIG. 1illustrates a computer architecture100in which the principles of the present invention may be employed. Computer architecture100includes web service platform110. Web service platform110may be any type of distributed or local computing system that is configured to provide web services, data processing or other internet-related functions. The web service platform may be provided by a cloud computing system that is distributed over a plurality of different computer systems. The web service platform may include an on-demand message handling service115that is configured to process on-demand messages. For instance, on-demand message106may be received from client105. The client may send message106indicating that the client wishes to access a web service provided by the web service platform.

The on-demand message handling service115may include multiple different processing threads116. These processing threads may be used to process various aspects of a web service, software program or other software function, or in processing the received message. Web service platform110may also include a background service120that includes processing threads121for processing background tasks. In some cases, the on-demand message handling service's threads may be used to perform background processing on client message106. In this manner, client messages specified for background handling are handled as service-initiated on-demand tasks, where the results from the processing (e.g. processed response122) are sent back to the client.

Background processing by service120may include periodic actions and work items polled from a set of queues. The queues may be populated by external schedulers, on-demand client requests, and work items themselves. Such polling may be performed on a continual basis through periodic calls to a remote messaging interface (in some cases, similar to web services for on-demand requests) from an external component. Each call may execute continuously until the next call. This converts pushes from the external component to the service tier into pulls and periodic actions inside the service tier. Background processing threads may be activated by the web service platform upon receiving client messages. Using these client messages, the client pushes the web service platform110to perform background processing. The web service platform then converts the client's pushes into its own pulls of work items.

In some cases, the web service platform calculates when the next work item will arrive, and compares that time with the current time. If the difference is sufficiently large, background processing will be suspended, since the cost of keeping it running for that large amount of time is higher than the cost of restarting the background processing. To ensure that the work item will be processed when it arrives, the client105sends a message to start background processing before then. For scheduled work items, the web service platform and the client may use similar methods to calculate the time of the very next work item, based on the schedule definitions of all the work items currently in queue.

As mentioned above, on-demand message processing threads116may be used for background processing. The on-demand message threads for background processing may be non-terminating. Background processing may reinitialize after failures through a web service request loop generated by the client. A message loop may send messages to the web service platform to perform background processing as interrupts. Interrupts may further be used to avoid hitting timeout thresholds set by the web service platform to control how long an individual message can be processed by the web service platform. In other words, it avoids having a single message consume resources for too long. A single logical loop may be implemented for background work item polling which continues across multiple messages (e.g.106). The message loop and background processing may be suspended based on a determination of future workload. Work may be distributed to all nodes hosting background processing through random addressing, load balancing and/or message bouncing. A message initiator domain may be provided which may increase the reliability of background processing threads through message distribution. Processing threads may have identical characteristic so that each can process work items. A unified architecture for interactive/on-demand processing and background/scheduled processing may also be provided which shares common features in the areas such as activation, health monitoring, resource recycles, deployment and hosting.

Background processing workers are hosted in the same process hosting interactive web services. An independent operating timer periodically sends a message to the process through a remote messaging interface. A message arriving at a worker results in a thread that initialize the background processing and performs work item polling. The thread will run until another message arrives. If such a thread terminate due to failure, or does not yield to a new message in time, the new message will reinitialize the background processing. This ensures its availability. Even if time allowed for a single message is limited, the background processing can run infinitely.

In some cases, a single infinite loop is used to poll work items. The loop may span multiple message threads. The loop yields a return in each iteration, while each thread iterates through the yield returns of the loop, checking signals set by newer messages. In some cases, a single thread may consume data returned by the loop.

The messages may be sent to different nodes randomly or through a load balancer. The message initiator and the poll of workers may be separated, allowing fault tolerance of individual threads and scalability. To ensure messages reach the threads, even when direct exhaustive addressing is not possible (for example, if messages have to go through a load balancer), message bouncing may be utilized. In some cases, messages may be given a minimum life expectancy. When a new message arrives, if the current message has not exceeded its minimum life expectancy, it will send another message out to the load balancer, which has a reduced life expectancy of the remainder of the current one.

In some embodiments, separate processes for background processing are not implemented so that shared components between the interactive web service and background processing may be deployed and configured once, in one place and through the same user interface. Components specific to background processing may be deployed and configured the same way as other components. Features available to web service on-demand threads116through the web service platform110may be available to background processing threads121as well. These concepts will be explained in greater detail below with regard to method200ofFIG. 2.

FIG. 2illustrates a flowchart of a method200for providing schedule-based processing using web service on-demand message handling threads. The method200will now be described with frequent reference to the components and data of environments100and400ofFIGS. 1 and 4, respectively.

Method200includes an act of receiving at a web service platform a message from a client that is specified for schedule-based, background handling, wherein the web service platform includes an on-demand message handling service with one or more threads that are configured to perform on-demand message processing (act210). For example, web service platform110may receive message106from client105. The message may be specified for schedule-based, background handling. Schedule-based handling may refer to the processing of messages according to a certain schedule or queue, where each message is placed in line for processing at a certain time or in a certain order. The web service platform may include an on-demand message handling service115that performs on-demand message processing. As the name implies, the on-demand service uses processing threads116to process messages as they are received, and not according to a schedule as the background service is configured to do.

In some cases, both on-demand and background processing occur on a single host. Thus, in cases where the web service platform110is hosted on a single computer system, both the on-demand service115as well as the background service120may be hosted on the same computer system. In cases where the web service platform is hosted on multiple computer systems (such as on the cloud or in another distributed system), the on-demand service and the background service may be hosted on different computing systems.

In some embodiments, schedule-based background handling comprises both user-scheduled scheduling and system-scheduled scheduling. Thus, background service120may process message106based on a user-specified schedule or a system-specified schedule. The schedule may be customized or modified by the user or by different software programs. The processing threads121of the background service may be allocated based on the user-defined or system-defined schedule.

Method200includes an act of the web service platform loading the on-demand message handling service including the on-demand message handling threads (act220). For example, web service platform110may load on-demand handling service115including on-demand processing threads116. These on-demand processing threads may be configured to process messages as they are received from various different clients and software systems. In some cases, the messages may include various work items. These work items may be distributed to a plurality of message processing threads. Thus, each work item may be processed by multiple different processing threads.

Method200includes an act of the web service platform implementing the on-demand message handling service's threads to perform background processing on the received client message, wherein client messages specified for background handling are handled as service-initiated on-demand tasks (act230). For example, web service platform110may implement on-demand processing threads116to perform background processing on message106. In this manner, client messages specified for background processing may be processed as service-initiated on-demand tasks.

In some cases, the on-demand message handling threads116implemented for background processing are non-terminating. That is, the message threads will continue to run until another message arrives. Thus, the message threads continue processing a given message until a new message is received. The non-terminating on-demand message handling threads may allocate at least one thread to propel a polling loop that polls for background processing work items. For instance, as shown inFIG. 4, on-demand message handling service415may use at least one of processing threads416to propel polling loop425. The loop is propelled to query work item queues to pull work items426from the queue. The pulled work items are426A are then sent back to processing threads416for on-demand processing. The on-demand processing of messages specified for background handling may automatically reinitialize after occurrence of a failure. Thus, when a failure does occur, automatic reinitialization may ensure that processing is automatically returned to a normal operating state.

The client405may send one-way messages406to the on-demand processing threads as interrupts. These interrupts may be used to restart a timer that tracks how long a work item is taking to process. Using this tracked processing time, timeout thresholds typically imposed by the on-demand message handling service may be avoided. Accordingly, allocated thread417may start the polling loop or take it over from the thread that is performing the loop in a timely manner to ensure that the work items are properly processed. Thread417may also check the health of the polling loop and reinitialize it when needed. If the polling loop is healthy, the web service platform may take over the polling loop from the processing thread for the previous message, without any re-initialization steps. In some cases, the polling loop may include a logical loop that continues across multiple different messages. Background processing may be started in one or more computer nodes through any of the following: random addressing, load balancing and message bouncing.

FIG. 3illustrates a flowchart of a method300for managing processing threads based on estimated future workload. The method300will now be described with frequent reference to the components and data of environments100and400ofFIGS. 1 and 4, respectively.

Method300includes an act of receiving at a web service platform a message from a client that is specified for schedule-based, background handling, wherein the web service platform includes an on-demand message handling service with one or more non-terminating threads that are configured to perform on-demand message processing, and wherein the non-terminating on-demand message handling threads allocate at least one thread to propel a polling loop that polls for background processing work items (act310). For example, web service platform410may receive one-way message406from client405that is specified for scheduled, background handling. The web service platform includes on-demand message handling service415with one or more non-terminating processing threads416that perform on-demand message processing.

As mentioned above, the non-terminating on-demand message processing threads may417to propel polling loop425forward. The loop425, upon receiving the allocated thread417from the processing threads416, queries a work item queue to pull work items426from the queue. Thus, the system acts in a “push” fashion where the on-demand processing threads drive the polling loop to query for and send work items426A back to the processing threads. The threads may then process the work item received from the polling loop.

Method300includes an act of the web service platform loading the on-demand message handling service including the on-demand message handling threads (act320). For example, web service platform410may load on-demand message handling service415which includes on-demand message handling threads416. The on-demand message handling service's threads may be implemented to perform background processing on the received client message. The client messages specified for background handling are handled as service-initiated on-demand tasks (act330). For instance, processing threads416, although typically used to perform on-demand message processing, may be configured to process messages specified for background handling. The processing threads may send the allocated thread(s) to polling loop425to access these background work items. The work items may be accessed in response to received one-way message406.

Method300also includes an act of estimating a future workload for the web service platform based on at least one of current and past polling loop activity (act340). For example, workload estimating module430may estimate a future workload431for web service platform415based on current polling loop activity, past polling loop activity, or activity over a specified period of time that includes past and current activity. The estimated workload may be sent to process suspending module435which determines whether various processes should be suspended and, if processes are to be suspended, which processes should be suspended.

Method300includes an act of suspending at least a portion of background processing based on the estimated future workload (act350). For example, process suspending module435may determine, based on the estimated future workload431, that processing on one or more background work items is to be suspended for a period of time. In some cases, the web service platform410calculates when the next work item will arrive, and compares that time with the current time. If the difference is sufficiently large, background processing will be suspended, since the cost of keeping is running for that large amount of time is higher than the cost of restarting the background processing. To ensure that the work item will be processed when it arrives, the client105sends a message to start background processing before then. For scheduled work items, the client calculates the time of the very next work item, based on the schedule definitions of all the work items currently in queue

The threshold level of processing for threads416, as well as the suspension period, may be customized by a user. The work items that are to be processed (i.e. those that have not been suspended) may be distributed to various nodes hosting background processing through any of the following: random addressing, load balancing and message bouncing. Thus, distribution of work items may reliably implemented in the web service platform.

Accordingly, systems, methods and computer program products are provided which implement schedule-based work item processing using web service on-demand message handling threads. Moreover, systems, methods and computer program products are provided which manage the processing of threads based on estimated future workload.