Cracking the System Design Code: A Comedy of Errors, Algorithms, and Caffeine - 01
The world is running on software. Many systems are built to provide different services. But, the process of designing these systems is quite similar.
Let's talk about a few steps briefly today. This is the first blog of a series about system design.
There should be a purpose behind each software. It needs to be analyzed and understood.
When someone is willing to build software you have to ask these basic questions.
What are the needs?
What are the functional requirements?
What are the non-functional requirements like performance, security and scalability?
Based on the client's responses, take the discussion further until you get the true picture of the system that you are doing to build. Remember to ask questions until you are crystal clear about the idea.
Always take notes and maintain proper documentation. Which will be helpful for you in the coming days. Take the approval from the customer after the discussions are finalized.
Then select an architectural pattern that is most suitable to meet the system goals. Some people select what they prefer or know more. But this will lead to unrecoverable problems in the future. You should always remember, after a few months are gone there is no way you can go back and change something without a huge cost. Therefore, always make sure you make accurate decisions along the way without adding any personnel bias.
After you select the architectural pattern, define major components, modules and their interactions. As I mentioned above properly document everything. Use appropriate UML diagrams.
When you are building a house you should have a well-designed and detailed plan. Otherwise, you will not know what you will be ending up with or What is the cost etc... It is the same for the software as well.
Well begun is half done
You should get an understanding of the current and future user base in the requirement-gathering phase.
There are many technical decisions you should make here. For example, you can think about these.
Should it scale vertically or horizontally?
How to do load balancing?
What are the caching and sharding strategies to distribute workload?
There are many ways that systems can be attacked. A few bad configurations can cause huge losses. Therefore, it is very important to do risk assessments and make sure you identify potential threats and vulnerabilities beforehand.
For example, you can take these actions to secure the system.
Proper authentication and authorization mechanism.
Encrypt sensitive data.
Use secure communication protocols (e.g.: HTTPS).
Maintain proper input validations.
A web user will wait 200 milliseconds to 1 second to get a response on average. As you can see systems should be fast enough to achieve that. Otherwise, the software product will lose customers constantly.
These are a few actions you can take to improve.
Tools like profiling and benchmarking can be useful here to identify performance bottlenecks.
Optimize important code flows.
Write efficient database queries.
Use caching mechanisms when necessary.
If it is a web, use content delivery networks(CDNs) to serve static content fast.
That is it for today.
Let's talk about five more steps tomorrow.