Linkedin Interview Question for Site Reliability Engineers
- -1of 1 vote
AnswerProgram to count all Response codes individually per database ( slideshare_backedn_fe01 is one db) in the given log file'
- swathi1243 March 09, 2014 in United States
output should like this
{
backend : backend name
{
200: 20
503: 3 where 3 is count of response codes 503
}
}
once again logfile looks like this
May 29 13:53:13 127.0.0.1 haproxy[27326]: 164.85.131.129:15592 [29/May/2013:13:53:13.671] slideshare slideshare_backend/fe01 1/0/1/106/296 200 451 - - --VN 1526/1526/837/402/0 0/0 {www.slideshare.net|Mozilla/5.0 (Windows NT 5.1; rv:10.0.4) Gecko/20100101 Firefox/10.0.4|http://www.slideshare.net/slideshow/embed_code/11959978?hostedIn=slideshare&referer=http://www.slideshare.net/goulart.sousa|} {2471317690|||pingback/embed_or_homepageplayerhits|s11959978/a8717995|} "GET /pingback/embed_or_homepageplayerhits/11959978?ref=http%3A%2F%2Fwww.slideshare.net
%2Fgoulart.sousa&_=1369853592559 HTTP/1.1"
May 29 13:53:13 127.0.0.1 haproxy[27326]: 217.129.26.81:50910 [29/May/2013:13:53:13.724] slideshare slideshare_backend/fe02 17/0/0/1/246 200 3291 - - --VN 1529/1529/839/435/0 0/0 {www.slideshare.net|Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; Trident/5.0)|http://www.slideshare.net/inexita/4|} {1098476889 1090975733|||||} "GET /images/fadedlogo.jpg?829e162373dc3b1cc145ba5b62aba32c8c804b67 HTTP/1.1"
May 29 13:53:13 127.0.0.1 haproxy[27326]: 79.154.237.97:50310 [29/May/2013:13:53:13.758] slideshare autosuggest_backend/solrsearch10_01 13/0/0/3/212 200 526 - - ---- 1528/1528/17/3/0 0/0 {autosuggest.slideshare.net|Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36|http://www.slideshare.net/faroviejo/las-10-ciudades-ms-grandes-del-mundo-y-la-paz-bcs|} {|||||} "GET /?q=las?10?ciudades?ma*&rows=5&wt=json&sort=frequency%20desc&fq=%2Bresults%3A%5B10%20TO%20*%5D&json.wrf=jQuery17209988682114053518_1369853526684&_=1369853590254 HTTP/1.1"| Report Duplicate | Flag | PURGE
Linkedin Site Reliability Engineer Algorithm
Ahha!
- code_monkey April 06, 2014This is a good question.
And what you asked above is just a cherry of an entire dessert.
for what you asked, is simple enough to split the strings using strtok or tokenizer and add stuff into a hashmap.
Now these are the follow up questions I thought of asking you
What if I need only what the K largest statuses are?
How would you implement them if there are some millions of machines?
How would you implement the same if there are millions of processors on a single machine(virtual machines with same address space)
:)
this question is way more interesting that you think, and is hugely open ended, and I can go very deep asking this to a person :)