cancel
Showing results for 
Search instead for 
Did you mean: 

M2 multiple servers configuration with loadbalancer

SOLVED

M2 multiple servers configuration with loadbalancer

Hi guys,

 

I was just wondering what would be the best practice for setting up multiple servers / machines behind a load balancer which would be synchronized of course.

 

I have a website which requires this kind of setup because of the high traffic. We are using Magento 2.2 community edition. My team did all the optimizations for performance that we could think of, varnish and redis are there, we are using CDN, cache warmer and so on. The primary and secondary databases are on different machines as well.
Server is using nginx and apache configuration with a load balancer.

 

So basicaly we did as much as we could but one problem still occurs. Whenever we do a deploy on the main server one of the other servers starts causing problems because of file cloning I suspect.

 

We are using rsync command to sync the files from the main server to the others.

 

Are there any better ways to do the cloning of the files?
What is your experience?
What would be the best practice solution for this problem?

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions

Re: M2 multiple servers configuration with loadbalancer

Hi,

This is a really old post. We have done many of these since. Mostly on Commerce, on both Nginx and Apache.

Here is what we usually do:

  • Admin panel on a separate machine. All the crons running here, API imports/exports, and other backend heavy lifting. It is usually on a separate subdomain.
  • In multiple servers environment, they always have a shared folder between them for media.
  • All servers that need to share sessions and data are connected to the same Redis, Varnish & Elastic

There are two options in a multisite environment:

  • Usage of subdomains
  • Usage of subfolders

When there is a multisite environment you could have separate Redis & Varnish configured for each site.

 

A load balancer is used in these cases:

  • Specific URL path, like admin subdomain, will target its own machine
  • True load balancer for us was problematic because we run Varnish right behind it. And if there are multiple servers they are still running through the same Varnish which could be a bottleneck

I'm really amazed that not many are using it as it is really necessary for bigger websites. We are using it for almost every Magento Commerce project.

Not sure if there is any documentation, but here, I wrote a blog post on Magento 2 Admin on a Separate (Sub)Domain in a Multi-Site Environment 


Not sure if this helps but I hope so.

View solution in original post

7 REPLIES 7

Re: M2 multiple servers configuration with loadbalancer

scale just php backend, not the whole system...

------------
MagenX - Magento and Server optimization

Re: M2 multiple servers configuration with loadbalancer

Can you elaborate more on scaling just php backend?

Re: M2 multiple servers configuration with loadbalancer

You could use GlusterFS or any other distributedFS. Where do you experience a bottleneck under high load?

Re: M2 multiple servers configuration with loadbalancer


@milos.z wrote:

Hi guys,

 

I was just wondering what would be the best practice for setting up multiple servers / machines behind a load balancer which would be synchronized of course.

 

I have a website which requires this kind of setup because of the high traffic. We are using Magento 2.2 community edition. My team did all the optimizations for performance that we could think of, varnish and redis are there, we are using CDN, cache warmer and so on. The primary and secondary databases are on different machines as well.
Server is using nginx and apache configuration with a load balancer.

 

So basicaly we did as much as we could but one problem still occurs. Whenever we do a deploy on the main server one of the other servers starts causing problems because of file cloning I suspect.

 

We are using rsync command to sync the files from the main server to the others.

 

Are there any better ways to do the cloning of the files?
What is your experience?
What would be the best practice solution for this problem?

 

Thank you!


Hello,

 

Did you ever get this figured out? We are trying to do the same kind of setup (multiple frontend servers running Magento behind a load balancer) and would love to know if there are best practices or a document on how to properly configure this. It seems like something that not many people are doing.

Re: M2 multiple servers configuration with loadbalancer

Hi,

This is a really old post. We have done many of these since. Mostly on Commerce, on both Nginx and Apache.

Here is what we usually do:

  • Admin panel on a separate machine. All the crons running here, API imports/exports, and other backend heavy lifting. It is usually on a separate subdomain.
  • In multiple servers environment, they always have a shared folder between them for media.
  • All servers that need to share sessions and data are connected to the same Redis, Varnish & Elastic

There are two options in a multisite environment:

  • Usage of subdomains
  • Usage of subfolders

When there is a multisite environment you could have separate Redis & Varnish configured for each site.

 

A load balancer is used in these cases:

  • Specific URL path, like admin subdomain, will target its own machine
  • True load balancer for us was problematic because we run Varnish right behind it. And if there are multiple servers they are still running through the same Varnish which could be a bottleneck

I'm really amazed that not many are using it as it is really necessary for bigger websites. We are using it for almost every Magento Commerce project.

Not sure if there is any documentation, but here, I wrote a blog post on Magento 2 Admin on a Separate (Sub)Domain in a Multi-Site Environment 


Not sure if this helps but I hope so.

Re: M2 multiple servers configuration with loadbalancer

Don't forget to share pub/static if you merge/combine css/js files. May also want to consider sharing "var" so you can place site into maintenance mode faster, di:compile sharing, etc...

Re: M2 multiple servers configuration with loadbalancer

I have a website which requires this kind of setup because of the high traffic. We are using Magento 2.2 community edition. My team did all the optimizations for performance that we could think of, varnish and redis are there, we are using CDN, cache warmer and so on. The primary and secondary databases are on different machines as well.  Tutuapp    9Apps   ShowBox