Tumblr interview question

code in the language of your choice: A site has 4,320,000 users. The users are sequentially numbered -- each user has a user_id between 1 and 4320000. You want to slowly roll out a new feature to all users, at a consistent rate of X users per second. The roll-out should start at noon today, beginning with the newest user (id 4320000). The rollout should last two days, so user_id 1 gets the feature around noon two days from now. $Write a function to determine whether the feature is currently enabled for a given user_id: can_use_new_feature(int user_id) -> bool.

Interview Answers

Anonymous

28 Nov 2016

Total seconds in 2 days = 172800 Divide total users 4320000/172800(seconds) = 25 users processed every second global start_time = unix_timestamp(start date noon) global users_per_second = 25 global total_users = 4320000 function can_use_new_feature(user_id) { var current_timestamp = unix_timestamp(current_time) var elapsed_seconds = timestamp_diff_to_seconds(current_timestamp, start_time) var processed_users = total_users - (users_per_second * elapsed_seconds) return (bool) user_id >=processed_users }

Anonymous

30 Jan 2021

There's a lot of elements to typically cover in these questions, clarifications, scoping, making sure you're answering the actual question the interviewer is looking for you to answer, etc. Could be worth doing a mock interview with one of the Prepfully Tumblr Director of Site Reliability Engineering experts... they've worked in the role so they clearly know how to get through the interview. prepfully.com/practice-interviews