Software Engg Assignment
Software Engg Assignment
ASSIGNMENT
NAMAN.V (17BCE7003)
Slot:E1/TE1
1. Case Study: "UBER|LYFT|GRAB|OLA System design”. Consider the any one system
design architecture and answer the following questions. (each question answer can be
max. of 500 words).
A. Understand the above system design of the App & explain the scenario?
ans: Uber’s Dispatch system acts like a real-time market platform that matches drivers with riders
using mobile phones.
So we need two services
Supply service
Demand service
Supply service:
• The Supply Service tracks cars using geolocation (lat and lang) Every cab which is active keep
on sending lat-long to the server every 5 sec once
• The state machines of all of the supply also kept in memory
• To track vehicles there are many attributes to model: number of seats, type of vehicle, the
presence of a car seat for children, can a wheelchair be fit, and so on.
• Allocation needs to be tracked. A vehicle, for example, may have three seats but two of those
are occupied.
Demand service:
• The Demand Service tracks the GPS location of the user when requested
• It tracks requirements of the orders like Does a rider require small car/big car or pool etc
• demand requirements must be matched against supply inventory.
Now we have supply and demand. all we need a service which matches they demand to a supply
and that service in UBER is called as DISCO
DISCO — DISPATCH optimization
This service runs on hundreds of processes.
Core requirements of the dispatch system:
reduce extra driving.
reduce waiting time
lowest overall ETA
B. What is the various use cases for the selected APP & explain?
ans: Rider app:
1.Scheduled Booking
2.Real time Navigation
3.App Call / Chat
4.Wallet Payment
5.Promotion Codes
6.Stripe payment
7.User Profile
8.working history
9.Ride Request Notifications
10.Estimation fare Calculation
11.Pay by Cash Option
12.User can Invite Friends
13.Emergency Contact Sharing
14.Book a Ride with Destination
15.Favorites location Option for the Rider
Driver app:
1.Online and offline
2.User Profile
3.App Call / Chat
4.Work History
5.Ride Request Notifications
7.Real time Navigation
8.driver Payout
9.working history
10.Rating and feedback List
C. What is the software design of the LYFT/Grab App & explain?
ans: To provide the good-quality work of the taxi ordering application, not only the mobile app
interface matters, but also the "back-end" part. It is about the server application which receives user
data, processes it, sending to the certain services and apps. This back-end part actually makes the
communication between different elements of the mobile app system possible.
The system faces challenge when it's the high load. To cope with it successfully and show good
speed of work, the architecture should be optimized:
Choose the technologies that will help to cope with the load;
Uber was fined $67,750 after it began offering its services in Portland without
proper regulatory approval. The city and the firm eventually reached an agreement,
but not before each had publicly denounced the other.
New York’s traditional yellow taxi firms aren’t fans of Uber, but last July the firm
was able
to see off a bill backed by mayor Bill de Blasio that would have put a cap on the
number of vehicles it could operate in the city.
UberPOP was suspended in France the same week two of the company’s
executives were arrested for “illicit activity”. The head of Uber France told Le
Monde the suspension was “primarily to assure the safety of Uber drivers”.
Uber is being investigated for criminal negligence in India after one of its drivers
raped a passenger. The firm has introduced an SOS feature that can put riders
directly in contact with the police.
The Chinese Ministry of Transportation has proposed new guidelines that would
mean fees, the number of cars in a fleet, and where ride-sharing firms can operate
would be decided by local authorities.
F. Differentiate Monolithic architecture and Micro service architecture. Which is best UBER
type of systems?
ans: Monolithic Architecture
Simple to develop.
Simple to test. For example you can implement end-to-end testing by simply launching the
application and testing the UI with Selenium.
Simple to deploy. You just have to copy the packaged application to a server.
Simple to scale horizontally by running multiple copies behind a load balancer.
In the early stages of the project it works well and basically most of the big and successful
applications which exist today were started as a monolith.
Drawbacks of Monolithic Architecture
This simple approach has a limitation in size and complexity.
Application is too large and complex to fully understand and made changes fast and
correctly.
The size of the application can slow down the start-up time.
You must redeploy the entire application on each update.
Impact of a change is usually not very well understood which leads to do extensive manual
testing.
Continuous deployment is difficult.
Monolithic applications can also be difficult to scale when different modules have
conflicting resource requirements.
Another problem with monolithic applications is reliability. Bug in any module (e.g.
memory leak) can potentially bring down the entire process. Moreover, since all instances
of the application are identical, that bug will impact the availability of the entire application.
Monolithic applications has a barrier to adopting new technologies. Since changes in
frameworks or languages will affect an entire application it is extremely expensive in both
time and cost.
Microservices Architecture
The idea is to split your application into a set of smaller, interconnected services instead of building
a single monolithic application. Each microservice is a small application that has its own hexagonal
architecture consisting of business logic along with various adapters. Some microservices would
expose a REST, RPC or message-based API and most services consume APIs provided by other
services. Other microservices might implement a web UI.
The Microservice architecture pattern significantly impacts the relationship between the application
and the database. Instead of sharing a single database schema with other services, each service has
its own database schema. On the one hand, this approach is at odds with the idea of an
enterprise-wide data model. Also, it often results in duplication of some data. However, having a
database schema per service is essential if you want to benefit from microservices, because it
ensures loose coupling. Each of the services has its own database. Moreover, a service can use a
type of database that is best suited to its needs, the so-called polyglot persistence architecture.
Some APIs are also exposed to the mobile, desktop, web apps. The apps don’t, however, have
direct access to the back-end services. Instead, communication is mediated by an intermediary
known as an API Gateway. The API Gateway is responsible for tasks such as load balancing,
caching, access control, API metering, and monitoring.
Benefits of Microservices Architecture
It tackles the problem of complexity by decomposing application into a set of manageable
services which are much faster to develop, and much easier to understand and maintain.
It enables each service to be developed independently by a team that is focused on that
service.
It reduces barrier of adopting new technologies since the developers are free to choose
whatever technologies make sense for their service and not bounded to the choices made at
the start of the project.
Microservice architecture enables each microservice to be deployed independently. As a
result, it makes continuous deployment possible for complex applications.
Microservice architecture enables each service to be scaled independently.
Drawbacks of Microservices Architecture
Microservices architecture adding a complexity to the project just by the fact that a
microservices application is a distributed system. You need to choose and implement an
inter-process communication mechanism based on either messaging or RPC and write code
to handle partial failure and take into account other fallacies of distributed computing.
Microservices has the partitioned database architecture. Business transactions that update
multiple business entities in a microservices-based application need to update multiple
databases owned by different services. Using distributed transactions is usually not an
option and you end up having to use an eventual consistency based approach, which is more
challenging for developers.
Testing a microservices application is also much more complex then in case of monolithic
web application. For a similar test for a service you would need to launch that service and
any services that it depends upon (or at least configure stubs for those services).
It is more difficult to implement changes that span multiple services. In a monolithic
application you could simply change the corresponding modules, integrate the changes, and
deploy them in one go. In a Microservice architecture you need to carefully plan and
coordinate the rollout of changes to each of the services.
Deploying a microservices-based application is also more complex. A monolithic
application is simply deployed on a set of identical servers behind a load balancer. In
contrast, a microservice application typically consists of a large number of services. Each
service will have multiple runtime instances. And each instance need to be configured,
deployed, scaled, and monitored. In addition, you will also need to implement a service
discovery mechanism. Manual approaches to operations cannot scale to this level of
complexity and successful deployment a microservices application requires a high level of
automation.
ans: Instagram is a social networking service which enables its users to upload and share their photos
and videos with other users. Instagram users can choose to share either publicly or privately. Anything
shared publically can be seen by any other user, whereas privately shared contents can only be
accessible by a specified set of people. Instagram also enables its users to share through many other
social networking platforms, such as Facebook, Twitter, Flickr, and Tumblr.
ans:Functional Requirements
The system should be able to generate and display a user’s News Feed consisting of top photos
from all the people the user follows.
Non-functional Requirements
The acceptable latency of the system is 200ms for News Feed generation.
Consistency can take a hit (in the interest of availability), if a user doesn’t see a photo for a while,
it should be fine.
The system should be highly reliable, any uploaded photo or video should never be lost.
ans: Adding tags to photos, searching photos on tags, commenting on photos, tagging users to photos,
who to follow, suggestions, etc.
ans:The system would be read-heavy, so we will focus on building a system that can retrieve photos
quickly.
Practically users can upload as many photos as they like. Efficient management of storage should
be a crucial factor while designing this system.
Data should be 100% reliable. If a user uploads a photo, the system will guarantee that it will
never be lost.
E. Give example for the scenario: Capacity Estimation and Constraints in Instagram
ans:Let’s assume we have 500M total users, with 1M daily active users.
ans:
G. Draw its Database Schema
ans:
H. What are the different approaches for sending News Feed contents to the users?
ans:a. Partitioning based on UserID :Let’s assume we shard based on the ‘UserID’ so that we can keep all
photos of a user on the same shard. If one DB shard is 1TB, we will need four shards to store 3.7TB of
data. Let’s assume for better performance and scalability we keep 10 shards.
So we’ll find the shard number by UserID % 10 and then store the data there. To uniquely identify any
photo in our system, we can append shard number with each PhotoID.
b. Partitioning based on PhotoID: If we can generate unique PhotoIDs first and then find a shard number
through “PhotoID % 10”, the above problems will have been solved. We would not need to append
ShardID with PhotoID in this case as PhotoID will itself be unique throughout the system.
I. Data Size Estimation: • Estimate how much data will be going into each table and how much total
storage we will need for next 10 years for 500million user?
ans:32GB.
ans:
ans:
Synchronisation
Dropbox Errors
Automatic updates
Efficient syncing
File sharing
File storage
Offline access
Dark launch: In August 2014, they embarked on “dark launch,” at which point they were mirroring
data between two regional locations and considered the system ready to store user data. Of course,
being Dropbox, they kept extra backups for another 6 months after this date just in case.
Launch day: February 27, 2015 was D-day. For the first time in the history of Dropbox, they began storing
and serving user files exclusively in-house. Once it validated the new infrastructure, it set an aggressive
goal of scaling the system to more than 500PB in six months.
BASE Jump: On April 30, 2015, they began the race to install additional servers in three regional locations
fast enough to keep up with the flow of data. To make this all work, they built a high-performance
network from the servers which allowed them to transfer data at a peak rate of over half a terabit per
second. Because their schedule left so little time to “open the parachute,”they called this part of the
project BASE Jump. On the hardware side, they were pushing up against the limitations of how many
racks of hardware could fit in the loading dock at one time.
Successful landing: The goal was to serve 90% of the data from in-house infrastructure by October 30,
2015. They actually hit the mark almost a month early, on October 7, 2015. The team not only delivered
on time, but also achieved this significant technical undertaking without any major service disruptions or
any loss of data.
OS: FreeBSD
Ejabberd server is based on a set of pluggable modules that enable features like:
One-on-one messaging
They use a customised version of XMPP - (eXtensible Messaging and Presence Protocol) which enables
message delivery. They call it FunXMPP (details on customization are in this post). WhatsApp stores
multimedia files on YAWS (Yet another web server).
Database: Mnesia
WhatsApp is an asynchronous IM app. It uses a client-server model for messaging. All the messages are
stored locally (on the app). They queue on the server, though, in case a recipient is offline. As soon as
delivered, the queue is deleted. A user may back them up to Google cloud.
B. What is LYCE/LYME Architecture and draw its architecture diagram.
ans: WhatsApp or most of the other messaging apps rarely work on a peer to peer basis. So it wouldn't
open a connection (from your device) to each of your friends' devices. Instead your device connects to
their server. It could then use a custom TCP protocol or maybe HTTP to communicate your messages to
the server. The server in return would dispatch them to your friends' devices. If your friend had their app
open or at least the app process running there might be a live connection to the server. WhatsApp will
use that connection to send them your messages. If their app is "offline" then they might choose to send
them a push notification instead. WhatsApp has chosen Erlang a language built for writing scalable
applications that are designed to withstand errors. Erlang uses an abstraction called the Actor model for
it's concurrency .Instead of the more traditional shared memory approach, actors communicate by
sending each other messages. Actors unlike threads are designed to be lightweight. Actors could be on
the same machine or on different machines and the message passing abstractions works for both. A
simple implementation of WhatsApp could be: Each user/device is represented as an actor. This actor is
responsible for handling the inbox of the user, how it gets serialized to disk, the messages that the user
sends and the messages that the user receives
D. Assume there are various features called user base,last seen,media,emcrypt and telephony services.
Explain how to implement Lastseen in Whatapp system design
ans: Implementation of this feature is very simple and straightforward, It is just about maintaining a
record with Client ID and Timestamp.
When we open Whatsapp in our smartphone, our application sends a pulse to server every 5 seconds,
and with every pulse last seen time is updated in the table. As the client disconnects the last seen time
exists in the record that is updated by the last pulse sent before closing the app.