Home  >  Q&A  >  body text

mysql - Why does database read-write separation improve database performance?

Why read-write separation can improve database performance
Please see the blog above. According to database common sense, read-write separation can indeed improve database performance, but you don't know if you understand its underlying principles. For example, one machine reads and the other writes, but the data still needs to be synchronized, otherwise the system will be meaningless. Well, isn't synchronization a write operation? So it's not essentially the same?

PHPzPHPz2705 days ago1250

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-05-24 11:36:46

    But there is no need to synchronize when reading. One has high performance for reading and one has high performance for writing. Separation of reading and writing is suitable for scenarios where reading is far greater than writing.

    MySQL uses many database storage engines, and each engine has advantages and disadvantages. Some do not support things, but have high performance and speed; some read quickly, but write very slowly, and some are just the opposite;... Master-slave read and write separation can give full play to the advantages of each database engine.

    Your question: But the data still needs to be synchronized. In fact, this is not considered synchronization, because all data is single item. The data of the application layer is written directly to the main library, but the data of the slave library is restored from the binlog. Moreover, the most important difference is that the main library sends the binlog to the slave library asynchronously, and the data recovery from the slave library is also asynchronous.

    Even if there is no slave database, the master database still needs to write the binlog data to the hard disk or other computers to prevent database failure. When a problem occurs in the database, the DBA can only restore the previous data from the binlog.

    In your description: "One for reading and one for writing." I guess you may be a beginner, or you may have never participated in a real project. Real online projects are all about reading and writing on N stations and backing up on M stations. After the separation of reading and writing, N units are reading, N units are writing, and M units are backing up; or 1 unit is reading, 1 unit is writing, and M units are backing up.

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-24 11:36:46

    The main purpose of reading and writing separation is to share the server pressure. It is suitable for businesses with less stringent data real-time requirements. Different system parameters can be configured as needed to cope with different reading and writing needs, thereby improving the overall performance of the entire business system!

    reply
    0
  • Cancelreply