I have to develop a program that will connect to three different servers that will be streaming data at certain intervals. I then need to put all that data together and broadcast it out via UDP.
I don't need syntax, I am looking for ideas on how to design this. Please be descriptive. (ie. Number of threads to use and what each is used for)
Thanks in advance!What is a good design to develop a program that can read data from 3 different servers then broadcast via udp?
I think the key here is how to share the memory space between the three pullers and the one broadcaster. The easiest answer to that is with a database. Depending on your data volume needs, you could go with almost anything - Berkley, the free version of DB2, ...
Here's my rough design - I'd need to know your language to go any further.
DB Design
Table Feed: feed id, feed timestamp, feed contents,
Table Broadcast: broadcast id (autonumber), broadcast contents, broadcast start timestamp
Thread 1: Scheduler daemon
Priority: Highest
Responsibilities: Spawn new Feed threads and Broadcast threads at appropriate intervals.
Thread 2: Publisher
Priority: Normal
Responsibilities:
-Query Broadcast table for last start timestamp
-Query Feed table for feed contents since last broadcast
-Assemble broadcast
-Update Broadcast table
-Send UDP
Thread 3...n: Feeder
Priority: Normal
Responsibilities:
-Connect to server
-Rip streaming data
-Commit to Feed table
So my Feeder and Publisher threads are single-use - they exist for one operation. The scheduler makes a fresh one every interval. This way, if a Feed interval comes up before the last one is done, or likewise a Publish, Scheduler can either start a new one to handle it or not, depending on your needs.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment