My Journey of Making an App Faster and Stronger: Scaling for Everyone
Tags: performance, architecture, learning, scalability
Published: 2023-06-30 07:38:56

Have you ever wondered how popular apps like Instagram or YouTube handle millions of users without crashing? Well, they achieve this by scaling their applications. 
Scaling means making an app faster, stronger, and able to handle lots of people using it. In this blog post, I'll share my experience of scaling an app, its strategies and real-world examples to help you navigate this journey with confidence.

**Why Apps Need Scaling ?**

Identifying the reasons why scalability is necessary is extremely important. 
Are you noticing that your application is taking too long to respond, frequently crashing, or having difficulty accommodating a large number of users? 
Recognizing these issues is the key to understand why scaling is essential. 

I faced the same problems with my application and identification of these pain points is first step towards finding a solution.

There comes Scaling.

![Scalability](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lt68m7cwvqvn0781v52e.png)

**Boosting Performance**
To make my app faster, I started looking for tactics which can help me with performance. 

![Performance fixes](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e7xt6oslhsirq8ngj9k8.png)

After some readings, I have implemented following ways to make my application faster -

1. Use of data caching -
I implemented data caching, which is like creating a temporary storage space for frequently accessed information.
By storing commonly used data in the cache, the app could retrieve it more quickly, reducing the need to fetch the data from the database every time. I have used both server side and client side caching.

2. Use of stored procedures and indexes -
I optimized the way my app interacted with the database by utilizing stored procedures and indexes. 
Stored procedures are pre-defined database commands that can be executed more efficiently than dynamic queries. 
Indexes, on the other hand, are like bookmarks that help the database quickly find specific data. 
By using these techniques, I minimized the time it took to retrieve and process the data, making the app more responsive.

3. Use of Aync await methods -
I implemented asynchronous programming using the async/await keywords. This allowed my app to perform multiple tasks simultaneously without blocking the main thread. 

**Horizontal vs. Vertical Scaling**

_Horizontal scaling,_ also known as scaling out, involves adding more machines or servers to distribute the workload.

![Horizontal Scaling](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u9tic2s8o3cat3zkgm9d.png)

When started exploring horizontal scaling, I found several benefits, it offered excellent scalability as I could simply add more servers to accommodate increasing user demand. It also allows to handle a larger number of users without sacrificing performance. 

But I have faced couple of challenges too with horizontal scaling, which are mainly,
- Data consistency 
- Multiple servers management 

Next one is _Vertical scaling_, also known as scaling up, involves improving the capacity of a single machine or server.

![Vertical Scaling](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p5c5j1p4gklvd5avzlhn.jpg)

With vertical scaling, I focused on enhancing the existing server's capabilities, such as increasing its processing power, memory, or storage capacity.

Vertical scaling provided some distinct advantages. 
Firstly, it simplified the management and configuration of my app by working with a single server. There were no complexities like multiple servers. 
Secondly, vertical scaling allowed me to use the full potential of a server, which led to significant performance improvements.

However, vertical scaling has its own limitations. 
Eventually, a server would reach its maximum capacity, and after that scaling would require costly hardware upgrades.

**Horizontal and vertical scaling together** 

When I undergo both these scaling, I started thinking like can I combine both and create a hybrid scaling. So I started implementing with load balancing and distributing the workload across multiple servers (horizontal scaling), Simultaneously, I used vertical scaling by optimizing the performance of individual servers, leveraging their increased resources.

But this hybrid approach allowed me to strike a balance between scalability and performance.

**Testing and Learning**
I used to test the changes I made to see if they improve the app's performance and scalability, I had also created an sheet where I wrote the actual numbers from testing(with load, without load etc.). 


![Build-Measure-Learn](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ljpbp0zgu4quzkpfqwdq.jpeg)

Sometimes things didn't work perfectly on the first try, but with each test, I got closer to finding the best solutions.

**Continuous Improvement**
My journey of scaling the app taught me the value of continuous improvement. Even after achieving a good results, I understood the importance of regularly monitoring the app's performance, analyzing user feedback, and making further optimizations.

**Conclusion**
Remember, 

> scaling is not a one-time task but a continuous process. 

Embrace the feedback from your users, stay updated with the latest technologies, and always strive for further improvements. 
By prioritizing performance and scalability, you can ensure that your app remains competitive, relevant, and loved by users.

I hope you found my journey and experiences of making an app faster and stronger through scaling insightful and valuable.

Happy Reading :)