Câu hỏi phỏng vấn NoSQL
Câu hỏi

Explain difference between scaling horizontally and vertically for databases

Câu trả lời

When discussing database scalability, it's essential to understand the two primary approaches: horizontal scaling and vertical scaling. Each method has its own advantages, disadvantages, and use cases.

Horizontal Scaling (Scaling Out)

Horizontal scaling involves adding more machines or nodes to a system to distribute the load. This method is often referred to as "scaling out."

Key Characteristics:

  • Distribution of Load: The database load is spread across multiple machines, each handling a portion of the data. This can be achieved through techniques like sharding and replication.
  • Fault Tolerance: Horizontal scaling can improve fault tolerance and availability because the failure of a single node does not bring down the entire system.
  • Potential for Infinite Scaling: Theoretically, you can continue to add more nodes to handle increasing loads, making it suitable for applications with massive data and high traffic.
  • Complexity: Implementing horizontal scaling can be complex. It often requires changes to the application architecture and careful management of data consistency and transactions across nodes.

Techniques:

  • Sharding: Dividing a large database into smaller, more manageable pieces called shards, each stored on a different machine[12][14].
  • Replication: Creating copies of the database on multiple machines to distribute read operations and provide redundancy[12][9].

Use Cases:

  • Applications with high read and write throughput requirements.
  • Systems that need to handle large volumes of data and user traffic, such as social media platforms and e-commerce sites.

Examples:

  • NoSQL databases like MongoDB and Cassandra are designed to scale horizontally with built-in support for sharding and replication[1][3][4].

Vertical Scaling (Scaling Up)

Vertical scaling involves adding more resources (CPU, RAM, storage) to an existing machine to increase its capacity. This method is often referred to as "scaling up."

Key Characteristics:

  • Resource Enhancement: Upgrading the hardware of a single machine to handle more load. This can be as simple as adding more memory or switching to a more powerful server.
  • Simplicity: Vertical scaling is generally easier to implement since it involves enhancing the existing infrastructure without significant changes to the application architecture.
  • Limitations: There is a physical limit to how much you can scale a single machine. Once the maximum capacity of the hardware is reached, further scaling is not possible.
  • Single Point of Failure: Since all operations are handled by a single machine, its failure can bring down the entire system.

Techniques:

  • Upgrading Hardware: Adding more CPU power, memory, or storage to the existing server[2][8].
  • Virtualization: Using virtual machines to allocate...
junior

junior

Gợi ý câu hỏi phỏng vấn

senior

Explain how would you keep document change history in NoSQL DB?

entry

What are NoSQL databases? What are the different types of NoSQL databases?

senior

What is Selectivity of the query in MongoDB?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào