Running Mailwizz on multiple servers

Discussion in 'Tips and tricks' started by Robin, Aug 5, 2019.

  1. Robin

    Robin New Member

    Joined:
    Aug 5, 2019
    Messages:
    6
    Likes Received:
    0
    S.E:
    2020-08-04 02:55:42
    L.T:
    Regular
    L.C:
    2
    Hello,

    I am setting up Mailwizz in a clustered environment. Obviously, there's no problem running the actual web application on multiple servers but what about the cron jobs? Can they be set up to run on multiple machines without any risk of unexpected behavior, for example sending duplicate emails? I am doing it to ensure everything is working even if one machine goes down or we need to take it out for maintenance.

    Thanks,
    Robin
     
  2. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,379
    Likes Received:
    2,411
    @Robin - For most of the cron jobs, we're locking them with mutexes when using pcntl to prevent running them twice, sending-campaigns being one of them. Then if using redis for mutexes and cache, you'll have them shared between your apps, so if a lock is aquired by machine A, machine B won't be able to acquire it.
    However, there are some crons which are not locked for good reasons, for example the daily cron job is not locked, because that one handles local cleanup and auto-update, so locking it makes no sense.
    My advice is to either use a single instance for crons, or programatically make sure the crons are called just once, for example by wrapping them in a scripting language(php / go / etc) which communicates with a shared lock machine like redis.
     
  3. Robin

    Robin New Member

    Joined:
    Aug 5, 2019
    Messages:
    6
    Likes Received:
    0
    S.E:
    2020-08-04 02:55:42
    L.T:
    Regular
    L.C:
    2
    Thank you so much @twisted1919. Do you have any other advice or recommendations when it comes to running Mailwizz in a multiple servers environment?

    Is there any documentation on which folders and files need to be hosted on a shared storage?
     
  4. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,379
    Likes Received:
    2,411
    @Robin - Not many since running mailwizz in multiple servers should be no different than running any web app, it's just these little things you have to take care of, like cron jobs (which i think it's the only thing actually in mailwizz).
    As for content that goes in shared storage, the /frontend/assets/{files,gallery} folders contain shared data which have to be kept in sync using rsync or any other tool you're familiar with, this is because that's where uploaded files go, template assets, etc.
    If you hit specific issues, let me know and i'll be more than happy to answer.
    Best.
     

Share This Page