Hi Guys, was asked a design question for software engineer position. I couldn't get anywhere near the question, can you guys suggest a good solution for this question?
Question:
There are 10 Servers which has 5 parameters such as A,B,C,D,E. Each parameter is timestamped and written to a logfile. As a note all 10 devices write to a single logfile. The format of the log will be device id, time stamp, parameter(A or B or C or D or E)
eg
device 1, 5 june , A=4
device 5 ,6 june , C =3
device 4 ,5 june , A =3
Design a logging mechanism where the user would query your API with device id and parameter he wants (A or B or C or D or E) with increasing timestamp and the single logfile.
I just wrote a function which would traverse the log file with priority queue for increasing timestamp and get the parameter, he screwed me by asking what if the same user queries the same parameter would you go through the logfile again ? I said I can cache it . I ran out of time for this one but neverthless can you guys give me a good design for this ?