转发: Gusto 全职换工作电面

地里没怎么看到Gusto的面经,分享一个最近电面的题,楼主三年多工作经验,网投之后recruiter聊完后就安排了一个小时的电面,coderpad做题,最后需要能跑通。

给了一个backend service的log file,

2014-01-09T06:16:53.748849+00:00 heroku[router]: at=info method=POST path=/api/online/platforms/facebook_canvas/users/100002266342173/add_ticket host=mygame.heroku.com fwd=“94.66.255.106” dyno=web.12 connect=12ms service=21ms status=200 bytes=782014-01-09T06:16:53.742892+00:00 heroku[router]: at=info method=GET path=/api/users/100002266342173/count_pending_messages host=mygame.heroku.com fwd=“94.66.255.106” dyno=web.8 connect=9ms service=9ms status=304 bytes=02014-01-09T06:16:53.766841+00:00 heroku[router]: at=info method=POST path=/logs/save_personal_data host=mygame.heroku.com fwd=“5.13.87.91” dyno=web.10 connect=1ms service=42ms status=200 bytes=162014-01-09T06:16:53.772938+00:00 heroku[router]: at=info method=POST path=/api/users/100002844291023 host=mygame.heroku.com fwd=“46.195.178.244” dyno=web.6 connect=2ms service=43ms status=200 bytes=522014-01-09T06:16:53.765430+00:00 heroku[router]: at=info method=GET path=/api/users/100005936523817/get_friends_progress host=mygame.heroku.com fwd=“5.13.87.91” dyno=web.11 connect=1ms service=47ms status=200 bytes=74982014-01-09T06:16:53.760472+00:00 heroku[router]: at=info method=POST path=/api/users/1770684197 host=mygame.heroku.com fwd=“74.139.217.81” dyno=web.5 connect=1ms service=17ms status=200 bytes=6812014-01-09T06:15:15.893505+00:00 heroku[router]: at=info method=GET path=/api/users/1686318645/get_friends_progress host=mygame.heroku.com fwd=“1.125.42.139” dyno=web.3 connect=8ms service=90ms status=200 bytes=75342014-01-09T06:16:53.768188+00:00 heroku[router]: at=info method=GET path=/api/users/100005936523817/get_friends_score host=mygame.heroku.com fwd=“5.13.87.91” dyno=web.13 connect=2ms service=46ms status=200 bytes=9355…
log file 里面有一些不同的endpoints,比如/api/users/{userid}/count_pending_messages, /api/users/{userid}/get_friends_progress, 让你统计每个endpoint被call的次数,平均的connect time,和每个endpoint的max dyno(dyno指的是API 被call的server, max dyno是说哪个server被call过最多次)

1 Like

请问一下面试中,log file是每行以日期,如“2014-01-09T06”,起头,可以一行一行读,将path后面the endpoint放入dictionary里面。不需要regex吧?谢谢!

请问不同user id也算同一个endpoint吗?我可以把“/api/users/{userid}/count_pending_messages”当成一个key吗?
请问这两个算是endpoint吗?
path=/logs/save_personal_data
path=/api/users/100002844291023

不同的id但是其他是一样的也算同一个endpoint,比如/api/users/123/count_pending_messages和/api/users/456/count_pending_messages 属于同一个

需要把id换成{userid}

请问下楼主,input的格式是什么呢?
多谢了

不知道为什么复制到格式都乱了,格式就是跟平常的web service上的access log是差不多的。每一行都有一些常见的信息比如endpoint,latency等等

比方说这里有两行我重新format一下,每一行里面的信息是空格分开
2014-01-09T06:16:53.748849+00:00 heroku[router]: at=info method=POST path=/api/online/platforms/facebook_canvas/users/100002266342173/add_ticket host=mygame.heroku.com fwd=“94.66.255.106” dyno=web.12 connect=12ms service=21ms status=200 bytes=78

2014-01-09T06:16:53.742892+00:00 heroku[router]: at=info method=GET path=/api/users/100002266342173/count_pending_messages host=mygame.heroku.com fwd=“94.66.255.106” dyno=web.8 connect=9ms service=9ms status=304 bytes=0

是不是说每一行都代表一个log,然后input是一个大的string?

多谢了

面试官当时跟我说,为了方便可以把每一行都当成一个string,以一个String 作为input