Scaling is a good problem. How to scale your application.

Hiren Kavad
Coding Monk
Published in
3 min readApr 13, 2019

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

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.

Pros.

  1. Application compatibility is retained.
  2. Administrative efforts are reduced.
  3. You need to handle just one system.
  4. Doesn’t require much technical knowledge. (haha) btw i am in big favor of horizontal scaling.

Cons.

  1. It costs too much.
  2. If your server goes down, whole system goes down.
  3. Maintenance will lead to downtime. (Which you don’t want, obviously)
  4. Waste of resource if not enough traffic.
  5. If hulk goes crazy, you go crazy.

Horizontal Scaling

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.

Pros.

  1. No Downtime(Less ;) ), if you want to go for maintenance your application will be still up and running.
  2. Can save your money as it is dynamic scaling technique.
  3. This type scaling is super easy, with zero downtime.
  4. No single point failure.
  5. Response time can be reduced.
  6. Fault tolerance is very easy.
  7. Minions are crazy but it makes you laugh.

Cons.

  1. Your application will need to be designed in specific way.
  2. Need lot of technical skills (If it is problem for you).
  3. Not suitable for RDBMS
  4. 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.

  1. Write Code and then think about scalability.
  2. First think about scalability and then write code.

If you think you can first think about scalability, then go ahead reading.

  1. Write code in modules which are independent of each other at code level.
  2. Try to divide app in micro services.
  3. Store assets in CDN.
  4. Use cloud storage to store dynamic assets and resources.
  5. Maintain only code on servers (No Assets, No Uploaded videos or images).
  6. Use containerization (This is the key to scaling).
  7. Make your code(app) platform independent.
  8. Put configuration variable in configuration files, don’t hard code.
  9. Don’t hard code anything.(Never Ever) (IP, Domain Names)
  10. Separate Project for Separate Purpose
  11. Use NoSql (If possible)
  12. Avoid RDBMS
  13. Use distributed database instead of central one.
  14. 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

--

--