Which database writer model is optimal?

57 Views Asked by At

I have 2 servers.

Server 1: (Master Server)

- Master Database MariaDB
- PHP Service
    + Reader from Master Database
    + Writer into Master database

Server 2: (Slave Server)

- Slave Database from Server 1
- PHP Service
    + Reader from Slave Database

So, I want to create Writer into Master Database for Server 2.

And I drawing and two way for insert data into Master Server in this image (The direction of the arrow is the direction the data will come.).

enter image description here

I do not know which the way to choose for optimization and I do not have much time to program both tests.

Anyone who has experience in this or a new idea. thank you

1

There are 1 best solutions below

1
On

I assume the Web Service next to the Master is for ingesting data from sources other than the "Clients"?

The first picture is better. Why incur the extra hop and the extra coding of the second picture?

But... Beware of the "critical read" problem. This where, for example, a client posts a blog comment, then goes to the next web page, but that page fails to show the comment. The problem is that the write to the Master may not have gotten to the Slave before the user gets to that page.

This is solved in a variety of ways; I am merely alerting you of the issue. (The issue is probably more prevalent in the second picture.)

I have done the first picture many times; never even considered the second picture.