Menu

Custom Map Source : multi-servers load balancing

2019-07-11
2019-07-11
  • Laurent Grenet

    Laurent Grenet - 2019-07-11

    Hi all,

    When a map source uses "load balancing" with several servers, this can be easily specified in custom map source file in XML format, thanks to ServerParts parameter (see : https://mobac.sourceforge.io/wiki/index.php/Custom_XML_Map_Sources#serverParts )

    On the other hand, if for any reason, script is in .bsh format, is there equivalent capability ? If yes, which syntax to use ?

    Thanks in advance for your answers.

     

    Last edit: Laurent Grenet 2019-07-11
  • r_x

    r_x - 2019-07-11

    BSH files are simple Java-like programs. Therefore you have a lot of options to implement load-balancing. The following example uses the tile x coordinate as indicator which server should be used:

    String[] serverParts = new String[] { "a", "b", "c"};
    
    String getTileUrl( int zoom, int x, int y ) {
       String sp = serverParts[x % serverParts.length];
       return "http://" + sp + ".myserver.example/" + zoom + "/" + x + "/" + y + ".png";    
    } 
    
     
  • Laurent Grenet

    Laurent Grenet - 2019-07-11

    OK. Many thanks !

     

Log in to post a comment.