0% found this document useful (0 votes)
4 views2 pages

Homework 1

Uploaded by

ahmed.karboun
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Homework 1

Uploaded by

ahmed.karboun
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

Neo4j (Graph Database)


Neo4j is a graph database, so it stores data in nodes and relationships. Horizontal scalability in
Neo4j is more difficult compared to other databases because graph data is highly connected.
To scale horizontally, Neo4j uses a cluster system. In a cluster, there is usually a leader node and
several follower nodes. The leader handles write operations (adding or updating data), and the
followers copy the data.
For reading data, Neo4j can distribute queries to different nodes, which helps improve performance.
However, because relationships between data are complex, scaling across many servers is limited.

Example:
Imagine a social network like Facebook. If you store users and friendships, Neo4j keeps all
connections. When the system grows, Neo4j adds more servers, but all servers must stay
synchronized to understand relationships correctly.
So, Neo4j scales horizontally mainly for reading, but writing is controlled by a leader.

2. MongoDB (Document Database)


MongoDB is a document database, and it is designed for easy horizontal scaling using a method
called sharding.
In sharding, data is divided into small parts called shards, and each shard is stored on a different
server. A special component called the query router (mongos) sends requests to the correct shard.
This allows MongoDB to handle very large datasets and many users at the same time.

Example:
Imagine an online shop like Amazon. Users from different countries are stored in different shards:
• Europe users → Shard 1
• Asia users → Shard 2
• America users → Shard 3
When a user logs in, MongoDB sends the request to the correct shard only.
MongoDB scales horizontally very well using sharding and data distribution.
3. Cassandra (Wide-column Database)
Cassandra is built for very high horizontal scalability. It uses a peer-to-peer architecture,
meaning there is no leader node. Every node is equal.
Data is automatically distributed across all nodes using a method called consistent hashing. Each
node is responsible for a part of the data.
If you add more servers, Cassandra automatically redistributes the data. This makes it very fast and
highly available, even if some nodes fail.

Example:
Imagine a messaging app like WhatsApp. Messages are stored across many servers. If one server
fails, other servers still continue working without interruption.
So, Cassandra scales horizontally very easily because all nodes share the work equally.

You might also like