<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Software System Design - Medium]]></title>
        <description><![CDATA[This publication is to share the articles on Low Level Design, Object Oriented Design, High Level Design. - Medium]]></description>
        <link>https://medium.com/software-system-design?source=rss----ba905bb5f783---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Software System Design - Medium</title>
            <link>https://medium.com/software-system-design?source=rss----ba905bb5f783---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 16:01:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/software-system-design" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Twitter High Level Architecture]]></title>
            <link>https://medium.com/software-system-design/twitter-high-level-architecture-eadb94e5ae4b?source=rss----ba905bb5f783---4</link>
            <guid isPermaLink="false">https://medium.com/p/eadb94e5ae4b</guid>
            <category><![CDATA[high-level-design]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[twitter]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Raj Thakur]]></dc:creator>
            <pubDate>Sat, 07 Jan 2023 04:40:57 GMT</pubDate>
            <atom:updated>2023-01-08T03:24:38.997Z</atom:updated>
            <content:encoded><![CDATA[<p>Twitter is a social media platform that allows users to send and receive short messages called “tweets.” The platform has millions of users around the world, and must be able to handle a high volume of tweets and other data in real time. Here, we will discuss the high-level architecture of Twitter and how it is designed to meet the needs of its users.</p><p>At the core of Twitter’s architecture is a distributed database that stores all of the tweets and other data in the system. This database is optimized for fast read and write operations, as well as scalability to support a large number of users. It may use a combination of SQL and NoSQL technologies to store and manage data, depending on the needs of the application.</p><p>To handle the high volume of incoming tweets and other data, Twitter uses a distributed messaging system. This system is responsible for routing messages between different components of the system, as well as distributing messages to users in real time. The messaging system may use a variety of technologies, such as Apache Kafka, to ensure high performance and reliability.</p><p>The user-facing portion of the Twitter platform is implemented as a set of client applications, such as the Twitter website and mobile apps. These client applications communicate with the server infrastructure using APIs to send and receive tweets and other data. The APIs are responsible for handling authentication and authorization of requests, as well as rate-limiting to prevent excessive usage.</p><p>To ensure high availability of the service, Twitter uses a combination of load balancing and caching to distribute incoming requests across a cluster of servers. The server cluster is designed to be horizontally scalable, so that it can be easily expanded as the number of users grows.</p><p>Twitter places a strong emphasis on security and privacy, so the system includes various measures to protect user data and communications. This includes encryption of messages, secure authentication protocols, and measures to prevent unauthorized access to user data. Twitter also complies with relevant laws and regulations regarding data protection and privacy.</p><p>In addition to the core functionality of sending and receiving tweets, Twitter also offers a number of other features and services. These may be implemented as separate microservices, which are independent components of the system that can be developed and deployed independently of the core platform. This allows Twitter to iterate quickly and add new features and services without disrupting the overall system.</p><p>In summary, the high-level architecture of Twitter is designed to support a large and growing user base, while also providing a fast, reliable, and secure service. By using a distributed database, a distributed messaging system, and a horizontally scalable server cluster, Twitter is able to handle a high volume of data and requests in real time. The use of microservices and APIs allows for flexibility and scalability, and a focus on security and privacy helps to protect user data and communications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eadb94e5ae4b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/software-system-design/twitter-high-level-architecture-eadb94e5ae4b">Twitter High Level Architecture</a> was originally published in <a href="https://medium.com/software-system-design">Software System Design</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Price surge during online hotel booking]]></title>
            <link>https://medium.com/software-system-design/price-surge-during-online-hotel-booking-ff060c33b2b6?source=rss----ba905bb5f783---4</link>
            <guid isPermaLink="false">https://medium.com/p/ff060c33b2b6</guid>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[surge-pricing]]></category>
            <category><![CDATA[dynamic-pricing]]></category>
            <category><![CDATA[high-level-design]]></category>
            <category><![CDATA[hotel-booking-system]]></category>
            <dc:creator><![CDATA[Raj Thakur]]></dc:creator>
            <pubDate>Fri, 03 Jul 2020 20:07:34 GMT</pubDate>
            <atom:updated>2020-07-06T18:39:28.399Z</atom:updated>
            <content:encoded><![CDATA[<h3>How surge pricing works during online hotel booking</h3><p>Many of us would have faced this situation, while we plan a vacation(In my case, this generally takes a week)and try to book a room on online platform, the price of the room has already changed from the price that we had seen when we started planning, This gives a major setback to your plan if the price has increased. This has potential to even cancel your plan if by any chance you are planning to travel by air(These people are the masters in surging the price high, even if you search multiple times)</p><p>Being a software engineer, I always thought to deep dive on the design of this feature but I was too lazy to start until I got a push from few friends in our small community of <a href="https://www.facebook.com/groups/1482332218566185/">Software System Design </a>.</p><p>I don’t have much idea on the parameters that dictates the dynamic/surge pricing in the real world. So, I have come up with my own easy requirements/parameters and tried to solve the problem.</p><p><strong>Requirement</strong></p><p>Design a feature that is capable to automatically surge the booking price of the room in a hotel based on below criteria.</p><ol><li>There is no surge until 50% of the room is booked in the hotel, after that per room being booked will add 5% of the last booked price for the hotel</li><li>In a different season there will be added percentage on top of the normal surge price that is configured by the hotel owner</li></ol><p>For simplicity purposes it is assumed that each room is of the same type so that base price, etc remains to be the same.</p><p><strong>Design Approach</strong></p><p>Before we move into the details of API and DB design first let’s discuss the non-functional requirements and other details</p><ol><li>Let’s assume we are developing it for company like OYO which is one of the largest hotel owner is India, with 15K hotels comprising for around 300K rooms</li><li>Search data can be cached and the price to be shown during the room search may not be updated and can be asynchronously updated.</li><li>There will be approximately 10x detailed views of the hotels with respect to number of bookings.</li></ol><p>Before we move ahead further let’s also discuss and determine the kind of data and network traffic that we may have to face per day.</p><p><em>We know that the dynamic pricing per day is requirement #1. #2 is the static with respect to #1.</em></p><p>Let’s do certain level of mathematics</p><ol><li>Since each hotel has the same type of room, we can afford to maintain the price at hotel level, If that was not the case we would have to maintain it at individual room level. So price to be updated for the same hotel multiple times(50% of the number of rooms in the hotel) .In the worst case 150K times update to 15K hotels, now 150K updates/day of the room price is not huge as we can see the number of updates are ~2 updates/sec.</li><li>After the initial search, we would need to show the details of the hotel when the user selects the particular hotel for the booking and review the details, At this point we would need to show the actual price and this call can go to the pricing engine service<br>Number of view request(max) = 300K * 10 = 3 Million/day ~35 req/sec</li><li>Let’s look at the data growth per day, 300K room bookings per day<br>a. Assuming each booking has 20 data fields(columns) to save, It can have at max 20 * 32 Bytes(Average per field data size) = 640 Bytes.<br>b. Total data size per day = 300K * 640Bytes = 200 MB data.<br>c. Per month growth is 200 MB * 30 = 6 GB data.<br>d. So does this amount of data concerns us, No because we can maintain the price per hotel level, 15K that will correspond to 15K * 640 Bytes = 10 MB data/day.<br>e. So if we maintain the price of room at hotel(since all rooms are same type) per day data growth is 10MB which we will be able to maintain quite comfortably.<br>f. Since the requirement #2 is per season we can just afford to maintain the data for each hotel and update the same when the season changes. For historical data we can maintain the trail in some other data table/store</li></ol><p>So from the data and traffic growth perspective, application is light weight with the given requirement. Now, Let’s move on to API and DB design</p><p><strong>API design</strong></p><p>Now, Let’s see the API that would be needed.</p><ol><li>GET room price (To get the price of the room in the hotel where the booking starts at day X.)<br>a. params can be HotelID, RequestID, Start Date.</li><li>UPDATE room price (To update the price of the room of the hotel when the booking is done for the same hotel, which will also take care of updating the cache asynchronously.)<br>a. params can be HotelID, RequestID, Start Date, End Date, incrementPercent</li><li>CREATE seasonal price structure for hotels(To support the requirement #2 to update the percent of increment on top of the current price that would be evaluated.)<br>a. params can be HotelID, RequestID, Start Date, End Date, incrementPercent</li></ol><p><strong>DB Schema Design</strong></p><p>We have seen that data growth is not huge, Also the requirement is relational and booking data is required hence ACID properties can also be thought around as the important requirement so we can go with SQL like MySQL or PostgresSQL. If we need to use the service in other countries we can have country level sharding. Also country level app deployment can be a way to go if we would need to maintain the edge servers in different region of our operations</p><p>Tables and Schema as per the requirement of the problem</p><ul><li><strong>hotel</strong>(ID, location_lat, location_long, name, number_of_rooms, owner_id, created_at, updated_at)</li><li><strong>hotel_level_price</strong>(ID, hotel_id, price_date, base_price, last_price, current_price, vacant_room_count, created_at, updated_at)</li><li><strong>seasonal_charges</strong>(ID, hotel_id, start_date, end_date, seasonal_charge_percent, created_at, updated_at)</li></ul><p><strong>High Level Architecture Design</strong></p><p>Few major services that would be required to demonstrate the surge pricing functionality would be namely <strong>Search service, Booking service, Pricing Engine(Our area of focus where the surge price would be calculated)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tsSed-jgcMO0raAqch6HLg.png" /><figcaption>Very High Level architecture diagram of online hotel system that can demonstrate surge pricing functionality</figcaption></figure><p>Let’s see the sequence flow diagram, which will give us the clear understanding of how the various components in the above architecture are interacting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nnM3n6FJWmL63pcQ4eqAzg.png" /><figcaption>Sequence Flow Diagram to show the interaction between various components that happen while booking a hotel</figcaption></figure><blockquote><strong>I have purposefully removed the Web/Mobile client for simplicity and better clarity.<br>Only the happy path is considered for the simplicity of the UML<br>Few major steps like redirecting user to payment section, etc are purposefully skipped to keep focus on the surge price calculation requirement</strong></blockquote><p><strong>Let’s look at the sequence flow in details</strong></p><ol><li>User search for the hotels in the home page and search engine will respond with many hotels to the user</li><li>User select the hotel to review, search engine gets the actual price of the hotel from pricing (this is where the surge price calculation comes into the picture)and send the response to user</li><li>User request the booking, booking engine gets the price from the pricing engine and show it to user for the confirmation of the booking</li><li>User confirms “book” and booking engine books and requests the pricing engine to update the price for the next booking(this can also happen asynchronously) and respond to the user with booking data.</li></ol><p><strong>Price Engine Implementation</strong></p><p>If we see the way the price is calculated<br><em>1. We see that for the first 50% booking of the hotel rooms the base price is the price that is considered<br>2. After which there is a surge for each room being booked, <br>3. Also there is a seasonal charge on top of the price that is calculated.</em></p><p>I can think of <a href="https://en.wikipedia.org/wiki/Decorator_pattern#:~:text=In%20object%2Doriented%20programming%2C%20the,objects%20from%20the%20same%20class."><strong>Decorator pattern</strong></a> as the suitable design pattern to calculate the price of the hotel room. So the initial price being the base price will be decorated with surge charge(which can be calculated based on the number of rooms being booked just before the current booking), which again is decorated with seasonal charges.<br>This design pattern gives us the flexibility to include any other charges like GST or different kind of surge price to add dynamically without much change in the code bases.</p><p>Let’s Look at the UML class Diagram after which we will discuss each class in details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jzv82JzvL-Qo_2aaVrnjew.png" /><figcaption>UML Class Diagram for the price engine</figcaption></figure><ol><li><strong>Controller class :</strong> It is responsible for interacting with the other services, It takes the request from the API layer and calls all the price decorators one after the other to calculate the net price of the room.</li><li><strong>BasePrice class : </strong>It is responsible for querying the base price of the hotel from DB for current day. It also maintains other data that might be needed by other classes. It holds the data so that other classes do not have to query the data again.</li><li><strong>SurgePriceDecorator class :</strong> It is responsible for checking if the current booking is above 50%, If it above 50% then instead of base price, 5% on top of last price is considered as the price for the room</li><li><strong>SeasonalPriceDecorator class: </strong>It is responsible for adding the seasonal price charges which will be on top of the surge price calculated in the last step.</li></ol><p><strong>Conclusion</strong></p><p>This is the very simple use case of price surge parameters based on which the system is designed. This design is just to give the readers a clarity on how we can design such a system. In reality price surge would be dependent on many factors like number of search requests, location, weather conditions and many other factors.</p><p>Thanks so much guys for patiently reading it. Do clap if you liked it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff060c33b2b6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/software-system-design/price-surge-during-online-hotel-booking-ff060c33b2b6">Price surge during online hotel booking</a> was originally published in <a href="https://medium.com/software-system-design">Software System Design</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[System Design First Step]]></title>
            <link>https://medium.com/software-system-design/system-design-first-step-3b2d3d65682c?source=rss----ba905bb5f783---4</link>
            <guid isPermaLink="false">https://medium.com/p/3b2d3d65682c</guid>
            <category><![CDATA[software]]></category>
            <category><![CDATA[high-scalability]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Raj Thakur]]></dc:creator>
            <pubDate>Fri, 26 Jun 2020 13:10:35 GMT</pubDate>
            <atom:updated>2019-01-07T04:15:04.173Z</atom:updated>
            <content:encoded><![CDATA[<h3>Interview Questions from system design topic is no different than what we face while designing a new feature or a new service.</h3><h3>It all starts with</h3><h4><strong>Business Requirements and feature that is expected to be built</strong></h4><p>Though we know and love to build pure technical systems which will be capable of catering to various use cases and scale indefinitely but the force that truly drives the implementation of any system is the business requirements. It is very important to clarify on the business requirements or the requirement of the interviewer in case of an interview and then think of the solution.</p><blockquote>In System Design there is no correct and incorrect design, It’s either a good design or a bad design. A Solution is a good design if it solves the business requirements as close as possible and is capable of scaling such that it needs less changes in the software when the requirement is incrementally enhanced.</blockquote><h4>With the requirements in place we need to think from the perspective of estimating the data and traffic</h4><p><em>If the high-traffic is the major requirements then scalability becomes a prime concern and we need to think whether we need distributed system or not.</em></p><p><em>If the data is going to be huge we need to think whether we need to shard our DB systems.</em></p><p><em>If the data is less and only high throughout is the only concerns, a single machine backed with proper caching system is good to go. So, having a thought out requirements is very important in estimating the various attributes of system.</em></p><h4>After we are clear from the requirements, we need to think of the design goals, which our system should follow</h4><p>Design Goals are directly derived from the business requirements and proper data estimation. One should be very clear about the behaviour of the system that is required because the design goals is very much influenced with that and then the design goals should be ranked. Ex.</p><ol><li><em>Consistency</em></li><li><em>Availability</em></li><li><em>Scalability</em></li></ol><p>Above three attributes of any system is dependent upon the behaviour of the system and should be carefully thought out.</p><p>Example: For designing a banking ledger system</p><p><em>a. Consistency/robustness takes over any other requirements as no consumer would like to see inconsistent bank balance.</em></p><p><em>b. Availability comes next, as the consumer always wants to transact.</em></p><p><em>c. then comes scalability, where you want to scale to as many consumer you would like to.</em></p><h4>With above points well thought out, a high level design of the system can be penned down with clear idea about the tasks of each components</h4><h4>With the bare design on Paper, now we need to design each components and think on solving the problem(task) that each component is going to perform</h4><p>Here starts the low level design of the system when designing each components as each components consists of many modules and each modules have some Algorithmic problems to solve. So, It becomes very important how we think from our low level DB and OO design principles.</p><p><em>In interviews, it is very important how we manage time in system design round. Step 1, 2, 3, 4, together should not take more than 15 minutes, and then half an hour to deep dive on any one of the components that is asked by the interviewer.</em></p><blockquote>Let’s Discuss, Learn and Build Awesome products.</blockquote><p><a href="https://www.facebook.com/softwareSystemDesignDiscussion/?modal=admin_todo_tour">https://www.facebook.com/softwareSystemDesignDiscussion</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b2d3d65682c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/software-system-design/system-design-first-step-3b2d3d65682c">System Design First Step</a> was originally published in <a href="https://medium.com/software-system-design">Software System Design</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>