Image upload using CMS is unstable in Raid server environment Problem

Because it is a Raid server, uploading is not stable because it is unknown whether to connect to server-01 or server-02

Image uploaded on server-01
Display correctly

Image uploaded on server-02
Images are deleted because they are synchronized with server-01


・ Raid server built with AWS (server-01 + server-02)
┗ server-02 is synchronized with the server-01 document root every 5 minutes

・ Custom CMS using php

Flow of behavior when uploading from CMS

server-02: synchronizes server-01's document root every 5 minutes

Upload via CMS
server-02: Image upload

server-02: Image deleted to synchronize under document root of server-01 every 5 minutes

Image data is registered in DB, but it is not on the server and an error occurs

  • Answer # 1

    The term

    Raid serveris not common, so if you don't know the exact configuration, you can't say anything.
    The answer is based on guessing whether it is a server that is simply distributed in DNS round robin.

    Since there are merits/disadvantages/restrictions, please examine/verify whether they can be introduced.

    Simple method (method without application modification)

    Change the sorting method so that all pages that upload images will access server-01.
    For example, if you can only upload images from the CMS management screen,
    Prepare another domain (or subdomain) and access the management screen only from the other domain.
    By registering only the IP address of server-01 in the A record of another domain, the file will be uploaded only to server-01

    Simple method 2 (don't give up deleting files)

    Do not delete files for the image upload directory in server-01 → server-02 file synchronization

    Add file synchronization from server-02 to server-01 (no image deletion)

    Classically common method 1

    Make the image upload directory of server-01 a shared directory so that it can be mounted from server-02

    Since directories are synchronized in real time, sync every 5 minutes

    Classically common method 2

    Perform bidirectional real-time synchronization with Lsyncd + Rsync

    A method unique to AWS. Comparatively easy (no need to modify the application, change the settings on the OS side)

    Mount EFS from server-01 and server-02

    A method unique to AWS. Application needs to be modified

    Use S3 (as in CHERRY's answer)

  • Answer # 2

    Yamakan from the current contents.

    If it is a high load countermeasure, Server1 and Server2 are distributed by the load balancer.

    If you don't know the relationship between Server1 and Server2 and the database, it will be difficult to answer concretely.