Search code examples
algorithmjbosswildflymod-cluster

Custom load balancing algorithm with mod_cluster


I have recently found out that mod_cluster offers more capabilities than mod_proxy or similiar modules. Hence there are dynamic deployment and new metrics available for the load balancing I have a question if there is a possibility to write own load balancing algorithm instead of using predefined ones. If so where to implement it?


Solution

  • Yes its possible. You need following steps:

    1. Create custom load metric by extending AbstractLoadMetric
    2. Package the custom load metric as a JAR
    3. Copy JAR to modcluster module
    4. Update module.xml to include the custom load metric JAR
    5. Update standalone/domain config XML to use custom load metric

    See sample example here: https://github.com/Karm/mod_cluster-custom-load-metric

    NOTE: WildFly 9 will bring improvement in this mechanism to avoid editing of module.xml. See https://issues.jboss.org/browse/WFLY-372