views:

54

answers:

1

[Queston asked in ML Interview]

Design an server/application which handle multiple incoming stock information ( stock symbol and values ) Server need to store the information in some cache ( need to design the data structure ), There are multiple client connected to server using tcp/ip socket. They will subscribe to particular request say stock symbol XYZ , and may be for more then one. As and when there is change the stock symbol server should broadcast the information to subscribed client. If tcp/ip write failed, server should handle the unregistration of the client.

What various data structures will be used and how threading model will be ?

A: 

Sounds to me like a n-tier messaging kind of scenario have a look at this pubsub,

anijhaw
will this model scale like more than 10000 of requests 1 second
Avinash
write it and see.
KevinDTimm
@Avinash it is used in major stock exchanges and major trading systems, It is the basis for most of the message brokers including JMS, Apache Active MQ, and I dont know for sure but twitter seems to be based on a similar paradigmbut yes write it and see :)
anijhaw
anijhaw, the link you have given says literally this `scalability for pub/sub products under high load in large deployments is very much a research challenge`. So it is not quite obvious how good this approach scales.
skwllsp
@Skwllsp, if you scroll down the page you would see the part where it says Middleware implementing pub/sub, almost all of the industry standard message broker systems implement this protocol but yes it isnt simple :)
anijhaw