Interview Question
Software Engineer / DevelopersCountry: United States
Interview Type: In-Person
can have two approach to display recently added images:-
1) use Cache for lets say top 10 pics using LRU type.
2) maintain the pic storage table :- image_id , user_id , uploaded_time.
hit above table for top 10 recently pic.
i would prefer 1st approach as we are not gonna hit table each time.
also we need to take care of availability for data , faluire etc.
I think the requirement here is that since fb has a lot of photos data, so we can build an app to just see the photos without the need to see the timeline. So I am thinking, we can get the photos by calling the fb api that they expose to get all the albums etc. Now what should we do if we want to support offline viewing? Lets say user is on mobile and currently in bad network or no network zone. How will the application perform? Kind of think of on similar grounds as google photos. I think when there is no network google photos show some very low resolution thumbnails so there is availability. What i dont know is how does this work? where is all this stored? What is the db schema? Is it user's mobile where all this data is stored?
there are certain consideration:-
- vinod August 18, 20171)i am assuming that recent images means anyone in your friend list added their pictures should be displayed(recently one should be on top).
2)we can have a Cache design , lets say top 5 recently uploaded pics.
3) definitely we would have pics storage table :- image_id , user_id , uploaded_time.
now we have two ways :-
1) use Cache (we maintain an LRU for top n image).
2) use API hitting pics storage table and display.
i would prefer first approach as in second one we have to hit table every time .