# Custom Load Balancing algorithm

**URL:** <https://community.traefik.io/t/custom-load-balancing-algorithm/22048>\
**Category:** Traefik v3 (latest)\
**Tags:** plugin\
**Created:** [March 29, 2024, 7:23am UTC](https://community.traefik.io/t/custom-load-balancing-algorithm/22048 "2024-03-29T07:23:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BLaurent](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/blaurent/32/8455_2.png) [@BLaurent](https://community.traefik.io/u/BLaurent)\
**Post date:** [March 29, 2024, 7:23am UTC](https://community.traefik.io/t/custom-load-balancing-algorithm/22048/1 "2024-03-29T07:23:51Z")

</div>

Hi everyone,

I've the nive diagram with the different stages: router, service, middleware.

I understood that only middleware is exposed to the plugin api. Did I understood correctly or creating a plugin at service level is totally possible.

I want to create a custom load balancer, to redirect request according to query parameters(regexp won't work).  
I've hacked a quick test with lua using HAP, but development effort will to big compared to golang.  
Thanks in advance for your comments.

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [March 29, 2024, 9:27am UTC](https://community.traefik.io/t/custom-load-balancing-algorithm/22048/2 "2024-03-29T09:27:39Z")

</div>

According to [doc](https://plugins.traefik.io/create) you can create middleware and provider plugin. I don’t think any plugin has influence on the service that follows in the chain (which service/URL).

You could try to hack the system by doing the request to target service within the middleware and then "return early", not delegating to service down the chain.

---

<div class="post-metadata">

**Author:** ![BLaurent](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/blaurent/32/8455_2.png) [@BLaurent](https://community.traefik.io/u/BLaurent)\
**Post date:** [March 30, 2024, 4:27pm UTC](https://community.traefik.io/t/custom-load-balancing-algorithm/22048/3 "2024-03-30T16:27:25Z")

</div>

Thanks the pointer but I am not sure if this might be enough. Will try anyway.  
Regards
