Skip to content

Commit

Permalink
Add diagram
Browse files Browse the repository at this point in the history
  • Loading branch information
GJSBRT committed Apr 29, 2024
1 parent 84e5d2a commit 3f48dc3
Show file tree
Hide file tree
Showing 4 changed files with 196 additions and 0 deletions.
186 changes: 186 additions & 0 deletions diagram.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
<mxfile host="65bd71144e">
<diagram id="X-lXIMiD5T2TeII0J0Zy" name="consitant path">
<mxGraphModel dx="1028" dy="824" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="11" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fillColor=#60a917;strokeColor=#2D7600;" edge="1" parent="1" source="2" target="4">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="2" value="Client" style="shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;outlineConnect=0;" vertex="1" parent="1">
<mxGeometry x="315" y="184" width="30" height="60" as="geometry"/>
</mxCell>
<mxCell id="13" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fillColor=#d80073;strokeColor=#A50040;" edge="1" parent="1" source="3" target="4">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="3" value="Client" style="shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;outlineConnect=0;" vertex="1" parent="1">
<mxGeometry x="400" y="184" width="30" height="60" as="geometry"/>
</mxCell>
<mxCell id="14" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="4" target="6">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="15" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="4" target="5">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="4" value="Router" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
<mxGeometry x="290" y="314" width="80" height="80" as="geometry"/>
</mxCell>
<mxCell id="16" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fillColor=#60a917;strokeColor=#2D7600;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="5" target="9">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="20" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fillColor=#1ba1e2;strokeColor=#006EAF;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="5" target="8">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="5" value="Loadbalancer" style="whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
<mxGeometry x="220" y="434" width="80" height="80" as="geometry"/>
</mxCell>
<mxCell id="17" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fillColor=#d80073;strokeColor=#A50040;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="6" target="10">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="6" value="Loadbalancer" style="whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
<mxGeometry x="360" y="434" width="80" height="80" as="geometry"/>
</mxCell>
<mxCell id="8" value="Backend server" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="110" y="584" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="9" value="Backend server" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="270" y="584" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="10" value="Backend server" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="430" y="584" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="19" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fillColor=#1ba1e2;strokeColor=#006EAF;" edge="1" parent="1" source="18" target="4">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="18" value="Client" style="shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;outlineConnect=0;" vertex="1" parent="1">
<mxGeometry x="230" y="184" width="30" height="60" as="geometry"/>
</mxCell>
<mxCell id="21" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fillColor=#60a917;strokeColor=#2D7600;" edge="1" parent="1" source="22" target="27">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="22" value="Client" style="shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;outlineConnect=0;" vertex="1" parent="1">
<mxGeometry x="825" y="184" width="30" height="60" as="geometry"/>
</mxCell>
<mxCell id="23" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fillColor=#d80073;strokeColor=#A50040;" edge="1" parent="1" source="24" target="27">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="24" value="Client" style="shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;outlineConnect=0;" vertex="1" parent="1">
<mxGeometry x="910" y="184" width="30" height="60" as="geometry"/>
</mxCell>
<mxCell id="25" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="27" target="32">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="27" value="Router" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
<mxGeometry x="800" y="314" width="80" height="80" as="geometry"/>
</mxCell>
<mxCell id="28" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fillColor=#60a917;strokeColor=#2D7600;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="32" target="34">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="29" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fillColor=#1ba1e2;strokeColor=#006EAF;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="32" target="33">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="30" value="Loadbalancer&lt;br&gt;(offline)" style="whiteSpace=wrap;html=1;aspect=fixed;opacity=25;" vertex="1" parent="1">
<mxGeometry x="730" y="434" width="80" height="80" as="geometry"/>
</mxCell>
<mxCell id="31" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fillColor=#d80073;strokeColor=#A50040;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="32" target="35">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="32" value="Loadbalancer" style="whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
<mxGeometry x="870" y="434" width="80" height="80" as="geometry"/>
</mxCell>
<mxCell id="33" value="Backend server" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="620" y="584" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="34" value="Backend server" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="780" y="584" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="35" value="Backend server" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="940" y="584" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="36" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fillColor=#1ba1e2;strokeColor=#006EAF;" edge="1" parent="1" source="37" target="27">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="37" value="Client" style="shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;outlineConnect=0;" vertex="1" parent="1">
<mxGeometry x="740" y="184" width="30" height="60" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
<diagram id="ToJn6T-rLavQwzOpIoSz" name="weighted backends">
<mxGraphModel dx="1209" dy="969" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="O8kC-5hYSHF-95IEW0hs-1" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fillColor=#60a917;strokeColor=#2D7600;" edge="1" parent="1" source="O8kC-5hYSHF-95IEW0hs-2" target="O8kC-5hYSHF-95IEW0hs-7">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="O8kC-5hYSHF-95IEW0hs-2" value="Client" style="shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;outlineConnect=0;" vertex="1" parent="1">
<mxGeometry x="570" y="184" width="30" height="60" as="geometry"/>
</mxCell>
<mxCell id="O8kC-5hYSHF-95IEW0hs-3" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fillColor=#d80073;strokeColor=#A50040;" edge="1" parent="1" source="O8kC-5hYSHF-95IEW0hs-4" target="O8kC-5hYSHF-95IEW0hs-7">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="O8kC-5hYSHF-95IEW0hs-23" style="edgeStyle=none;html=1;entryX=1;entryY=0;entryDx=0;entryDy=0;fillColor=#d80073;strokeColor=#A50040;" edge="1" parent="1" source="O8kC-5hYSHF-95IEW0hs-4" target="O8kC-5hYSHF-95IEW0hs-7">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="O8kC-5hYSHF-95IEW0hs-4" value="Client" style="shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;outlineConnect=0;" vertex="1" parent="1">
<mxGeometry x="655" y="184" width="30" height="60" as="geometry"/>
</mxCell>
<mxCell id="O8kC-5hYSHF-95IEW0hs-5" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="O8kC-5hYSHF-95IEW0hs-7" target="O8kC-5hYSHF-95IEW0hs-12">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="O8kC-5hYSHF-95IEW0hs-6" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="O8kC-5hYSHF-95IEW0hs-7" target="O8kC-5hYSHF-95IEW0hs-10">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="O8kC-5hYSHF-95IEW0hs-7" value="Router" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
<mxGeometry x="545" y="314" width="80" height="80" as="geometry"/>
</mxCell>
<mxCell id="O8kC-5hYSHF-95IEW0hs-8" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fillColor=#60a917;strokeColor=#2D7600;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="O8kC-5hYSHF-95IEW0hs-10" target="O8kC-5hYSHF-95IEW0hs-14">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="O8kC-5hYSHF-95IEW0hs-9" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fillColor=#1ba1e2;strokeColor=#006EAF;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="O8kC-5hYSHF-95IEW0hs-10" target="O8kC-5hYSHF-95IEW0hs-13">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="O8kC-5hYSHF-95IEW0hs-21" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fillColor=#1ba1e2;strokeColor=#006EAF;" edge="1" parent="1" source="O8kC-5hYSHF-95IEW0hs-10" target="O8kC-5hYSHF-95IEW0hs-20">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="O8kC-5hYSHF-95IEW0hs-10" value="Loadbalancer" style="whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
<mxGeometry x="475" y="434" width="80" height="80" as="geometry"/>
</mxCell>
<mxCell id="O8kC-5hYSHF-95IEW0hs-11" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fillColor=#d80073;strokeColor=#A50040;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="O8kC-5hYSHF-95IEW0hs-12" target="O8kC-5hYSHF-95IEW0hs-15">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="O8kC-5hYSHF-95IEW0hs-22" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fillColor=#d80073;strokeColor=#A50040;" edge="1" parent="1" source="O8kC-5hYSHF-95IEW0hs-12" target="O8kC-5hYSHF-95IEW0hs-18">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="O8kC-5hYSHF-95IEW0hs-12" value="Loadbalancer" style="whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
<mxGeometry x="615" y="434" width="80" height="80" as="geometry"/>
</mxCell>
<mxCell id="O8kC-5hYSHF-95IEW0hs-13" value="Backend server 2" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#76608a;fontColor=#ffffff;strokeColor=#432D57;" vertex="1" parent="1">
<mxGeometry x="365" y="584" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="O8kC-5hYSHF-95IEW0hs-14" value="Backend server 3" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#6d8764;fontColor=#ffffff;strokeColor=#3A5431;" vertex="1" parent="1">
<mxGeometry x="525" y="584" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="O8kC-5hYSHF-95IEW0hs-15" value="Backend server 3" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#6d8764;fontColor=#ffffff;strokeColor=#3A5431;" vertex="1" parent="1">
<mxGeometry x="685" y="584" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="O8kC-5hYSHF-95IEW0hs-16" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fillColor=#1ba1e2;strokeColor=#006EAF;" edge="1" parent="1" source="O8kC-5hYSHF-95IEW0hs-17" target="O8kC-5hYSHF-95IEW0hs-7">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="O8kC-5hYSHF-95IEW0hs-24" style="edgeStyle=none;html=1;entryX=0;entryY=0;entryDx=0;entryDy=0;fillColor=#1ba1e2;strokeColor=#006EAF;" edge="1" parent="1" source="O8kC-5hYSHF-95IEW0hs-17" target="O8kC-5hYSHF-95IEW0hs-7">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="O8kC-5hYSHF-95IEW0hs-17" value="Client" style="shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;outlineConnect=0;" vertex="1" parent="1">
<mxGeometry x="485" y="184" width="30" height="60" as="geometry"/>
</mxCell>
<mxCell id="O8kC-5hYSHF-95IEW0hs-18" value="Backend server 3" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#6d8764;fontColor=#ffffff;strokeColor=#3A5431;" vertex="1" parent="1">
<mxGeometry x="845" y="584" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="O8kC-5hYSHF-95IEW0hs-20" value="Backend server 1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#647687;fontColor=#ffffff;strokeColor=#314354;" vertex="1" parent="1">
<mxGeometry x="205" y="584" width="120" height="60" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
Binary file added images/hwrr-consitent-path.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/hwrr-weighted-backends.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ If this algorithm already exists then please let me know. I have not been able t
2. The hash is used to generate an index into a list of backends. The weight of the backend is used to determine how many times it is in the list.
3. The backend at the index is selected.

### Consitant path
Because we use a hash to select a backend the path will always be the same for the same hash. This is useful for tcp connections for example as we do not want to load balance packets from the same connection to different backends as this results in broken connections.

We can use this to our advangate when we want to use multiple load balancers in a network. These load balancers do not need to share any state as they will always select the same backend for the same hash. Because of this a router can evenly distribute packets between our load balancers and the load balancers will make sure the packets are sent to the same backend. Even when a load balancers fails the packets will still be sent to the same backend making for a very fault tolerant system.
![Consitant Path](./images/hwrr-consitent-path.png)

### Weighted backends
The weight of a backend determines how many times it is in the list of backends. For example if we have 3 backends with weights 1, 1 and 3 then the list of backends will look like this.
![Weighted backends](./images/hwrr-weighted-backends.png)

## Results
```
goos: windows
Expand Down

0 comments on commit 3f48dc3

Please sign in to comment.