Best practice for media/assets/cache/image directories in HA settings

I’m working on deploying one of our Mautic deployments into an auto scaling group for HA setup to match our web servers. We run about 80k contacts so we’re not huge, but I prefer a fault tolerant/HA setup for whatever I can get. We’re on AWS and Mautic is using RDS so the DB is running just fine.

For the server setup I’m using Redis for PHP session management.

I’m wondering about best practice for media/assets/cache/image directories?

I was thinking about sharing those files across servers with NFS, moving them outside the web root so I’m not serving the site php on NFS because of performance. Is this the best way to set up for what I’m trying to do? Can the cache me moved to Redis or some other in-memory shared service?

Any thoughts would be greatly appreciated. Thanks!

Hello 131,

Have you advanced in the last weeks?

I would like to help, can you provide some ore information?
First things first, are we dealing with one Mautic installation or several Mautic installations?
Why are you using RDS? Can you use anything else?
Why are you using an auto scaling group? Can you use something else?
What OS are you running Mautic on top of?
How does the rest of the stack look like?

@Yosu_Cadilla,

Thank you for the offer, your help would be greatly appreciated.

I’ve moved the cache/assets/logs/tmp to EFS and php sessions to redis. The initial rebuild of the cache on EFS was terribly slow, but performance once that was complete seems fine.

For now it’s just one instance of Mautic as a trial. 75k contacts, campaigns and broadcast emails to segments of around 25k contacts several times each week, so the vast majority of the time we have a mostly idle server.

It’s not behind the ALB yet, just running on 2 EC2 instances in separate AZ’s, but ultimately I’d like to move this to an auto-scaling container deployment.

  • RDS - because I already had a multi-az deployment available that I am using with another application
  • Stack: Ubuntu 20.04, nginx with php-fpm 7.4.2, MySQL 8

One thing that I can’t seem to figure out is how/where to host the email images. The new grapejs builder automatically moves them to the images-directory/grapejs. I can’t seem to be able to move this to a shared location, ideally it would be hosted somewhere like S3 with Cloudfront.

I’d love to have your input and suggestions.

I see, have you considered storing the images and other assets elsewhere? (As in not on a File System).

You could store them in the database.
You could store them on Redis.

For this phase of the project (you are not yet using containers) it could be as simple as using good old rsync.

Or, since you like using AWS services, you could use Elastic FS

Once you start using containers, you might be better off with one of the following Open Source tools:
Ceph: Old(-er) shared storage (automatic replication), which I believe pre-dates microservices and was used intensively in the early microservices.

Gluster / GlusterFS: De facto standard storage for many of the Docker based microservices (so everyone) for a long time.

Storageos: Newest of the bunch, newer generation of shared cloud storage, looking very good…

I, being an old school guy who prefers to install Bind than using Route 53, would simply go with rsync or any other similar tool from your prefer from your Linux toolbox…

Why do people love to pay AWS forever for just deploying open source applications for them?

Another consideration, which could make your live a lot simpler is, do you really need HA?

Maybe a serious backup strategy could serve you better? Cause if you are having trouble deploying Mautic in HA, wait for the fun of maintaining it and troubleshooting HA problems once you are in production…

I have considered rsync, it seems the easiest and most straightforward.

Thank you for the container tips, I was thinking Gluster at that point but I haven’t really looked at Storageos, I’ll have to do that.

To answer your other questions, HA because everything else I host is setup that way, not that I’ve ever had any problems. I also think I want to do it just to do it. But I think it’s more about the auto scaling for me, I don’t like seeing a server sitting around doing mostly nothing only to spike a few times a week when campaigns are running.

Thank you so much for your thoughts and input!

Understood, if you decide to try simpler components to build your HA setup, let me know…