How to Build Scalable Application

How to make a scalable application

Right architecture for a scalable application to support 2+ Million User

I have worked with clients and built many small and medium size enterprise application, usually the user base for those applications are small (not in millions) and thus the application architecture will different from what is required for a consumer based application. In B2C application, you need your application to be scalable, as the demand or user base increase, you need to quickly increase your resources to handle the demand and thus provide a smooth user experience.

Key Concepts

The key concept here is to break down your application. Below is list, how I did it for Snap Homework (we were successfully able to serve 2M+ users)

1- Frontend End — Web (HTML — Interface that user sees) or Mobile App

2- Web Services — Every function should be in this layer.

3- Database — Master — Slave Configuration

4- Frontend Processing — Process data/calculations on user device, this will have help save CPU power.

Application break down

1. Frontend Application — Mobile App, Web, Desktop

The customer interact with your application using web or mobile app or a desktop app. In case of mobile or desktop, they are already on different layer, whereas for web you need to break it from your API ‘s where your business logic/web services sits.

This will allow you easily scale horizontally.

2. Web Services — API— Business Logic

The second layer will be where you will build your Web Services or API. You can build your Web Services using any technology you are comfortable with — we used PHP as we had expertise in it.

Remember both these layers will be behind a Load Balancer (you can refer my other article on how to setup Load Balancer on GCP here) and you may require Redis to manage your sessions (you can read about how to setup Redis here)

3. Database Layer

Here you can use 2 approaches.

a) Master — Slave

In Master Slave setup, we have Master where all the writes happen and it keeps replicating all data inserts to Slave. You can setup multiple Slaves as you grow. Key here is that, in your Web services you will have to direct all your reads to Slave and All Writes to Master.

This allows you scale horizontally for your reads.

In Snap Homework we had use this setup.

Note: when building frontend, you can process lot of data on user device thus using their device processing power. This will save you CPU and those extra queries on DB

b) InnoDB Cluster

This is more refined way of doing scaling your Database, here you can add multiple servers and application will automatically directs writes to master and reads to slave, so you don’t have to worry about where to point reads or writes.

4- Frontend Processing

What this means is to leverage user device processing power rather that doing each and every processing on your servers. For instance, image upload — all image optimisation/resizing/compression can be performed on user device (mobile app or web using js) and sending the final image to server. Think about it, if you let your server do all the processing and you have millions of users uploading images, how much processing power can you save?

Similarly based on your application/business logic, you can transfer lot of small processing tasks to frontend/user device. As when add, these will huge savings for you.

Which Cloud Platform to use?

Azure

 

You can use AWS, GCP or Azure. I have used all three for various applications i have built for my clients, but I personally liked GCP for its flexibility, Cost effectiveness, easy of use and ability to scale up or scale down your server (in GCP if you turn off your server, you are not charged where in other cloud platforms even if you turn it off, you are still charged)

Hope this helps someone looking to have right application architecture to scale their application to meet growing customer.

Author

  • Harish Sharma

    Entrepreneur and Technology Enthusiast | Started Varshyl Technologies, a web and mobile application development company, helping companies build and promote their digital presence. Co-founded Snapworks - a mobile first communication platform for schools. Outside VT, enjoys his morning workouts, reading biographies and golf.

    View all posts