git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Use alternate GIT servers to share traffic

From
SMSamuel Lucas Vaz de Mello <samuellucas@datacom.ind.br>
Date
Mar 26, 2009, 13:40 UTC
Message-ID
<49CB85C3.20700@datacom.ind.br>
In-Reply-To
<200903252145.30226.thomas@koch.ro>
Thomas Koch wrote:
Show 21 quoted lines
> Hi,
> 
> we host a public GIT repository on our high availability company
> cluster. Cloning the repo causes a trafic volume of 326 MB. We'd like to
> avoid that much trafic while still leaving the GIT repo where it is.
> 
> I could imagine the following conversation between the GIT client and
> server:
> 
> Client: Wanna clone!
> Server: You're welcome. Please note, that while I serve the most current
> state, you can get objects much faster from my collegue Server
> CHEAPHOST.
> Client: Thank you. Will take all the objects I can get from CHEAPHOST
> and come back if I should need anything else!
> 
> The enduser should not need to specify anything, but only the regular
> git clone EXPENSIVEHOST line.
> 
> Your thoughts?
> 

I have a scenario here that is (nearly) similar to what you want. We have two development sites and we let users choose the server that is closer to them. As all changes to these repositories are made using push, we use post-receive hooks to syncronize. User can push no any of the servers and the changes will get replicated.

In the EXPENSIVEHOST you add the CHEAPHOST as remote and put a 'git push --mirror cheaphost' in the post-receive hook.
In the CHEAPHOST, you add EXPENSIVEHOST as remote and changes git config to make it put the references in refs/heads/* instead of refs/remotes/expensivehost/*.  In the post-receive hook you add a 'git push --all expensivehost'.
Also, you need to ensure that all users can authenticate in both servers (or, in my case, I made the hook use sudo to push the updates using a special user that authenticate using ssh keys).
The drawback ares:
1) User must manually choose the closest server. (maybe some sort of round-robin DNS would do it automatically?)
2) Branch and tag deletion must be done in the EXPENSIVEHOST.
3) EXPENSIVEHOST stores the remote refs from CHEAPHOST in remotes/cheaphost/* and they are pushed back to CHEAPHOST by push --mirror. These references are not used at all, but they can cause some noise in the log message during pushes.
4) If we have two users committing to the same branch exactly at the same time in the different servers, I'm not sure about what will happen :-). As precaution, I added in CHEAPHOST a cron job that does a 'git remote update' in the repo. So, if the servers became inconsistent, it will perform a forced update from EXPENSIVEHOST to CHEAPHOST. 
I have the scenario running just for a few days, so there may be some additional corner cases.
HTH,
 - Samuel
Previous: Andrew Wang
Message 4 of 4 in “Use alternate GIT servers to share traffic”
  1. Thomas KochMar 25, 2009
  2. Johannes SchindelinMar 25, 2009
  3. Andrew WangMar 26, 2009
  4. Samuel Lucas Vaz de MelloMar 26, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.