Instagram is a well known microblogging and social networking service founded in October 2010; the users typically post images inhibiting a sense of privilege level where non-registered users can only see the posts by default and registered users can also like, comment and share these posts. Additionally, each user has to be created and authenticated by the service provider in order to use the service where profile customisation is an additional feature. In this regard, we consider the following requirements and limitations of Instagram below:
The following requirements have been considered:
For the purpose of simplicity, the following limitations have been put in place:
If we consider the flow of persistence here, then persistence is another way of expressing that our intention is to store some data for a later usage into another process. Let us view the entire relationship diagram below.
We’ve decided to opt for postgreSQL in this instance, simply because it is a standard relational database and we will store the information in multiple tables, some fields may overlap between tables. For instance userID may be found in the “like” and “comments” table to indicate which user the activity originated from. This way, updating one instance of userID automatically updates all relevant instances. An alternative would be a non-relational database, inter alias, a MongoDB which is great for systems that can scale well horizontally, however, updating entries that are duplicated may need numerous calls to the DB to update all instances of the same field. The entire relationship diagram may look like this:
SELECT User FROM Binding WHERE Followee = userID
Additionally, if we intend to query all the users one user follows, it may look like this:
SELECT Followee FROM Binding WHERE User = userID
Followers can also be represented graphically, e.g., where orange single directional arrows indicate a “following” and green bi-directional arrows indicate mutual “following”:
Further on, we’ve opted for a Microservice architecture as opposed to a monolith because with such a large system and much room for improvement we thought it was best to separate the duties into smaller dedicated services:
The general scenario is as follows:
To conclude, we had the pleasure of exploring the Net Reply’s take on in terms of designing an Instagram-like ecosystem. Since Instagram is an extremely complex system, we introduced some limitations in order to cater it for the wider audience and keep this blog simple yet concise while still conveying the main system design concepts. Feel free to reach out with any questions/feedback here.