I am designing a fairly sophisticated fault tolerance model for my app that requires very customized load balancing algorithms. The TL;DR version is that nodes in the balancer pool will flicker between different types of health statuses (Stable, Unstable, Degraded, Offline, etc.) and the balancer algorithm needs to know how to route traffic to nodes based on their health status.
I am interested in using nginx for the balancer implementation, and since I am a JVM developer, I would greatly prefer to write this complicated load balancing algorithm in Groovy/Java rather than in C, Perl, Ruby, etc. I found the nginx-clojure module after doing some basic Google searches for Java-based nginx modules/plugins.
All I'm wondering is this:
- Does this nginx-clojure module allow me to write a Java/Groovy class (say MyComplexBalancerAlgorithm.groovy) and then configure nginx to use that algorithm for routing traffic?
- If so, what is the API/contract between my custom balancer algorithm class and what the module expects? Where is this contract documented/defined? In other words, I assume nginx-clojure would pass MyComplexBalancerAlgorithm something like a J2EE servlet request (javax.servlet.http.HttpServletRequest), and would expect back a descriptor of which node in the balancer pool to forward the request off to (?). So what is nginx-clojure passing my algorithm, what method would I need to implement (say, MyComplexBalancerAlgorithm#onRequest, etc.), and what is the return type expected?
- Are there any known performance caveats/pitfalls when working with this module?
Thanks in advance!
Best,
Manny