Implementing Read-Write Splitting Feature in Empress

Introduction

Welcome to this developer-centric guide, designed to help you understand and implement the Read-Write Splitting Feature in Empress. This feature is crucial to improving the performance of your software as data size or the number of concurrent activities in your database increases.

Introduction to Read-Write Splitting

In conventional systems, both read and write operations are performed on the same database. However, as data size increases or the number of concurrent activities rises, developers may start encountering latency in operations.

The Read-Write Splitting Feature provides an immediate solution to this problem by separating read and write activities. It enables the system to read all data from a replica or secondary database, and write all information to a master or primary database.

In the Empress context, this feature allows you to split read and write activities between the master and replica databases, boosting operational efficiency and minimizing lag time.

Setting up the Read-Only Environment

To implement this feature, follow these steps:

  1. Pre-requisites: Ensure you have set up a MariaDB Master-Slave or Cluster environment.

  2. Configurations for Read-Only Replica: Update your site_config.json file to enable reading from the replica or secondary system.

    ...
    "read_from_replica"                 : 1/0,  // to enable disable read from replica
    "different_credentials_for_replica" : 1/0, // if database credentials are different on replica then set 1 else 0
    "replica_host"                      : "IP address for replica",
    "replica_db_port"                   : "Replica DB port",
    "replica_db_name"                   : "Replica DB name",
    "replica_db_password"               : "Replica DB password",
    ...
  1. Note: In a MariaDB master-replica environment, the DB name and DB password are the same on both systems.

  2. Grant Access Permissions: Grant access permissions for the master host on the slave or secondary system.

By following these steps, you can enhance your system’s efficiency and performance by leveraging Empress’s Read-Write Splitting Feature.

Conclusion

The Read-Write Splitting Feature in Empress unlocks a higher level of efficiency and scalability in your software. By separating the read and write activities between the master and the replica, Empress offers a solution for handling increased data sizes and concurrent activities, ensuring smooth and uninterrupted operations. This feature significantly contributes to the development and customization of business solutions, making it an essential tool for developers working with Empress.