As a backend developer, the delight of solving tough problems is an everyday thing. It’s what keeps us going, what pushes us to refine our skills always. Recently, I encountered a backend challenge that pushed my abilities to their limits, a challenge that was both discouraging and compelling. Here, I share my journey through this problem and why the HNG Internship is the perfect next step in my career.
The Problem
It all started with a simple requirement: to optimize a RESTful application. A few endpoints (especially during sign-up) were underperforming, having slow response times and a poor user experience. The task was to identify the causes and provide solutions to improve performance.
Discovering the bottlenecks
Step 1
Having an unambiguous picture of the problem, I was left with discovering the cause of the problem. The first step in solving any problem is understanding it. I needed to reproduce the issue while taking notes of the essential details that could help my analysis. I began to conduct a thorough analysis of the endpoints using "ThunderClient". I recorded the response time for most endpoints, especially the ones with POST and PUT requests. By doing this, I was able to identify the slowest endpoints.
Step 2
It is important to note that I did not overlook the GET endpoints. I decided to test a GET-based endpoint due to the complexity of its route handler and the number of middleware the request was passing through. During this process, I discovered that the endpoint \users\:id\posts
was returning comments for every post, even though it was only supposed to return the data needed for previewing a post. For instance, if a user had 10 posts, each with an average of 100 comments, the endpoint would return around 1000 comments, which were not necessary for rendering on the webpage. To address this, I modified the handler to fetch only the specific table columns required.
I also looked at other database queries, removed unnecessary joins, and wrapped some queries into a transaction.
Step 3
Something about building software is that in the end, it's the users' opinion and experience that matters. We engineers tend to improve, optimize, and innovate software to make it responsive, faster and better. I wanted to help provide a better experience for the API consumer.
I observed that the API for checking if a username is available was frequently querying the database. Initially, this might seem acceptable, but it is not efficient. To improve this, I configured the database to support indexing for the "username" column and did the same for the email. While this solution is effective for now, it may not be sustainable in the long run.
The other option which I think should be adopted in version 2.0 is to use a database to store frequently accessed DB columns. The database system for this task must be one that's optimized for search capabilities e.g. Solr, Elasticsearch etc.
Why HNG Internship?
Embarking on the HNG Internship is a significant step in my career journey. The program offers a unique opportunity to learn from some of the best minds in the industry and to work on real-world projects that can have a substantial impact. By participating in the HNG Internship, I aim to sharpen my skills further and expand my professional network.
The HNG Internship is renowned for its strict training and mentorship. It’s an environment where interns are encouraged to push their boundaries, innovate, and grow. You can learn more about the program and its offerings by visiting the HNG Internship website and the HNG Premium site.
Conclusion
Solving challenging problems is what makes backend development so rewarding. The journey through this recent problem was a testament to the importance of persistence, continuous learning, and the willingness to tackle challenges head-on. The HNG Internship represents the next phase in my journey, a chance to grow, learn, and achieve new heights.
So, if you’re passionate about backend development and eager to push your limits, I highly recommend exploring the HNG Internship. It’s an opportunity to be part of something bigger, to learn, and to make a difference.