Scaling webapps

1. How scaling works

1.1 Vertical scaling

Run same things on a more powerful computer

1.2 Horizontal scaling

Means run many processes in parallel.

Nowadays, mostly we use horizontal scaling, since every computer internally have multi processors, we could do parallel programming to make whole thing work faster by nature.

2. Scaling process

2.1 Initialization: single server and database


2.2 Reverse proxy


  • Check if guests are allowed to enter
  • A proxy is a process that receives and forwards requests
  • Reverse means reqeust comes from teh internet and needs to be routed to our server

Reverse proxy does following tasks:

  • health check
    • make sure actual server is still up and running
  • routing
    • forward a request to the right endpoint
  • authentication
    • make sure that a user is actually permitted to access the server
  • firewall
    • ensure users only have access to the parts they are allowed to use

2.3 Load balancer


Most reverse proxy can also act as load balancers. Load balancer’s job is to split incoming requests among those servers

2.4 Grow database


  • Scaling database needs to deal with consistency
  • Master - slace setup or write with read-replicas
    • one part is exclusively responsible for receiving data and storing it
    • all other parts are responsible for retrieving the stored data

2.5 Microservices


  • why we need microservices?

    • different part use server to different extends
    • development - might have more overlaps in singe service
  • break server down into functional units and deploy them as individual, inter connected mini servers

2.6 Caching & Content Delivery Networks


  • Large portion of our web app consists of static assets - almost never change
    • use cache to speed it up

2.7 Message Queues


  • deal with the waiting E.G fackbook deal with uploaded images
    • store the raw, unprocessed image
    • confirm the upload to users
    • add to queue to process in the near future (async)
  • benefits
    • decouple tasks and processors
    • scale on demand

2.8 sharding


  • A technique of parallelizing an application’s stacks by separating them into multiple units, each responsible for a certain key or namespace
  • shard based on location, use frequency and so on

2.9 load balancer


Load balancer has hard limit of how many requests they can handle

  • DNS
    • free load balancers
    • registry allows you to specify multiple IPs per domain name, each leading to a different load balancer



文章标题:Scaling webapps


本文作者:Leilei Chen

发布时间:2020-01-31, 15:20:10

最后更新:2020-02-02, 14:06:57


版权声明: "署名-非商用-相同方式共享 4.0" 转载请保留原文链接及作者。