A portion of the disclosure of this patent document contains material which is subject to copyright protection. The copyright owner has no objection to the facsimile reproduction by anyone of the patent document of the patent disclosure, as it appears in the Patent and Trademark Office patent file or records, but otherwise reserves all copyright rights whatsoever.
The following applications are cross-referenced and incorporated herein by reference:
U.S. Provisional Application No. 60/305,986 entitled “DATA REPLICATION PROTOCOL,” by Dean Bernard Jacobs, Reto Kramer, and Ananthan Bala Srinvasan, filed Jul. 16, 2001.
U.S. Provisional Application No. 60/316,187 entitled “CLUSTER CACHING WITH CONCURRENCY CHECKING,” by Dean Bernard Jacobs and Rob Woollen, filed Aug. 30, 2001.
The invention relates generally to a system and method for storing data on a network.
When a data item is stored in a single database or data store that is accessible over a network, it is often the case that multiple servers or clients will require access to that data item. Traditionally, this requires a hit to the database each time the data item is accessed. Each hit to a database is relatively resource intensive and relatively inefficient.
One way of overcoming some of the efficiency and scalability problems is to store a local copy of the data item in cache memory. A server or client can then use that local copy if future access to the data item is needed. This process may be appropriate and efficient for data items that never change, but problems can arise when a data item is updated in the database.
If a data item in the database is updated, a copy of that data item stored in a local cache on the network will be different than the item in the database, as the cache will not automatically receive the update. The problem intensifies when there are local copies on multiple servers and/or clients on the network. Since each of these local copies is created at a different time, there can be multiple versions of the data item on the network. If a user tries to update or view the data item, the copy accessed by the user may not be current and correct.
Such a problem with data latency can cause serious problems for applications that require near real-time accuracy, such as web sites that offer “real time” stock prices. Such an application might utilize a database table having at least two columns, one column containing stock symbols, which can be used as primary keys for the table, and one column containing the current price of each stock. In such an application, most of the activity involves users accessing the site and reading the current stock values. There is typically also activity involving back-end applications or systems that come in periodically, such as once every minute, with updated stock prices. These back-end systems need read/write access to the database in order to update the data.
Most access to the system will be read only. For these read-only users, the system can cache data to provide faster access. The system can update the cached information periodically, such as every fifteen minutes. In such a “read-mostly” situation, however, it may be preferable to give a user the most recent data. A fifteen minute delay in providing accurate information may be undesirable for many applications. It is typically desirable to give users information that is as accurate as possible.
One way to ensure that users get accurate information, or at least information that is current with data stored in the database, is to pull the information from the database for each request instead of reading a cached copy. This can be very expensive for many applications, as a hit to a database is much more time and resource intensive than reading a value from memory.
For people updating the data in the database, it may be desirable to wrap as many updates as possible into a batch transaction in order to improve performance. Wrapping updates into a single transaction also ensures that either all the updates occur or none of the updates occur. Problems arise, however, in how to update cached copies for each item updated in a transaction.
A system and method are included for updating a copy of a data item stored in local cache on at least one server in a network cluster. Identification information is provided to a read/write bean stored on a server in the cluster. The identification information relates to any server in the cluster that contains a read-only bean and a copy of the data item in local cache. A read-only bean provides read access to the local copy of the data item. The original data item is stored in a network database, and is updated using the read/write bean. When the data item is updated by the read/write bean, an invalidate request can be sent or multicast from the server containing the read/write bean to the entire cluster, or can be sent to any server or read-only bean identified by the identification information having a local copy of the data item. Any local copy of the data item can then be dropped in response to the request. A current copy of the data item can be read from the database and stored in local cache.
In order to maintain consistency among items distributed on a network, a system in accordance with the present invention can take advantage of beans, or JavaBeans. A bean is basically a framework for components that can be added to a server to extend functionality. One embodiment utilizes two types of beans, “read-only” entity beans and “read/write” entity beans. An entity bean is a bean that is persistent, allows shared access, has primary keys, and can participate in relationships with other entity beans. Each entity bean can have an underlying table in a relational database, with each instance of the bean corresponding to a row in that table.
A read-only bean is a bean that can be cached on a server, such as an enterprise JavaBean that resides in a network cluster. The read-only bean can provide read access to any server in the cluster, as well as to any client inside or outside of the cluster. The read/write bean is transactional, residing on a server in the cluster and providing cluster servers with read/write access to a network database. The read-only bean deals with data in local cache on a cluster server. The read/write bean deals with information in a database.
One way to address the concurrency of information in the cache and in the database is to associate a timeout value with each read-only entity bean. For example, a read-only bean can be deployed with a default cycle of ten minutes. After each period of ten minutes passes, the read-only bean goes back to the database and reads the current value. This approach can work well for certain applications, such as those applications with values that change at a regular interval.
There may be applications, however, which have data that changes very infrequently. When this data changes, users may want to know about the change as soon as possible. Since the data does not change very often, it is tempting to set a long read cycle time in order to conserve resources. This can have the undesirable effect, however, of creating latency issues with the data, as the resultant delay in updating the data can be almost as long as the cycle time, depending on the point in the cycle at which the update occurs. For such applications, it is desirable that the data accessible by a read-only user is updated as soon as possible after the data is the database is updated.
One system in accordance with the present invention provides an interface, exposed by a read-only bean. The interface allows a user or application to tell the system to drop a cache, or “invalidate” a cache, when the user updates a data item or is aware of an update. This interface shall be referred to as a “CachingHome,” as an entity bean typically has a “home” or factory that creates it. CachingHome can have three methods on it, and be coded as follows:
The method invalidate (Object pk) lets a user invalidate data associated with a particular primary key in a database or data table. The method invalidate (Collection pks) lets a user invalidate data for a collection or group of keys. The method invalidateAll ( ) allows a user to invalidate data for all keys in the database table. These invalidate methods allow a user to ensure that values are stored in local cache until a programmer, application, user, or system says otherwise.
One such method 300 is shown in the flowchart of
In a system 100 with a network cluster 104, such as is shown in
One embodiment allows server 110 to drop a copy 116 in local cache when it receives an invalidate request 124 from the client 102, as shown in
Another problem exists due to the fact that a multicast message is only sent once by the source and does not wait for confirmation of receipt by the other servers. A server in the cluster might not get an invalidate request, such as if it is temporarily offline. A system in accordance with the present invention can provide a more reliable multicast by tagging each such message or request with a version number or sequential number. In this way, a server receiving a request will know the version of the request, as well as the version of the last request it received, such that the server will know if it missed a message. Once a server determines that it has missed a message, it can request that the message be sent again so that it can update accordingly.
One problem with this approach, however, is that a serverwill not know it has missed an update until another update is sent. In certain applications such as an on-line store posting weekly specials for weeks 1, 2, and 3, it may be unacceptable to wait until the next update to get correct information. The store would not realize that it had missed the specials for week 2 until the update for week 3. The week 1 specials would have remained up during week 2, displaying the wrong information to any user accessing the system during that time. When the system realizes that it missed the week 2 update, it will already be week 3. The serverwill end up simply discarding the week 2 information without the information ever having been displayed to a user.
A system in accordance with the present invention can get around this problem by periodically “heartbeating” information to the servers in the cluster. A server heartbeats a packet of information or a message by sending the message periodically over the network or cluster. A heartbeat message can contain information such as the latest version number, previous version numbers, or the actual update information itself if the update information is small enough to be practical. If a server receives a heartbeat message containing the latest version number, and the server is not on that version of the data or did not receive the latest invalidate request, the server can request or pull the invalidate message from the server.
The initiating server that initially sent the invalidate request, which may also be the server sending the multicast and/or heartbeats, can store recent requests for a certain amount of time or can store a certain number of recent requests. If a cluster server requests an invalidate message that the initiating server is still storing, the initiating server can simply send the message to the cluster server, by a method such as a multicast or a point-to-point connection. If the initiating server no longer has the message, the initiating server can tell the cluster server to simply drop its entire cache, since it is not possible to tell the cluster server which keys have changed. The cluster server can read new and/or current information from the database. This can temporarily lessen performance, but the newly-cached information will at least be current with the information in the database.
In operation, a client or application can update a data item through a read/write entity bean. The update, or a transaction containing multiple updates, will commit to the database. An invalidate message can be sent to the servers in the cluster, with the message being triggered for example by the client or server updating the data item. The cluster servers can each drop any copy in local cache and can read in the new value from the database, either right away, later, or when necessary to serve a request. Normally it is not possible to read uncommitted data, so it may be preferable to use a two-step process where the data is committed first and then a message is multicast to the cluster.
One problem with the above approach is that it forces a client to initiate an invalidate request, which can involve a little more complexity for the client. There is also the possibility that the client could use the invalidate method incorrectly or make a mistake. It may therefore be preferable that the system can do it automatically.
A system in accordance with the present invention can address this problem by using an “invalidation target.” An invalidation target is based on the idea that the read-only and read/write beans point to the same data in the database, with the people reading the data using the read-only bean and the people updating the data using the read/write bean. The idea is to invalidate the read-only bean when the read/write bean is updated or modified.
When deploying an entity bean or enterprise JavaBean, there is typically a deployment descriptor used to store meta data about the actual entity bean. A deployment descriptor can be, for example, an XML document used to provide information about the services provided by the bean that should be made available to clients. The information can provide a wide variety of information to the clients, such as request routing information, as well as method and class details for a supporting Java class. A tag can be added to the deployment descriptor, referred to previously as an “invalidation target.” The invalidation target for a read/write bean can contain the identity of any associated read-only bean. The invalidation target can be used to automatically invalidate any associated read-only bean(s) when the read-only bean is updated.
In one embodiment, the invalidation target can be updated when a server requests information from a read/write bean or generates a read-only bean does the request. When the read/write bean forwards information from a database or data store to the requesting server, the read/write bean can also update the invalidation target. An XML file stored on the server containing the read/write bean can be updated to include the identity of the server requesting the information or creating the bean.
A subsequent call to an invalidated read-only bean can cause a method such as ejbLoad to be called, which can read current information from the database into cache. For example, a container-managed persistence (CMP) bean, an entity bean whose state is automatically synchronized with a database, can use an invalidation-target element in an XML file such as ejb-jar.xml to specify a read-only entity bean that should be invalidated when the read/write bean has been modified. The container in this example can automatically invalidate the invalidation-target, such as after the transaction is completed.
Such a method 200 is shown in the flowchart of
In this way, customers or clients do not have to write any additional code to invalidate an item. In accordance with an embodiment of the present invention, only an invalidation target must be specified in order to keep the read/write and read-only beans coherent. The beans can coexist on the same server, with the read-only bean reading items from local cache and the read/write bean reading from, and writing to, the database.
In order to improve performance, a system in accordance with the present invention can instead wait until an entire transaction or series of updates is committed to the database or data table, instead of sending an individual message for each update. A server, such as the server initiating the update, can keep track of which keys were updated during the transaction and multicast a single message that includes information for all updated primary keys. Such batching of messages can improve the overall performance of such a system and can reduce the opportunity for error or inconsistencies.
One example of a system that can be used in accordance with the present invention contains a table of stock symbols, as well as information associated with each symbol, such as price and volume. A Java server page can be used to allow a user to request the current price of a stock. The Java server page can read the information from a read-only entity enterprise Java bean. A Java Message Service (JMS) queue can receive messages with updates to stock prices. An message-driven bean can de-queue these messages and update the associated CMP entity bean. When this modification occurs, the container can invalidate the associated read-only bean.
The foregoing description of preferred embodiments of the present invention has been provided for the purposes of illustration and description. It is not intended to be exhaustive or to limit the invention to the precise forms disclosed. Many modifications and variations will be apparent to one of ordinary skill in the relevant arts. The embodiments were chosen and described in order to best explain the principles of the invention and its practical application, thereby enabling others skilled in the art to understand the invention for various embodiments and with various modifications that are suited to the particular use contemplated. It is intended that the scope of the invention be defined by the following claims and their equivalence.
This application is a Continuation of U.S. patent application Ser. No. 11/105,263, filed on Apr. 13, 2005, entitled “SYSTEM AND METHOD FOR FLUSHING BEAN CACHE,” currently pending, which is a Continuation of U.S. application Ser. No. 10/212,382 filed on Aug. 5, 2002, entitled “SYSTEM AND METHOD FOR FLUSHING BEAN CACHE,” now U.S. Pat. No. 6,918,013, issued Jul. 12, 2005, which claims priority to U.S. Provisional Patent Application No. 60/335,633, filed Oct. 25, 2001, entitled “SYSTEM AND METHOD FOR FLUSHING BEAN CACHE,” and to U.S. Provisional Patent Application No. 60/316,187, filed Aug. 30, 2001, entitled “CLUSTER CACHING WITH CONCURRENCY CHECKING,” all of which are incorporated herein by reference.
Number | Name | Date | Kind |
---|---|---|---|
4714996 | Gladney et al. | Dec 1987 | A |
5163148 | Walls | Nov 1992 | A |
5201010 | Deaton et al. | Apr 1993 | A |
5561797 | Gilles et al. | Oct 1996 | A |
5613060 | Britton et al. | Mar 1997 | A |
5634052 | Morris | May 1997 | A |
5677945 | Mullins et al. | Oct 1997 | A |
5765171 | Gehani et al. | Jun 1998 | A |
5805798 | Kearns et al. | Sep 1998 | A |
5813017 | Morris | Sep 1998 | A |
5832514 | Norin et al. | Nov 1998 | A |
5909689 | Van Ryzin | Jun 1999 | A |
5926816 | Bauer et al. | Jul 1999 | A |
6018805 | Ma et al. | Jan 2000 | A |
6065046 | Feinberg | May 2000 | A |
6122629 | Walker et al. | Sep 2000 | A |
6134673 | Chrabaszcz | Oct 2000 | A |
6173293 | Thekkath et al. | Jan 2001 | B1 |
6256634 | Moshaiov et al. | Jul 2001 | B1 |
6304879 | Sobeski et al. | Oct 2001 | B1 |
6345288 | Reed et al. | Feb 2002 | B1 |
6366930 | Parker et al. | Apr 2002 | B1 |
6374264 | Bohannon et al. | Apr 2002 | B1 |
6389462 | Cohen et al. | May 2002 | B1 |
6401239 | Miron | Jun 2002 | B1 |
6405219 | Saether et al. | Jun 2002 | B2 |
6425005 | Dugan et al. | Jul 2002 | B1 |
6430564 | Judge et al. | Aug 2002 | B1 |
6438705 | Chao et al. | Aug 2002 | B1 |
6453321 | Hill et al. | Sep 2002 | B1 |
6505200 | Ims et al. | Jan 2003 | B1 |
6505241 | Pitts | Jan 2003 | B2 |
6523130 | Hickman et al. | Feb 2003 | B1 |
6526521 | Lim | Feb 2003 | B1 |
6567809 | Santosuosso | May 2003 | B2 |
6578160 | MacHardy et al. | Jun 2003 | B1 |
6609213 | Nguyen et al. | Aug 2003 | B1 |
6651140 | Kumar | Nov 2003 | B1 |
6654766 | Degenaro et al. | Nov 2003 | B1 |
6675261 | Shandony | Jan 2004 | B2 |
6711579 | Balakrishnan | Mar 2004 | B2 |
6721777 | Sharma | Apr 2004 | B1 |
6757708 | Craig et al. | Jun 2004 | B1 |
6775703 | Burns et al. | Aug 2004 | B1 |
6804818 | Codella et al. | Oct 2004 | B1 |
6826601 | Jacobs et al. | Nov 2004 | B2 |
6832238 | Sharma et al. | Dec 2004 | B1 |
6836889 | Chan et al. | Dec 2004 | B1 |
6918013 | Jacobs et al. | Jul 2005 | B2 |
6944785 | Gadir et al. | Sep 2005 | B2 |
6963857 | Johnson | Nov 2005 | B1 |
7000019 | Low et al. | Feb 2006 | B2 |
7028030 | Jacobs et al. | Apr 2006 | B2 |
7065616 | Gajjar et al. | Jun 2006 | B2 |
7085834 | Delany et al. | Aug 2006 | B2 |
7089317 | Jeyaraman et al. | Aug 2006 | B2 |
7089584 | Sharma | Aug 2006 | B1 |
7100195 | Underwood | Aug 2006 | B1 |
7130964 | Ims et al. | Oct 2006 | B2 |
7171692 | DeMello et al. | Jan 2007 | B1 |
7185364 | Knouse et al. | Feb 2007 | B2 |
7188145 | Lowery et al. | Mar 2007 | B2 |
7240101 | Rich et al. | Jul 2007 | B2 |
20020004850 | Sudarshan et al. | Jan 2002 | A1 |
20020073188 | Rawson | Jun 2002 | A1 |
20020147961 | Charters et al. | Oct 2002 | A1 |
20020188591 | Santosuosso | Dec 2002 | A1 |
20030014480 | Pullara et al. | Jan 2003 | A1 |
20030018732 | Jacobs et al. | Jan 2003 | A1 |
20030041135 | Keyes et al. | Feb 2003 | A1 |
20030115366 | Robinson | Jun 2003 | A1 |
20060143239 | Battat et al. | Jun 2006 | A1 |
20060168118 | Godlin et al. | Jul 2006 | A1 |
Number | Date | Country | |
---|---|---|---|
20070192320 A1 | Aug 2007 | US |
Number | Date | Country | |
---|---|---|---|
60335633 | Oct 2001 | US | |
60316187 | Aug 2001 | US |
Number | Date | Country | |
---|---|---|---|
Parent | 11105263 | Apr 2005 | US |
Child | 11697675 | US | |
Parent | 10212382 | Aug 2002 | US |
Child | 11105263 | US |