Timeout Management using Hashed Timing Wheels | Gautam's personal blog
Here is an effort to implement a simple Timeout Management framework based on the concept of Hashed Timing Wheel design. The details of this design was published in a paper by George Varghese and Tony Lauck, 'Hashed and Hierarchical Timing Wheels: data structures to efficiently implement a timer facility'. More comprehensive slides are located here.
JBoss HashWheelTimer was designed based on this concept.
Idea here is to design a Timeout Manager that uses minimum system resources (clock cycles) and works in a highly multi-threaded environment.
Lets assume we have a JTA based transaction manager. Lets pick a simple design where we store all the transactions in a HashMap as values against the Keys as Threads. Lets a Thread 1 starts a transaction TX1, Transaction Manager inserts an entry into the HashMap.
txMap.put(Thread1, TX1);
As time progresses there would be multiple entries of threads and their associated transactions.
Why we store Transactions against Threads?
When the threads accesses a transactional entity (supports or required Transaction) thread can look up the txMap and see if already a transaction is associated with the Thread. If thread finds a transaction, it associates the entity with the transaction if not it starts a new transaction and pushes a new entry into the txMap.
Read full article from Timeout Management using Hashed Timing Wheels | Gautam's personal blog
No comments:
Post a Comment