Skip to main content

Building an Optimized Backend Environment

Competitive Programming  and Backend are two really different fields, but I feel that there's a great connection between them. Backend Development is mainly about storing User Data, and building endpoints and queries to efficiently retrieve them. Once you get the hang of it, it becomes fairly easy. Honestly, I don't even feel that there's anything challenging in it unless you have a really big project to build where there are tons of endpoints and jobs. Even that, to be honest, will just require better project structure and you're sorted.





The real challenge for me, though, is deciding the format of the databases. I had learnt a Software Design principle in one my classes, and till date, I think it's the best way to efficiently design any project. Here's the 6-step procedure:

  1. Specify the problem
  2. Specify Data Structures
  3. Define Format of Data Structures
  4. Specify Algorithm
  5. Look for modularity
  6. Repeat above steps
I know it's not perfectly built for Backend Development, but if you're good with analogies, you'll know that the 'problem', is the project idea, 'Data Structures' can be our project's Data Base, 'algorithm' can be how we're going about outputting data for endpoints, and 'modularity' would mean subdividing our code features into different sections.

The last point emphasizes that we should always keep checking all our steps and validate our steps. Although the design principle says that the repetition should be restricted only to the designing phase, I make sure I'm following the steps even while implementation.

Looking for Modularity

Let's look at the second-last point again - Modularity. This point not be as important for some fling side projects as they are for bigger projects with a lot of code and data. The ease of Debugging is inversely related to the Chaos of Code. Once we figure out the different things that a project does, we can subdivide the features into modules. This gives us a rough idea of all the things that we need to do to complete the project. Now, the features can be assigned to people as tasks. The 6th step of repetition can be used, that is, let's say we divided our project into feature A and B. So the 5 steps can again be applied to simplify feature A, and likewise, for B. I love this step because the ease with which you are able to build any project totally depends on this very step of designing.

Algorithm Specification    

This is a fairly obvious point. Although there isn't any big 'algorithm' for every endpoints response, specifying what happens in every step is perhaps the core part of designing.

Data Structures Specification

This is the 2nd point in the 6-step procedure. Specifying the Data Bases. The next step, Specifying the Format of Data Bases is closely linked with this step too. Together, these steps decide your project's real scalability. In today's world, Data plays the most important role in everything. All AI, ML, etc applications that you want to build in your project will need a lot of Data, any website that you build will need you to store User's data, and your content. All this data needs to be stored in such a way that it is efficiently retrieved in the fastest possible time from the Data Base. 

This step, honestly, is the toughest one for me. Sure, you can build a side project in any format you want, but how you store that data will impact the difference in response times when your project starts to scale. Imagine the amount of optimizations that engineers at Google, Facebook and Amazon must have done to deliver such quick response times! And this is the area, where most Backend Developers must strive to improve. 

Backend Developers must know what kind of Data Base would maintain their project after scaling. Usage of Graphs, Trees, LinkedLists is something which I have never done in my projects. Certainly there must be ways & situations to implement these in real-life projects. The question is, how do we decide when to use which data structure? 

There is a lot of theory that could give you some idea about applications of Data Structures, but if you're a good coder, I can say that you don't like memorizing. Referencing the conditions needed for usage of a DS is not as good as being able to visualize the project through that application. 

So now the question is, how do we get to the state where we can decide for ourselves what kind of optimizations to use & when? 
By practicing cases where it can be used and actually implementing it on code. That's where Competitive Programming comes in. CP is something that will definitely teach you how to optimize everything in your project. That is the best way to learn the applications of Data Structures and Algorithms I've found till date. Building an API or a Website is easy, but making it efficient is tougher. That is the challenge you should aim for.
























Comments

Popular posts from this blog

Namaste JavaScript Quick Notes

Note:  Akshay Saini's Namaste JavaScript is probably the best course for JavaScript developers out there. These are my personal notes that I made while watching the course; they serve more of as an online quick reference for my understanding and revision, and I hope it benefits anyone reading it too! Everything in JS happens inside an Execution Context. Before a JS code is run, memory is allocated and variables are set as undefined   , and functions are set as their exact code in the scope within the Execution Context. The global execution context hosts all the global variables and function definitions. An Execution Context has 2 components: Memory, that stores variables and functions; and Code, that reads and executes the code. Call Stack maintains the order of execution contexts. Since JS is single threaded and asynchronous, at one point of time, only one function is executed which is at the top of the call stack. For each function, an execution context is created before ex...

How Kafka replaced Zookeeper with the (K)Raft algorithm?

Back in 2021, when I first came across Kafka, I remember the DevOps engineer in my team using terms like Zookeeper, broker configs, etc on our team standup calls. I remember not caring about those terms, and simply focusing on learning about the producer, partitions, topics and consumer groups, and how they could be used in the product my team was developing. While platforms like Kafka were built to abstract certain aspects of distributed computing (replication, consistency) while storing & processing logs, it's a pity how so many of us miss out on knowing the amazing engineering that went behind to build the different parts of a platform such as this one. 4 years later, I'm hungry enough to reverse engineer one of my favourite distributed platforms - Kafka! What did the Zookeeper do? To quote the 1st  Kafka paper from 2011, Kafka uses Zookeeper for the following tasks:  (1) detecting the addition and the removal of brokers and consumers,  (2) triggering a rebalance ...

"Hey Google" get me a new T-shirt

Everyone loves Google for its amazing technology and creative workspaces! Guess what? Google loves its developers as much as the world loves it too! And yeah, you don't need to be an amazing programmer to be a developer in Google's community. All you need to do is to spare 30 minutes, just once, and maybe have some creativity! That's it! Oh, and you should be really checking your mails periodically, although if you don't currently have this habit, your excitement would develop that for you. What do we want? So you arrived here to know about getting a T-shirt. Would you also like having a Google Home ? Yup, that is also something you could get through this. And of course, as I mentioned earlier, an entry to Google's Developers Community Program! There're a lot of perks for it but let's first talk business. What do we have to do? In a nutshell: Make an Action for Google Assistant .  But what's an Action ? Action is a feature, or a sub-applicat...