Categories
Software Architect

How Netflix implemented Microservices architecture

As google explains Microservices architecture (often shortened to microservices) refers to an architectural style for developing applications. This architecture pattern allows a large application to be separated into smaller independent parts, with each part having its own realm of responsibility. Unlike the monolithic style, this approach to software development allows for better scalability To serve a single user request, application can call on many internal microservices to compose its response.

Check out the Microservices Architecture at Netflix!

Microservices architecture at Netflix
  1. Client sends a Play request to Backend running on AWS. The request is handled by AWS Load balancer (ELB)
  2. AWS ELB will forward that request to API Gateway Service running on AWS EC2 instances. That component, named Zuul, is built by the Netflix team to allow dynamic routing, traffic monitoring & security, etc
  3. Application API component is the core business logic, in this scenario, the forwarded request from API Gateway Service is handled by Play API.
  4. Play API will call a (sequence of) microservice(s) to fulfill the request.
  5. Microservices are mostly stateless small programs, to control its cascading failure & enable resilience, each microservice is isolated from the caller processes by Hystrix.
  6. Microservices can save to or get data from a data store during its process.
  7. Microservices can send events for tracking user activities or other data to the Stream Processing Pipeline for either real-time processing or personalized recommendations.
  8. The data coming out of the Stream Processing Pipeline can be persistent to other data stores such as AWS S3, Hadoop HDFS, Cassandra, etc.
'Coz sharing is caring
Categories
Algorithm

Sort hotel list challenge

Problem statement
Given a set of hotels and its guests reviews, sort the hotels based on a list of words specified by a user. The criteria to sort the hotels should be how many times the words specified by the user is mentioned in the hotel reviews.

Input

  1. The first line contains a space-separated set of words which we want to find mentions in the hotel reviews.
  2. The second line contains one integer M, which is the number of reviews.
  3. This is followed by M + M lines, which alternates an hotel ID and a review belonging to that hotel.

Output
A list of hotel IDs sorted, in descending order, by how many mentions they have of the words specified in the input. If the count is same, sort according to the hotel IDs.

Notes

  • The words to be find will always be singe words line ‘breakfast’ or ‘noise’. Never double words like ‘swimming pool’.
  • Hotel ud is a 4-byte integer.
  • Words match should be case-insensitive.
  • Dots and commas should be ignored.
  • If a word appears in a review twice, it should count twice.
  • If two hotels have the same number of mentions, they should be sorted in the output based on their ID, smallest ID first.
  • In case one or more test cases time out, consider revisiting the runtime complexity of your algorithms.

Sample input

breakfast beach citycenter location metro view staff price
5
1
This hotel has a nice view of the citycenter. The location is perfect.
2
The breakfast is ok. Regarding the location, it is quite far from citycenter but price is cheap so it is worth.
1
Location is excellent, 5 minutes from citycenter. There is also a metro station very close to the hotel.
1
They said I could't take my dog and there were other guests with dogs! That is not fair!
2
Very friendly staff and goof cost-benefit ratio. Its location is a bit far from citycenter.

Sample Output

2 1

Explanation
Hotel 2 has 7 mentions of the words: ‘location’ and ‘citycenter’ are mentioned twice while ‘breakfast’, ‘price’ and ‘staff’ are mentioned once. Hotel 1 in the other hand has 6 mentions in total ‘location’ and ‘citycenter’ also twice and then ‘view’ and ‘metro’ once.

'Coz sharing is caring