Creating a Python System to Turn All PostgreSQL Servers into Masters with Auto-Recovery and Sync – N

Posted by tp-li@reddit | Python | View on Reddit | 6 comments

Hello Python community!I’m currently working on developing a distributed PostgreSQL system using Python, where all servers act as masters. Additionally, I’m adopting a clear separation between servers and clients to create a flexible and efficient architecture.The primary goals of this project are as follows:

  1. Master-Master architecture
  2. All servers operate equally, eliminating single points of failure (SPOF).
  3. Server-Client separation
  4. Clients can seamlessly access the system while the internal operations are optimized for distributed workloads.
  5. Automatic recovery
  6. In case of server failures, other nodes automatically handle recovery to maintain uninterrupted service.
  7. Automatic data synchronization
  8. Efficiently synchronizing data across nodes while ensuring consistency.
  9. Leveraging Python and PostgreSQL
  10. Combining Python's flexibility with PostgreSQL's robust features.

Current Tools

For this project, I’m focusing on the following two key modules:

Challenges and Feedback Needed

Here are some specific points where I’d love to get your insights:

  1. Server-Client Design Approach
  2. What’s the best way to dynamically determine which server the client should connect to in a distributed master-master setup?
  3. Any recommendations for handling automatic failover, where clients detect server failures and switch to another server seamlessly?
  4. Using psycopg3 and aioquic
  5. Any tips on best practices for asynchronous operations with psycopg3 or optimizing aioquic for this use case? Are there other libraries I should consider?
  6. Distributed Database Challenges
  7. In a master-master architecture, what are the best approaches to address consistency and conflict resolution? Are there any recommended algorithms or design patterns?
  8. System Name Suggestions
  9. I’m considering names like “PostMasterSync” or “PolyMaster,” but I’d love to hear any creative suggestions!

The Potential of This Project

This project aims to explore new possibilities in distributed databases by combining high availability and flexibility. With the power of Python and PostgreSQL, I’m excited to see how far this idea can go.I truly value the community’s knowledge and insights, and I’m looking forward to your feedback and ideas!Thank you for your time and support