Performance relates to how efficiently a system executes tasks. It encompasses response time, throughput, and resource utilization. Techniques for improving performance include optimizing algorithms, caching, using content delivery networks (CDNs), and minimizing database queries.
The close relationship between performance and scalability stems from the ability to scale effectively impacting overall performance. A well-designed system can handle increased loads and maintain or improve its performance, keeping response times fast and resource utilization efficient as demand grows. On the other hand, scalability may be hindered by poor performance due to bottlenecks arising from increased user or data demands.
Reliability#
Reliability ensures that a system consistently performs its intended functions without failures or errors. Achieving reliability involves redundancy (backup servers), fault tolerance (handling failures gracefully), and issue monitoring.
Security#
Security involves protecting data, systems, and users from unauthorized access, breaches, and attacks. Practices include encryption, authentication, authorization, input validation, and regular security audits.
System design concepts in React#
Now that we have understood the four core system design concepts, let’s see how we can connect them with React.
Scalability in React#
Scalability is crucial when building React applications. Let’s explore some best practices to ensure our React project scales effectively.
Project structure#
It might seem unimportant, but interestingly, choosing an organizational approach that suits our project’s size and complexity can significantly increase our project’s scalability. There are a few concepts which can help organize the project:
Feature-based organization#
An easy way of grouping the files is by grouping either by features or modules. Each feature has its directory containing related components, styles, services, and utilities.
One way to organize is using layered (vertical) organization. In this organization, we can group files by functional layers (presentation, data, services). It helps to clearly define responsibilities for each layer in this case.
Another possibility for organizing files is using a Domain-Driven Design (DDD). To understand DDD, businesses can organize files by adjusting folders and subfolders around specific business domains or subdomains. This is especially useful in the case of business expansion.
A third possibility for project organization is to use atomic design. Atomic design involves creating components as building blocks at different levels of abstraction, similar to how the real world is structured. So, think in terms of how atoms are the smallest building blocks. They combine to form molecules, which interact in complex ways in organisms. In the same way, we can use templates and pages and structure our project in an intuitive manner.
Types of scalability in React#
Horizontal scalability#
Achieving horizontal scaling in a React application involves deploying it on various servers or containers, typically through cloud platforms like AWS, Azure, or Kubernetes. Horizontal scaling allows for the distribution of user requests across multiple instances, resulting in better load balancing and reduced downtime.
Vertical scalability in React#
When it comes to server-side rendering (SSR) or handling API requests, vertical scaling in a React application can improve server performance.
By vertically scaling a React application, it becomes capable of handling a higher volume of requests and delivering content more rapidly, which is particularly advantageous for applications with demanding computations or extensive datasets. When a React application requires a backend server for data retrieval or complex computations, enhancing the server’s resources can result in faster response times and a more seamless user experience. Although vertical scaling can boost performance, it has capacity restrictions and can create a single point of failure. To ensure resilience and scalability, a balanced approach, which may include horizontal scaling, is necessary.