7 Bottlenecks That Hurt the Scalability of Your System
By: Bobi Pu
Tags: Scalability, System Design Interview, Software Architecture, Computer Science, Software Development

Scalability means the capability of the system to process increased workload while maintaining the same latency.

For example, if your system takes X seconds to respond to a user’s request. It should take the same amount of time to respond to each of the million concurrent user requests.

Scalable Application(Img Source)

For a web application, there are 7common mistakes that can become a bottleneck and can hurt the scalability.

Poor Code Quality

Inefficient, unstructured code has the potential to slow down the entire service in production. Specifically:

Writing tightly coupled code(aka Spaghetti )

) Using unnecessary loops or nested loops

Using inefficient, higher Big-O complexity algorithm

Choosing the Wrong DB Type

Picking the wrong DB could be deadly. We need to be clear on the pros and cons of different types of DB technology.

For SQL-based(relational) DB, we are optimizing for:

Transactional

Strong consistency

For No-SQL DB:

No strong consistency requirements

Horizontal scalability

Additionally, we also need to ensure DB itself are scalable as well. The DB we choose should be able to do the partitioning, sharding, and deploying on multiple DB servers quickly.

Embedding Business Logic in the DB

The DB isn’t a place to add business logic most of the time, like in-place calculation or validation.

Adding these logics will make it significantly harder to upgrade DB or App separately. Also, it’s adding workload to DB, which it isn’t optimized for.

Having this highly coupled system could make DB refactoring or migration work a nightmare.

Not Caching Enough

In general, the cache should intercept most of the DB requests.

With the proper eviction logic, deploying cache at all necessary application layers will dramatically boost the response time.

Load Balancer Config

Depends on the traffic volume and number of servers, we need to tune the number of LB as the system scale.

LB works as the gateway to our application. Having the right amount of LB is crucial to the latency of a system.

Wrong API

The efficiency of API also dictates the latency as traffic increases. For web applications, here’s the pros and cons of the mainstream APIs:

#1 REST API:

Easy to implement and discover

Chunky response

#2 GraphQL:

Flexible query

Additional setup time on client and server

#3 RPC(gRPC) with Protocol Buffer:

Better performance with encoded and compressed binary data

Requires both clients and sever to support the data schema

Sync vs. Async

As the system scaling, handling sync tasks and async tasks with different pipelines could reduce the system complexity and latency.

For instance, to handle tasks like “processing user logging data” or “sending notifications” which should be done asynchronously, we could use an async messaging-based framework(like Kafka). Its subscribers/listeners model is ideal for handling this type of job.

Summary

Diagnosing a system’s bottleneck could be challenging. Equip yourself with proper tooling and the knowledge of typical mistakes could make this process much more manageable.