There are two kinds of problems. Good problems and bad problems. Problems always comes with cost. You need to check whether solving that problem is worthy ? Will it make your app faster and highly available ?
Today every startup wants to grow large, larger or huge. Few people gets together, gets some idea, writes some code and rolls out. Startup is started. Everyone wants to reach millions of people. If startup fails then there is no issue. But when people likes idea, and starts adapting it. Then Problem arises.
Shitty code and shitty project structure always makes scaling hard. Scaling is not a problem at all. The way code is written is a problem. Here are some points which can help you to visualize your application in large scale production environment. But before that let’s see types of scaling.
I came across very nice definition of both type of scaling on stack overflow:
Horizontal Scaling is millions of minions working together for you and vertical scaling means one big hulk will handle your business. got it, right ? No ? Go ahead reading.
Vertical scaling means you add more power (CPU/RAM) to your existing machine. Eg. Your web app became so much popular that people are crazy about all over the world. Your EC2/VPS instance is not enough handle the request pool. You go to your service provider, make few clicks and upgrade server to larger CPU/RAM. Now you can handle enough amount of traffic. That’s vertical scaling.
Data is meant to be queried, so when single node faces lot’s of query it becomes too hard to handle. For large applications involving loads of querying shouldn't implement vertical scaling. If you have limited amount of users and load, this technique is for you. Mostly uses Relational Database Management.
- Application compatibility is retained.
- Administrative efforts are reduced.
- You need to handle just one system.
- Doesn’t require much technical knowledge. (haha) btw i am in big favor of horizontal scaling.
- It costs too much.
- If your server goes down, whole system goes down.
- Maintenance will lead to downtime. (Which you don’t want, obviously)
- Waste of resource if not enough traffic.
- If hulk goes crazy, you go crazy.
When your users goes crazy about your app. You add more machines not more power to your existing machine. If your app is being used world wide these kind of scaling is very beneficial, in that case you spin up instance in different regions.
Your data can be distributed over network, so you can make it available to specific region or geographical area.
- No Downtime(Less ;) ), if you want to go for maintenance your application will be still up and running.
- Can save your money as it is dynamic scaling technique.
- This type scaling is super easy, with zero downtime.
- No single point failure.
- Response time can be reduced.
- Fault tolerance is very easy.
- Minions are crazy but it makes you laugh.
- Your application will need to be designed in specific way.
- Need lot of technical skills (If it is problem for you).
- Not suitable for RDBMS
- Need to consider while developing application.
How to build scalable Application ?
If you want to write scalable application there are two ways to write code.
- Write Code and then think about scalability.
- First think about scalability and then write code.
If you think you can first think about scalability, then go ahead reading.
- Write code in modules which are independent of each other at code level.
- Try to divide app in micro services.
- Store assets in CDN.
- Use cloud storage to store dynamic assets and resources.
- Maintain only code on servers (No Assets, No Uploaded videos or images).
- Use containerization (This is the key to scaling).
- Make your code(app) platform independent.
- Put configuration variable in configuration files, don’t hard code.
- Don’t hard code anything.(Never Ever) (IP, Domain Names)
- Separate Project for Separate Purpose
- Use NoSql (If possible)
- Avoid RDBMS
- Use distributed database instead of central one.
- Learn Docker and Kubernetes or any other container orchestration.
So these were the points to keep in mind. if you have some tips to make scaling easier, don’t forget to comment below. For more scaling and DevOps related tutorials, tricks and guide. Subscribe Coding Monk YouTube Channel. Here is a link https://www.youtube.com/channel/UC6WmItI0_8ItxS8m3Lna4-g