how to fix a monolith
how to fix a monolith
When it comes to improving the performance of your monolithic application, the number of users is not as important as the amount of traffic they generate. For example, some products can have fewer users but generate more traffic than others with a larger user base. Therefore, it's crucial to consider the requests and traffic your monolith receives.
To enhance your application's performance and efficiency, you need to identify bottlenecks and problematic functionalities. This involves monitoring the application to determine:
- The functionalities that receive the most traffic
- The functionalities that block the most CPU time
- The functionalities that require the most memory
After identifying bottlenecks and problems, the next step is to redesign the product accordingly. This may involve breaking down the monolith into microservices that can scale independently, and considering traffic patterns to ensure optimal performance. Evaluate whether certain functionalities can be split or merged when redesigning the backend. By addressing these issues, you can enhance the product's performance, efficiency, and reduce costs.
For example, if you identify that a bottleneck is one functionality that is composed of two operations, you can start by splitting it into two. By doing this, you can scale both operations horizontally instead of having one, allowing you to better manage traffic and reduce the impact of high traffic on your system. This approach can also help you address the issue of load imbalances, where some servers or resources may be overloaded while others are underutilized.
To create a better backend, it's important to focus on the operational level, not just the service level. Each operation can have a varying number of requests, but their impact, measured by the ratio of errors, may differ significantly.
- Operation A: 10,000 requests with 10 failures - error rate is 0.1%
- Operation B: 100 requests with 10 failures - error rate is 10%
- Operation C: 100 requests with 50 failures - error rate is 50%
If these requests are in the same service, the initial requests may hide the true error rate of your service, making it appear to have an error rate of 0.03%. Therefore, it's critical to analyze the impact of each operation and prioritize them accordingly.
Focus on the operations that have the biggest impact on user experience, not just the ones that happen most often. For instance, if a manual step in a process is crucial, users may have a bad experience if it fails, even if it's not done often. On the other hand, an operation with lots of requests that rarely fails may not affect the user experience, even if it has a high error rate. So, prioritize critical operations based on their impact, not just how often they're used.
To make a monolithic application perform better, focus on finding bottlenecks and problems. Check the traffic patterns and see what needs fixing. Then, redesign the app by breaking it down into smaller services or changing how the functions work. Also, prioritize critical tasks that impact the user experience. By doing these things, you can make the app run better, save money, and make users happy.
PS: Yes, this is a post I wrote some months ago that I have given to ChatGPT to format and rewrite in proper English.