Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to design buffer based application

 
William Ni
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am involved in optimizing a high-traffic application and I need your help on the buffer design.
The application has a few components. please refer to the graph below:

             B
A -----> B ------> C
             B

The 3 running threads of B connect to an external Database to do some validation and due to some limitations, we can only acquire 3 connections to the database. Meanwhile, we can only have a single instance of C. The processing speed of the 3 components is: A > 3*B > C
Therefore, during some peak hours, A will generate a large number of traffic such that B couldn't handle in time, and when B passes the task to C, C couldn't handle it in time either. Clearly, we need a task buffer between each component so that they can continue processing the tasks during off-peak hours.
I am seeking your advice on how to design a robust and efficient buffer. Memory-based buffer may not work because the traffic is high and in case of system failure, everything stored in memory is not recoverable. What I am trying now is to use a local database as buffer, but it looks to me not an ideal approach either.
I am sorry that I post this question here as it's not SCEA related at all. However, I believe you guys are the people who can help. Any ideas will be appreciated. Thanks.

[ April 12, 2005: Message edited by: William Ni ]

[ April 12, 2005: Message edited by: William Ni ]
[ April 12, 2005: Message edited by: William Ni ]
 
Lucy Hummel
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by William Ni:
I am involved in optimizing a high-traffic application and I need your help on the buffer design.
The application has a few components. please refer to the graph below:

             B
A -----> B ------> C
             B

The 3 running threads of B connect to an external Database to do some validation and due to some limitations, we can only acquire 3 connections to the database. Meanwhile, we can only have a single instance of C. The processing speed of the 3 components is: A > 3*B > C
Therefore, during some peak hours, A will generate a large number of traffic such that B couldn't handle in time, and when B passes the task to C, C couldn't handle it in time either. Clearly, we need a task buffer between each component so that they can continue processing the tasks during off-peak hours.
I am seeking your advice on how to design a robust and efficient buffer. Memory-based buffer may not work because the traffic is high and in case of system failure, everything stored in memory is not recoverable. What I am trying now is to use a local database as buffer, but it looks to me not an ideal approach either.
I am sorry that I post this question here as it's not SCEA related at all. However, I believe you guys are the people who can help. Any ideas will be appreciated. Thanks.



[ April 12, 2005: Message edited by: William Ni ]


Hi William,

Your idea to use a database is not that bad since database guarantees persistence. So your tasks are stored in case of system failure. Furthermore, the system might have already a database in use, so you do not have to buy the software.

Another approach in case of J2EE 2.0 is to use JMS. Just use a queue and define the queue as persistence. But you have to buy the JMS, like Websphere MQ, you have to set up the software, the software will decrease your system response time additionally.

Looking forward to other opinions

Lucy
 
Bhanu
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes!! Persistent Queue is an ideal solution if you take a trade off between time to develop/reliability and other options.

But still you have to throw some light on how to enhance the current system.
 
sairam sam
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William,
I can think of three solutions for your problem in high level, based on what you described.
Multiple request (A) coming in and only 1-3 or 1-n (B) thread to process the request and do validation to external DB (3-connection max) and then pass it to C (singleton) for further processing

1.MOM (message oriented middleware) like IBM MQ (cost involved in setting up)
If data is critical, data recovery, processing time should be less and robustness of app. You need to have 2 Q�s for doing your task�
2.Database: - mechanism is similar to above, but involves in db connection and purging of the processed data�defining the fields or having one field to hold the request data�there is some limitation on it�like 2 Q�s you need to table�
3.In memory and file storage (for data recovery purpose). I used this methodology to my current project (and other 2 in my previous projects).
I used Stack as in memory storage�with max of 15 msg�s and rest is written in file with time stamp to process in order�even stack msg is stored in file in different folder�for data recovery in case of system crash�Handling of this data is done when the system restarts�
Like B in your system�I have a thread job which process the stack msg first, then data from file�each msg is independent of other in my case�. thread (B) only does its job if there is msg in stack or file to be processed else it sleeps.
After every successful processing B moves the data to processed folder
I don�t have C processing object�but you can replicate the in-memory for C or just put every thing in file and let C do its job from file (time consuming then in memory)



If MQ is available then go for it�and the other 2 depends on the system requirement �if the data is going to be consistent or not going to change very often the DB is good�(response will be slow then in memory processing) but persistence wise its good then in-memory and file storage�.

Comments welcome�.

Sai,
SCJP 1.4
SCWCD 1.4
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic