Hey Everyone,
Today we’ll be talking about
Questions? Please contact me at [email protected].
Quastor is a free Software Engineering newsletter that sends out deep dives on interesting tech, summaries of technical blog posts, and FAANG interview questions and solutions.
Netflix is an online video streaming service that operates at insane scale. They have more than 220 million active users and account for more of the world's downstream internet traffic than YouTube (in 2018, Netflix accounted for ~15% of the world’s downstream traffic).
These 220 million active users are accessing their Netflix account from multiple devices, so Netflix engineers have to make sure that all the different clients that a user logs in from are synced.
You might start watching Breaking Bad on your iPhone and then switch over to your laptop. After you switch to your laptop, you expect Netflix to continue playback of the show exactly where you left off on your iPhone.
Syncing between all these devices for all of their users requires an immense amount of communication between Netflix’s backend and all the various clients (iOS, Android, smart TV, web browser, Roku, etc.). At peak, it can be about 150,000 events per second.
To handle this, Netflix built RENO, their Rapid Event Notification System.
Ankush Gulati and David Gevorkyan are two senior software engineers at Netflix, and they wrote a great blog post on the design decision behind RENO.
Here’s a Summary
Netflix users will be using their account with different devices.
Netflix engineers have to make sure that things like viewing activity, membership plan, movie recommendations, profile changes, etc. are synced between all these devices.
The company uses a microservices architecture for their backend, and built the RENO service to handle this task.
There were several key design decisions behind RENO
Here’s a diagram of RENO.
We’ll go through all the components below.
At the top, you have Event Triggers.
These are from the various backend services that handle things like movie recommendations, profile changes, watch activity, etc.
Whenever there are any changes, an event is created. These events go to the Event Management Engine.
The Event Management Engine serves as a layer of indirection so that RENO has a single source of events.
From there, the events get passed down to Amazon SQS queues. These queues are sharded based on event priority.
AWS Instance Clusters will subscribe to the various queues and then process the events off those queues. They will generate actionable notifications for all the devices.
These notifications then get sent to Netflix’s outbound messaging system. This system handles delivery to all the various devices.
The notifications will also get sent to a Cassandra database. When devices need to pull for notifications, they can do so using the Cassandra database (remember it’s a Hybrid Communications Model of push and pull).
The RENO system has served Netflix well as they’ve scaled. It is horizontally scalable due to the decision of sharding by event priority and adding more machines to the processing cluster layer.
For more details, you can read the full blog post here.
Quastor is a free Software Engineering newsletter that sends out deep dives on interesting tech, summaries of technical blog posts, and FAANG interview questions and solutions.
You are given the head of a linked list.
You are also given an integer n.
Remove the nth node from the end of the linked list and return it’s head.
Example
Input: head = [1, 2, 3, 4, 5], n = 2
Output: [1, 2, 3, 5]
As a refresher, here’s the previous question
Write a function that checks whether an integer is a palindrome.
For example, 191 is a palindrome, as well as 111.
123 is not a palindrome.
Do not convert the integer into a string.
Solution
We’ll first create a function that gets the ith digit of an integer given an integer and i.
The function does this by dividing the integer by the next smallest power of ten.
This removes all the digits to the right of i.
Then, we can remove the digits to the left of i by taking the number % 10.
In our main function, we’ll have two pointers i and j that iterate through all the digits in our number.
They will use the getIthDigit function to get the specific digit and will return False if there are any mismatching digits.
After iterating through the entire number, we can return True.
What’s the time and space complexity of our answer?
Reply with your estimates and we’ll tell if you if you’re right.
Quastor is a free Software Engineering newsletter that sends out deep dives on interesting tech, summaries of technical blog posts, and FAANG interview questions and solutions.