Advanced Mirroring Module

jdeweese

Joined: 2007-04-18
Posts: 2
Posted: Wed, 2007-04-18 18:54

I am interested in writing a module to perform the advanced mirroring functions and I am looking for advice on where to start. I am specifically interested in doing mirror of the images (and thumbnails) not so much the load balancing of the whole site.

First off I'm not sure if enough is exposed to the module api or if this has to be a core change. Can someone point me to the right classes to start looking at? I assume there is a class that handles the behavior of the images.

Has anyone thought of a design approach? I was thinking of having some JavaScript that would go through a priority list of alternatives and try to retrieve the images. So instead of the img src being a hard link it would be effectively a list of alternative defaulting to the server that Gallery 2 is being served from.

I am a Java (JSP) programmer by day so sorry if any of my terminology is wrong.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2007-04-18 23:03

Changing the image URL isn't the problem in this task.
The coral cache module did that already (compatible wtth G2.0, hasn't been really updated to work with G2.1/2.2).
All needed to change image URLs to point to another server is registering a new url generator.

Pointing image URLs to another server, just saves you load / bandwidth.

The 2 main challenges in this task are:
1. Fetching files from a remote server on request (and hopefully transparentely)
2. Permission / Access control

Most users interested in the "advanced mirroring module" are actually interested in putting the image storage on another server.
They usually argue that their G2 server has PHP, but not enough webspace. And that they have another server, which wouldn't have PHP or wouldn't be fast enough, but has a lot of disk-space.
So what they want is not a copy of their image files on the remote server, they want to move the original to the remote server.

Which introduces the problem of availability of the original when it's actually needed.
E.g. what to do at configuration time / album / image editing time. Say the user wants to generate new thumbnails or larger resizes. Now you have to fetch the image file from the remote server, generate the new resize / thumbnail and upload the resize / thumbnail to the remote server again.

@Access control:
I guess you only want to mirror publicly accessible images. Adding proper access control gets quite challenging when dealing with remote servers.

Either way:
The two main components you'll have to deal with are:
- GalleryUrlGenerator -> register your own one to change image urls to point to another server
- GalleryPlatform -> maybe we can do a core change to allow modules to register their own platforms to fetch / put files to a remote server

You'll also have to add an admin view/controller to let the admin enter a list of mirrors with access credentials.

There has been more discussion of all this.
See:
http://gallery.menalto.com/node/1625

--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage

 
jdeweese

Joined: 2007-04-18
Posts: 2
Posted: Fri, 2007-04-20 03:51

Thanks for the explanation. I didn't consider the need for access control. A secure implementation would require some code on the "image storage" side to authenticate the request. In my mind this would kind of defeat the purpose, it would be easier to just run all of G2 from the higher bandwidth server.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2007-04-20 12:17

Thus, you may want to put only public / unprotected content on the remote server.

--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage