- Overview
- System Architecture
- Environment Setup
- Local Execution
- Containerized Deployment
- Results and Testing
- References
This project implements a fault-tolerant distributed database system designed for Autonomous Vehicle Networks (AVNs). It ensures reliable, scalable, and efficient data management in dynamic environments through advanced data sharding, fault-tolerance mechanisms, and containerized deployment.
- Data Sharding: Reduces latency by storing data closer to the source.
- Fault Tolerance: Maintains operations during node failures using master-slave replication.
- Efficient Query Processing: Handles concurrent requests with non-blocking socket communication.
- Scalability: Enables rapid deployment and testing with Docker and CI/CD pipelines.
The project deploys six nodes:
Client Node
: For sending queries.Master Node
: For query parsing and routing.Update Nodes (2)
: For handling CREATE and UPDATE operations.Replica Nodes (2)
: For handling SELECT operations and maintaining data consistency.
Refer to the project report for detailed architecture
- Install Python 3.x
- Install PostgreSQL: Download PostgreSQL
- Install Docker and Git
- Set up and activate a Python virtual environment:
python3 -m venv .venv source .venv/bin/activate python3 -m pip install --upgrade pip pip install -r requirements.txt
- Deactivate the environment:
deactivate
To update requirements.txt
after adding new libraries:
pip freeze > requirements.txt
## Environments
1. use virtualenv
```bash
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install --upgrade pip
pip install -r requirements.txt
- deactivate virtualenv
deactivate
- Update requirements.txt
pip3 freeze > requirements.txt
git clone https://github.com/Max851010/distributed_postgresql.git
cd distributed_postgresql
Each node requires specific configurations for ports and addresses in the respective Python files:
-
Client node
cd client pip install -r requirements.txt python3 db_client.py
-
Master node
cd master_server pip install -r requirements.txt python3 master_server.py
-
Update node
cd update_server pip install -r requirements.txt cd update python3 update_server.py
-
Replica node
cd update_server pip install -r requirements.txt cd replica python3 replica_server.py
- Use Docker to containerize each node.
- Automate deployments with GitHub Actions for CI/CD.
- Tested locally with three machines simulating six nodes.
- Verified query routing, sharding, and fault recovery using 9 sample records.
- Demonstrated seamless failover between update and replica nodes.
- MongoDB Documentation: Hashed Sharding
- Grolinger, K., Higashino, W. A., Tiwari, A., & Capretz, M. A. M. (2013). "Data Management in Cloud Environments: NoSQL and NewSQL Data Stores." Journal of Cloud Computing: Advances, Systems and Applications. Link
- Oluyemi, O. (2019). "How to Build a CI/CD Pipeline with Docker." CircleCI Blog. Link
- Appu, T. (2020). "Event Loop and Non-Blocking I/O." Medium. Link