0

My Infra setup :-

  1. 2 Webservers - Behind LoadBalancer
  2. From Magento admin - changed the base URL for media, skin and js.
  3. ONLY webserver 1 hosts the media images and not webserver2
  4. Admin URL is redirected to a admin subdomain which is pointed to webserver 1 and hence every new image upload always happens on the webserver1
  5. CloudFront origin is set to webserver1, so that it always finds the image.
  6. Both webservers are connected to DB (nothing fancy, just good to mention)

As long as I keep only 1 webserver behind the loadbalancer everything works perfect but when I add webserver2 behind the load-balancer the catalog images on front end starts appearing as default image placeholders. This happens only when the request goes to webserver2 which does not holds the catalog images locally.

This makes me think that there is some check within Magento's default functionality which replaces the actual img src with the placeholder if images are not present locally. I am looking for that function so that I can modify that as per my requirement.

Does anyone had similar experience ? Any workarounds here so that images appear on webserver2 as well ? May be I am missing something in the cloudFront setup.

Any help is appreciated!!

1

You will need to sync the media directory (using rsync), when displaying an image Magento checks if this image exists on disk (cached or original). So when the request goes to the second webserver during the page generation it fails to find the requested image and shows the placeholders.

0

Is Magento caching the images on each server? If so, webserver2 is probably generating a different cache id for the image it needs - the image with that cache id doesn't exist on webserver1, so CloudFront looks for it on webserver1, can't find it, and returns the default image.

As to what to do about it... You could write something in product view.phtml to pick up the original image - see Get original image file from a cache URL, then both servers would use the single path to the original image.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.