• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Design Question

 
Edmund Yong
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sometime ago I went to a job interview, and the interviewer drew on a white board a box representing a module.

The module will take in an input X, which is a queue (could be a message queue or anything) with many messages coming in. The module must be able to handle the high throughput, which could be 100 messages per second or 1000 messages per second.

The module has another input Y, which is an XML file containing business rules. This input can be read only once, when the module initializes.

Based on the business rules read from Y, the module will apply the rules on the message from X, then put the message into either output A or B.

I was asked to design such a module on the spot. My question is: what kind of answer am I supposed to give? Was the interviewer expecting some class diagrams or sequence diagrams? Or was he expecting some architecture drawings?

And how is this going to address the high throughput problem?

Note that the interviewer said that this has nothing to do with J2EE.
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use thread-pool to handle messages should be OK, I think.

Don't sure about message queue, it doesn't sound to me that this module requires to process messages in order.
 
Edmund Yong
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did mentioned about using multiple threads to handle the high throughput. However, I wasn't able to tell exactly how many threads would be required.

The feedback that I got was that it seemed that my answer was not satisfactory.
 
Scott Soo
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Edmund Yong:
I did mentioned about using multiple threads to handle the high throughput. However, I wasn't able to tell exactly how many threads would be required.

The feedback that I got was that it seemed that my answer was not satisfactory.


Hi,

Will the interviewers be expecting you to ask questions an Architect will ask if the interview is for the role of an Architect? Questions like size of each message? Are all messages well categorized? etc. so that an Architectural Diagram (can be block diagrams since the interviewers do not expect UML) can be derived? Some Interviewers may wish to know your thought process similar to the design notes you have to justify for the SCEA Part II Assignments.

Just my thoughts.

Thank you.

Cheers!!
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Edmund Yong:
I did mentioned about using multiple threads to handle the high throughput. However, I wasn't able to tell exactly how many threads would be required.

The feedback that I got was that it seemed that my answer was not satisfactory.


You should specify how many threads, no need to be exact.

The interviewer might not sure if you really understand, if you just said multiple threads. Using 1,000 threads for 1,000 messages is not good solution.
[ December 22, 2008: Message edited by: Kengkaj Sathianpantarit ]
 
Chaminda Amarasinghe
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Very Interesting post,

If I faced to this interview, My answer would be a MDB. Achieving high through put will be handle by the Application Server's thread pooling. For a better performance Messages should be well categorized in order to filter by filters of MDB

Kengkaj Sathianpantarit has suggested thread pooling. It sounds like a manually handled thread pool. Based on that I have following questions

Is Handling threads manually a good practice (if we have an AS)?

Also he has suggested 1000 threads for 1000 messages is not a good solution. If so how many threads for 1000 messages?

For next question lets assume you suggest 100 threads 1000 messages. That means at a time there is a possibility to miss 900 messages which has not been handled by a thread.
How we handle those messages?
Should use some kind of buffer?

Plss add your comments

Thanks indeed.
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Chaminda Amarasinghe:

For next question lets assume you suggest 100 threads 1000 messages. That means at a time there is a possibility to miss 900 messages which has not been handled by a thread.

It depends on how much processing time for each message.
Maybe only 5-10 threads are enough if almost messages don't require much time to process, once complete, a thread will be returned to pool available for other message.

Caching would also help to achieve high throughput.
We can cache full or partial results, so no need to re-compute the same thing many times.
 
Chaminda Amarasinghe
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Kengkaj
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic