1

I have N git repositories that I want to shard across M git servers behind a load balancer, but I'm not sure how to do this.

For example, if I'm on Client 1

git push foo master

should to push to server A, and on Client 2

git push bar master

to push to server B.

Where git remote -v on Client 1 shows

foo     https://git.example.com/foo.git/ (fetch)
foo     https://git.example.com/foo.git/ (push)

and git remote -v on Client 2 shows

bar     https://git.example.com/bar.git/ (fetch)
bar     https://git.example.com/bar.git/ (push)

Normally, if I were sharding a database, I would modify my application code to point to a different database depending on the request, but in this case, I don't have any application code nor a database. I'm just using the git-http-backend provided by git which uses the local filesystem.

Is there a simple way of routing certain repositories to certain machines without giving each repository a different subdomain?

Jesse Shieh
  • 4,660
  • 5
  • 34
  • 49
  • Does each server have a different host name? – Code-Apprentice May 11 '17 at 23:53
  • I'd like to keep them behind a load balancer so the user isn't aware there are multiple servers. – Jesse Shieh May 11 '17 at 23:56
  • 3
    Having two remotes `foo` and `bar` exposes the fact that there are multiple servers. If you want to hide this, then you only need one remote and configure your network to handle the URL correctly. This does not seem like an issue with git at all. – Code-Apprentice May 12 '17 at 00:11
  • Well, I currently have only one git server hosting many repositories: foo, bar, and N others. What I want is to shard them from one server to many servers because N is growing too large. – Jesse Shieh May 12 '17 at 00:59
  • Do you mean that foo and bar are completely separate projects? – Code-Apprentice May 12 '17 at 01:01
  • Most likely separate projects, but they don't have to be. From the server's perspective they are just different repositories. – Jesse Shieh May 12 '17 at 01:03
  • 3
    If you have two repositories with similar code on your server, then you will need two remotes as you have shown in your example output. This is a separate issue from load balancing and sharding. The load balancing itself has nothing to do with git. You will configure your network so that a single host name refers to the entire server farm. The load balancing software/hardware will then determine which physical machine handles each request. – Code-Apprentice May 12 '17 at 01:08
  • Yeah I think you're right, but how does the load balancing determine which machine handles the request? It doesn't matter to me whether the solution is git or load balancing related. – Jesse Shieh May 12 '17 at 01:12
  • I have reached the end of my knowledge here and probably a little beyond. – Code-Apprentice May 12 '17 at 01:21

0 Answers0