Abstract:
One aspect of the invention is a method for load balancing in a distributed object system running on a network comprising a plurality of computers ( 42, 44 ) including a first computer ( 44 ) wherein the computers ( 42, 44 ) are operable to access a plurality of shared objects in a distributed object system. The method comprises instructing an object comprising a part of an application process ( 50 ) running on the first computer ( 44 ) to record at least one performance statistic in response to a message directed to the object. The application process ( 50 ) comprises a multi-threaded process and includes a statistics thread ( 54 ). Periodically, at least one performance statistic is obtained using the statistics thread ( 54 ) and that performance statistic is sent to a local agent process ( 48 ) running on the first computer ( 44 ). The performance statistics are relayed to a workload service ( 46 ) running on a second computer ( 42 ) connected to the network. A new distributed object is instantiated in the memory of one of the plurality of computers ( 42, 44 ) based upon performance statistics maintained by the workload service ( 46 ).

Description:
TECHNICAL FIELD OF THE INVENTION 
     This invention relates generally to object-oriented programming and more particularly to a method and system for load balancing in a distributed object system. 
     BACKGROUND OF THE INVENTION 
     When large-scale distributed object systems are built, scalability and performance are major concerns. Scalability refers to the ability of a system to scale up to support a larger number of users, a larger workload, a larger number of transactions, and/or a larger number of services. In other words, scalability refers to the ability of a system to easily expand to perform more work. A system with good scalability allows one to introduce more resources as needed to scale the system to support the additional workload without making significant changes to the remainder of the system. 
     In typical distributed system environments, the load on the system changes, sometimes on a monthly basis and even on a daily basis. A flexible system should ideally make efficient use of all resources in the system to balance the load across the network and achieve high performance. 
     Software developers have begun considering the implementation of large distributed object systems. In such systems, it may be desirable for the systems manager to balance the workload of various computer processes across the network. Accordingly, a need has arisen for a scalable distributed object system that attains high performance by efficiently distributing the workload across a network. 
     SUMMARY OF THE INVENTION 
     The invention provides a method and system for load balancing in a distributed object system that facilitates the scalability and efficient performance of that system. One aspect of the invention is a method for load balancing in a distributed object system running on a network comprising a plurality of computers including a first computer wherein the computers are operable to access a plurality of shared objects in a distributed object system. The method comprises instructing an object comprising a part of an application process running on the first computer to record at least one performance statistic in response to a message directed to the object. The application process comprises a multi-threaded process including a statistics thread. The at least one performance statistic may be periodically obtained using the statistics thread and sent to a local agent process running on the first computer. The performance statistic is related to a workload service running on a second computer connected to the network. A new distributed object is instantiated in the memory of one of the plurality of computers based upon performance statistics maintained by the workload service. 
     The invention has several important technical advantages. By using a workload service to determine where new objects are instantiated, the invention allows efficient use of all computer resources in a distributed object system. The disclosed system is highly scalable. Because the invention takes into account the performance of the system in determining where to instantiate new objects, the system makes efficient use of resources to achieve higher throughput. The architecture of the system allows each business object (or application object) to maintain its own statistics, thus allowing the workload service and local agents to operate smoothly without regard to how many application processes are providing the workload service and local agent with statistics. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     For a more complete understanding of the present invention and the advantages thereof, reference is now made to the following descriptions, taken in conjunction with the accompanying drawings, in which: 
     FIG. 1 illustrates an exemplary general purpose computer that may be used to implement the present invention; and 
     FIG. 2 illustrates an exemplary distributed object system constructed in accordance with the invention. 
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
     The preferred embodiment of the present invention and its advantages are best understood by referring to FIGS. 1-2 of the drawings, like numerals being used for like and corresponding parts of the various drawings. 
     FIG. 1 illustrates a general purpose computer  22  that may be used in a distributed object system created in accordance with the invention. The general purpose computer  22  may be used to execute distributed application processes and/or distributed system services in accordance with the invention. General purpose computer  22  may be adapted to execute any of the well-known OS 2 , UNIX, MAC-OS and WINDOWS operating systems or other operating systems. General purpose computer  22  comprises processor  24 , random access memory (RAM)  26 , read only memory (ROM)  28 , mouse  30 , keyboard  32  and input/output devices such as disk drives  34 , printer  36 , display  38  and communications link  40 . The present invention includes programs that may be stored in RAM  26 , ROM  28  or disk drives  34  and may be executed by processor  24 . Communications link  40  connects to a computer network but could be connected to a telephone line, an antenna, a gateway or any other type of communications link. Disk drives  34  may include a variety of types of storage media such as, for example, floppy disk drives, hard disk drives, CD-ROM drives or magnetic tape drives. Although this embodiment employs a plurality of disk drives  34 , a single disk drive  34  could be used without departing from the scope of the invention. FIG. 1 only provides one example of a computer that may be used with the invention. The invention could be used on computers other than general purpose computers, as well as on general purpose computers without conventional operating systems. 
     FIG. 2 illustrates an example of a distributed object load balancing system  41  constructed in accordance with the invention. Distributed object load balancing system  41  comprises two or more computers  42 ,  44  networked together. Each of the computers  42 ,  44  may be similar in structure and operation to general purpose computer  22  illustrated in FIG.  1 . Other types of computers could also be used without departing from the scope of the invention. Mainframe computers and mini-computers as well as personal computers (also known as microcomputers) may be useful for implementing distributed object systems in accordance with the invention. Each of the computers  42 ,  44  may be networked to one another in any way that multiple computers may be connected. 
     Distributed object load balancing system  41  comprises computer  42  with workload service software  46  running on it. Workload service  46  is operable to receive performance statistics for various application processes running in the distributed object system. The term, distributed object system, as used in this application is meant to refer broadly to any system that uses distributed objects. Workload service  46  may then be used to determine which of the plurality of computers  42 ,  44  in the distributed object system should be used to create a new object in the memory of one of the computers  42 ,  44  where the new object comprises a part of the distributed object system. Although workload service  46  could be designed with many different goals in mind, workload service  46  preferably causes objects in a distributed object system to be created in the memory of one of the computers  42 ,  44  in such a way as to balance the workload of each of the computers  42 ,  44 . The invention thus allows a distributed object system constructed in accordance with the invention to adapt to varying traffic patterns in the system and make efficient use of various available resources. 
     The workload service  46  collects detailed statistical information about what different objects are active in different processes, the computer  42 ,  44  on which the objects reside, what methods have been invoked on them, how many times those methods have been invoked, and how much time has been spent in executing the methods. In one embodiment, the amount of time spent for a given method is measured in terms of CPU time but could be measured by other types of time measurements. The present invention allows statistics gathering for the aggregate of all objects of a particular type. For example, a bank attempting to keep track of customer accounts in a distributed object system may have a customer object. Suppose that the bank has only three customers A, B &amp; C. Workload service  46  may maintain the statistics for objects A, B and C, separately, and may also maintain cumulative numbers for all customers. Thus, workload service  46  may maintain the above-described statistics for all customer objects cumulatively as well as other statistics on a cumulative basis. Average statistics for all instances of a given object class might also be maintained by workload service  46 . Thus, when workload service  46  attempts to determine which computer  42 ,  44  should contain a distributed object in its memory, the workload service  46  may take into account not only the present workload of the computers  42 ,  44  in the distributed object system, but may also make the decision based upon a prediction of the resources that will be consumed by the new object due to the average workload that objects of that particular object class have previously imposed on computers  42 ,  44 . Note that more statistics or less statistics could be collected by workload service  46  without departing from the scope of the invention. 
     Because the application processes  50  running on various computers  42 ,  44  may be performing critical tasks, the invention seeks to perform valuable statistics gathering without interfering with the operation of these application processes  50 . Note that an actual application may comprise many application processes  50 . The invention achieves this goal by providing a statistics thread  54  within each application process  50  to be responsible for gathering statistics. Statistics thread  54  may be transparent to an application developer who is developing a distributed object system application process  50 . A distributed object framework may be provided to an application developer such that statistics thread  54  is automatically incorporated into an application process  50  when the application developer chooses to use that framework. Statistics thread  54  avoids interfering with the function of application process  50  by running asynchronously and avoiding interruption of the actual business tasks being conducted by application process  50 . In this example, application process  50  is a multi-threaded application process comprising a statistics thread  54  and a main thread  52 . Main thread  52  and any other application threads may be used to perform whatever task for which application process  50  is designed to perform. Additional threads could be included without departing from the scope of the invention. 
     In this embodiment, an interceptor thread (not explicitly shown) for each application process  50  intercepts messages intended for objects of application process  50 . The interceptor thread is responsible for informing an object to update its performance statistics upon completion of a given operation. Thus, application process  50  instructs its own objects to gather performance statistics regarding themselves. Each object has access to a statistics data structure in memory of the computer  42 ,  44  on which it is running. The statistics data structure for a given application process  50  resides in the memory space for that application process  50 . When an object completes an operation, it updates the statistics data structure with the statistics described above in connection with workload service  46 . Additional statistics could be recorded or some of the above statistics excluded without departing from the scope of the invention. One option for avoiding interference with the operation of application process  50  is to only maintain performance statistics for messages received by application process  50  that originated outside of the application process  50 . 
     Statistics thread  54  may be configured by the developer of application process  50  to periodically wake up, gather the statistics on objects currently residing in the memory of the computer  42 ,  44  on which the application process  50  is executing, and send these statistics to workload service  46  through local agent  48 . Statistics thread  54  may be programmed to send either an empty message or no message at all to local agent  48  if no new statistics have been generated since the last time statistics thread  54  woke up. Such an action may be considered to be part of the process of waking up and forwarding of statistics. Thus, when this application refers to periodically waking up and obtaining performance statistics, that action encompasses obtaining no information during some of the periods. Eventually, the statistics thread will obtain a performance statistic during one of the periodic wake up times. The statistics thread gathers statistics on objects residing in the memory space of the application process  50  with which it is associated. In this embodiment, statistics thread  54  wakes up periodically, accesses the data structure containing the statistical data and sends the statistical information to local agent  48 . Statistics thread  54  then goes to sleep. The time between the periods of statistics gathering by statistics gathering thread  54  may be adjustable either during development of application process  50  or by a system administrator during use of application process  50 . 
     Local agent  48  receives performance statistics from various statistics threads  54  and relays those statistics to workload service  46 . The invention thus avoids interference with application process  50 . In a distributed object network environment, no assumptions can be made about the speed of the network and the availability of various services on the network. In addition, statistics data is eventually reported from many different local agents  48  to a central workload service  46 . Because the workload service  46  may be busy receiving data from several local agents  48 , it may delay the reporting of data from other local agents  48 . Because local agents  48  receive their data from statistics threads  48  resident on the same computer  42 ,  44 , local agent  48  may receive the statistical data immediately from the statistics thread  48 , freeing up the application process  50  to continue performing its function. Local agent  48  may save the statistics data on a persistent storage medium and relay it to workload service  46  when the network is not busy or when workload service  46  is ready to receive the data. In an alternative embodiment, statistics thread  48  could perform the functions of local agent  48  such as forwarding statistics to the workload service. 
     Although the operation of distributed object load balancing system  41  has been described above, it will now be briefly summarized for an example embodiment. Each application process  50  maintains performance statistics regarding its objects resident in memory of the computer  42 ,  44  that is running the application process  50 . Periodically, statistics thread  54  wakes up and relays those statistics to local agent  48 . Local agent  48  relays the performance statistics to workload service  46 . When it is desired to instantiate a new application object, the decision of which application process  50  is to instantiate and contain the new application object is based upon performance statistics maintained by workload service  46 . Any suitable formula or algorithm may be used for this determination. 
     Although the present invention has been described in detail, it should be understood that various changes, substitutions, and alterations can be made hereto without departing from the spirit and scope of the invention as defined by the appended claims.