Skip to content

Instantly share code, notes, and snippets.

@timmc
Last active June 5, 2019 19:51
Show Gist options
  • Save timmc/cb12ee4e50bfd7dd75b7697a78550551 to your computer and use it in GitHub Desktop.
Save timmc/cb12ee4e50bfd7dd75b7697a78550551 to your computer and use it in GitHub Desktop.
Simulating ELB-style hysteresis for a host that exhibits random failures for both the healthcheck and regular requests
Display the source blob
Display the rendered blob
Raw
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg
width="500" height="400"
viewBox="0 0 500 400"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
>
<title>Gnuplot</title>
<desc>Produced by GNUPLOT 5.0 patchlevel 5 </desc>
<g id="gnuplot_canvas">
<rect x="0" y="0" width="500" height="400" fill="#ffffff"/>
<defs>
<circle id='gpDot' r='0.5' stroke-width='0.5'/>
<path id='gpPt0' stroke-width='0.222' stroke='currentColor' d='M-1,0 h2 M0,-1 v2'/>
<path id='gpPt1' stroke-width='0.222' stroke='currentColor' d='M-1,-1 L1,1 M1,-1 L-1,1'/>
<path id='gpPt2' stroke-width='0.222' stroke='currentColor' d='M-1,0 L1,0 M0,-1 L0,1 M-1,-1 L1,1 M-1,1 L1,-1'/>
<rect id='gpPt3' stroke-width='0.222' stroke='currentColor' x='-1' y='-1' width='2' height='2'/>
<rect id='gpPt4' stroke-width='0.222' stroke='currentColor' fill='currentColor' x='-1' y='-1' width='2' height='2'/>
<circle id='gpPt5' stroke-width='0.222' stroke='currentColor' cx='0' cy='0' r='1'/>
<use xlink:href='#gpPt5' id='gpPt6' fill='currentColor' stroke='none'/>
<path id='gpPt7' stroke-width='0.222' stroke='currentColor' d='M0,-1.33 L-1.33,0.67 L1.33,0.67 z'/>
<use xlink:href='#gpPt7' id='gpPt8' fill='currentColor' stroke='none'/>
<use xlink:href='#gpPt7' id='gpPt9' stroke='currentColor' transform='rotate(180)'/>
<use xlink:href='#gpPt9' id='gpPt10' fill='currentColor' stroke='none'/>
<use xlink:href='#gpPt3' id='gpPt11' stroke='currentColor' transform='rotate(45)'/>
<use xlink:href='#gpPt11' id='gpPt12' fill='currentColor' stroke='none'/>
<path id='gpPt13' stroke-width='0.222' stroke='currentColor' d='M0,1.330 L1.265,0.411 L0.782,-1.067 L-0.782,-1.076 L-1.265,0.411 z'/>
<use xlink:href='#gpPt13' id='gpPt14' fill='currentColor' stroke='none'/>
<filter id='textbox' filterUnits='objectBoundingBox' x='0' y='0' height='1' width='1'>
<feFlood flood-color='#FFFFFF' flood-opacity='1' result='bgnd'/>
<feComposite in='SourceGraphic' in2='bgnd' operator='atop'/>
</filter>
<filter id='greybox' filterUnits='objectBoundingBox' x='0' y='0' height='1' width='1'>
<feFlood flood-color='lightgrey' flood-opacity='1' result='grey'/>
<feComposite in='SourceGraphic' in2='grey' operator='atop'/>
</filter>
</defs>
<g fill="none" color="#FFFFFF" stroke="currentColor" stroke-width="1.00" stroke-linecap="butt" stroke-linejoin="miter">
</g>
<g fill="none" color="black" stroke="currentColor" stroke-width="1.00" stroke-linecap="butt" stroke-linejoin="miter">
<path stroke='black' d='M53.9,342.4 L62.9,342.4 M475.0,342.4 L466.0,342.4 '/> <g transform="translate(45.6,346.3)" stroke="none" fill="black" font-family="Arial" font-size="12.00" text-anchor="end">
<text><tspan font-family="Arial" > 0</tspan></text>
</g>
</g>
<g fill="none" color="black" stroke="currentColor" stroke-width="1.00" stroke-linecap="butt" stroke-linejoin="miter">
<path stroke='black' d='M53.9,277.3 L62.9,277.3 M475.0,277.3 L466.0,277.3 '/> <g transform="translate(45.6,281.2)" stroke="none" fill="black" font-family="Arial" font-size="12.00" text-anchor="end">
<text><tspan font-family="Arial" > 0.2</tspan></text>
</g>
</g>
<g fill="none" color="black" stroke="currentColor" stroke-width="1.00" stroke-linecap="butt" stroke-linejoin="miter">
<path stroke='black' d='M53.9,212.1 L62.9,212.1 M475.0,212.1 L466.0,212.1 '/> <g transform="translate(45.6,216.0)" stroke="none" fill="black" font-family="Arial" font-size="12.00" text-anchor="end">
<text><tspan font-family="Arial" > 0.4</tspan></text>
</g>
</g>
<g fill="none" color="black" stroke="currentColor" stroke-width="1.00" stroke-linecap="butt" stroke-linejoin="miter">
<path stroke='black' d='M53.9,147.0 L62.9,147.0 M475.0,147.0 L466.0,147.0 '/> <g transform="translate(45.6,150.9)" stroke="none" fill="black" font-family="Arial" font-size="12.00" text-anchor="end">
<text><tspan font-family="Arial" > 0.6</tspan></text>
</g>
</g>
<g fill="none" color="black" stroke="currentColor" stroke-width="1.00" stroke-linecap="butt" stroke-linejoin="miter">
<path stroke='black' d='M53.9,81.8 L62.9,81.8 M475.0,81.8 L466.0,81.8 '/> <g transform="translate(45.6,85.7)" stroke="none" fill="black" font-family="Arial" font-size="12.00" text-anchor="end">
<text><tspan font-family="Arial" > 0.8</tspan></text>
</g>
</g>
<g fill="none" color="black" stroke="currentColor" stroke-width="1.00" stroke-linecap="butt" stroke-linejoin="miter">
<path stroke='black' d='M53.9,16.7 L62.9,16.7 M475.0,16.7 L466.0,16.7 '/> <g transform="translate(45.6,20.6)" stroke="none" fill="black" font-family="Arial" font-size="12.00" text-anchor="end">
<text><tspan font-family="Arial" > 1</tspan></text>
</g>
</g>
<g fill="none" color="black" stroke="currentColor" stroke-width="1.00" stroke-linecap="butt" stroke-linejoin="miter">
<path stroke='black' d='M53.9,342.4 L53.9,333.4 M53.9,16.7 L53.9,25.7 '/> <g transform="translate(53.9,364.3)" stroke="none" fill="black" font-family="Arial" font-size="12.00" text-anchor="middle">
<text><tspan font-family="Arial" > 0</tspan></text>
</g>
</g>
<g fill="none" color="black" stroke="currentColor" stroke-width="1.00" stroke-linecap="butt" stroke-linejoin="miter">
<path stroke='black' d='M138.1,342.4 L138.1,333.4 M138.1,16.7 L138.1,25.7 '/> <g transform="translate(138.1,364.3)" stroke="none" fill="black" font-family="Arial" font-size="12.00" text-anchor="middle">
<text><tspan font-family="Arial" > 0.2</tspan></text>
</g>
</g>
<g fill="none" color="black" stroke="currentColor" stroke-width="1.00" stroke-linecap="butt" stroke-linejoin="miter">
<path stroke='black' d='M222.3,342.4 L222.3,333.4 M222.3,16.7 L222.3,25.7 '/> <g transform="translate(222.3,364.3)" stroke="none" fill="black" font-family="Arial" font-size="12.00" text-anchor="middle">
<text><tspan font-family="Arial" > 0.4</tspan></text>
</g>
</g>
<g fill="none" color="black" stroke="currentColor" stroke-width="1.00" stroke-linecap="butt" stroke-linejoin="miter">
<path stroke='black' d='M306.6,342.4 L306.6,333.4 M306.6,16.7 L306.6,25.7 '/> <g transform="translate(306.6,364.3)" stroke="none" fill="black" font-family="Arial" font-size="12.00" text-anchor="middle">
<text><tspan font-family="Arial" > 0.6</tspan></text>
</g>
</g>
<g fill="none" color="black" stroke="currentColor" stroke-width="1.00" stroke-linecap="butt" stroke-linejoin="miter">
<path stroke='black' d='M390.8,342.4 L390.8,333.4 M390.8,16.7 L390.8,25.7 '/> <g transform="translate(390.8,364.3)" stroke="none" fill="black" font-family="Arial" font-size="12.00" text-anchor="middle">
<text><tspan font-family="Arial" > 0.8</tspan></text>
</g>
</g>
<g fill="none" color="black" stroke="currentColor" stroke-width="1.00" stroke-linecap="butt" stroke-linejoin="miter">
<path stroke='black' d='M475.0,342.4 L475.0,333.4 M475.0,16.7 L475.0,25.7 '/> <g transform="translate(475.0,364.3)" stroke="none" fill="black" font-family="Arial" font-size="12.00" text-anchor="middle">
<text><tspan font-family="Arial" > 1</tspan></text>
</g>
</g>
<g fill="none" color="black" stroke="currentColor" stroke-width="1.00" stroke-linecap="butt" stroke-linejoin="miter">
</g>
<g fill="none" color="black" stroke="currentColor" stroke-width="1.00" stroke-linecap="butt" stroke-linejoin="miter">
<path stroke='black' d='M53.9,16.7 L53.9,342.4 L475.0,342.4 L475.0,16.7 L53.9,16.7 Z '/></g>
<g fill="none" color="black" stroke="currentColor" stroke-width="1.00" stroke-linecap="butt" stroke-linejoin="miter">
<g transform="translate(264.4,391.3)" stroke="none" fill="black" font-family="Arial" font-size="12.00" text-anchor="middle">
<text><tspan font-family="Arial" >Server failure rate</tspan></text>
</g>
</g>
<g fill="none" color="black" stroke="currentColor" stroke-width="1.00" stroke-linecap="butt" stroke-linejoin="miter">
</g>
<g id="gnuplot_plot_1" ><title>server uptime</title>
<g fill="none" color="black" stroke="currentColor" stroke-width="1.00" stroke-linecap="butt" stroke-linejoin="miter">
<g transform="translate(407.9,38.6)" stroke="none" fill="black" font-family="Arial" font-size="12.00" text-anchor="end">
<text><tspan font-family="Arial" >server uptime</tspan></text>
</g>
</g>
<g fill="none" color="black" stroke="currentColor" stroke-width="1.00" stroke-linecap="butt" stroke-linejoin="miter">
<use xlink:href='#gpPt0' transform='translate(53.9,16.7) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(58.1,16.7) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(62.3,17.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(66.5,21.3) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(70.7,23.1) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(75.0,24.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(79.2,33.6) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(83.4,37.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(87.6,54.1) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(91.8,58.9) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(96.0,65.9) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(100.2,77.3) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(104.4,82.7) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(108.6,104.9) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(112.9,121.8) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(117.1,126.8) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(121.3,146.9) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(125.5,158.2) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(129.7,182.3) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(133.9,190.7) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(138.1,203.9) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(142.3,213.6) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(146.5,241.7) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(150.8,248.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(155.0,261.6) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(159.2,260.3) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(163.4,268.6) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(167.6,282.5) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(171.8,295.8) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(176.0,305.0) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(180.2,301.5) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(184.4,312.3) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(188.7,319.8) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(192.9,318.3) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(197.1,327.0) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(201.3,323.3) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(205.5,326.1) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(209.7,328.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(213.9,330.8) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(218.1,336.1) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(222.3,336.0) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(226.6,338.1) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(230.8,339.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(235.0,337.8) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(239.2,340.1) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(243.4,339.8) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(247.6,338.3) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(251.8,340.6) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(256.0,341.0) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(260.2,341.5) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(264.5,340.3) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(268.7,341.8) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(272.9,341.7) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(277.1,341.0) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(281.3,341.9) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(285.5,341.6) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(289.7,342.2) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(293.9,341.9) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(298.1,342.3) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(302.3,342.3) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(306.6,342.2) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(310.8,342.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(315.0,342.2) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(319.2,342.2) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(323.4,342.3) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(327.6,342.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(331.8,342.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(336.0,342.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(340.2,342.3) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(344.5,342.3) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(348.7,342.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(352.9,342.3) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(357.1,342.3) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(361.3,342.1) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(365.5,342.2) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(369.7,342.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(373.9,342.3) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(378.1,342.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(382.4,342.3) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(386.6,342.3) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(390.8,342.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(395.0,342.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(399.2,342.3) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(403.4,342.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(407.6,342.3) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(411.8,342.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(416.0,342.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(420.3,342.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(424.5,342.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(428.7,342.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(432.9,342.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(437.1,342.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(441.3,342.3) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(445.5,342.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(449.7,342.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(453.9,342.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(458.2,342.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(462.4,342.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(466.6,342.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(470.8,342.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(475.0,342.4) scale(4.50)' color='rgb(148, 0, 211)'/>
<use xlink:href='#gpPt0' transform='translate(437.3,34.7) scale(4.50)' color='rgb(148, 0, 211)'/>
</g>
</g>
<g id="gnuplot_plot_2" ><title>effective failure rate</title>
<g fill="none" color="black" stroke="currentColor" stroke-width="1.00" stroke-linecap="butt" stroke-linejoin="miter">
<g transform="translate(407.9,56.6)" stroke="none" fill="black" font-family="Arial" font-size="12.00" text-anchor="end">
<text><tspan font-family="Arial" >effective failure rate</tspan></text>
</g>
</g>
<g fill="none" color="black" stroke="currentColor" stroke-width="1.00" stroke-linecap="butt" stroke-linejoin="miter">
<use xlink:href='#gpPt1' transform='translate(53.9,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(58.1,339.1) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(62.3,335.9) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(66.5,332.8) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(70.7,329.6) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(75.0,326.5) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(79.2,323.9) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(83.4,321.1) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(87.6,319.3) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(91.8,316.9) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(96.0,314.8) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(100.2,313.2) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(104.4,311.2) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(108.6,311.5) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(112.9,311.5) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(117.1,310.1) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(121.3,311.1) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(125.5,311.1) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(129.7,313.6) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(133.9,313.6) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(138.1,314.7) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(142.3,315.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(146.5,320.3) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(150.8,320.8) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(155.0,323.0) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(159.2,321.9) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(163.4,323.2) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(167.6,326.2) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(171.8,329.3) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(176.0,331.5) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(180.2,330.1) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(184.4,333.1) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(188.7,335.2) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(192.9,334.5) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(197.1,337.2) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(201.3,335.7) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(205.5,336.6) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(209.7,337.2) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(213.9,338.0) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(218.1,340.0) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(222.3,339.8) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(226.6,340.6) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(230.8,341.1) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(235.0,340.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(239.2,341.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(243.4,341.2) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(247.6,340.5) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(251.8,341.6) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(256.0,341.7) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(260.2,342.0) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(264.5,341.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(268.7,342.1) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(272.9,342.0) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(277.1,341.6) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(281.3,342.1) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(285.5,342.0) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(289.7,342.3) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(293.9,342.1) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(298.1,342.3) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(302.3,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(306.6,342.3) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(310.8,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(315.0,342.3) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(319.2,342.3) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(323.4,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(327.6,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(331.8,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(336.0,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(340.2,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(344.5,342.3) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(348.7,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(352.9,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(357.1,342.3) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(361.3,342.2) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(365.5,342.3) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(369.7,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(373.9,342.3) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(378.1,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(382.4,342.3) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(386.6,342.3) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(390.8,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(395.0,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(399.2,342.3) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(403.4,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(407.6,342.3) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(411.8,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(416.0,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(420.3,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(424.5,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(428.7,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(432.9,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(437.1,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(441.3,342.3) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(445.5,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(449.7,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(453.9,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(458.2,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(462.4,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(466.6,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(470.8,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(475.0,342.4) scale(4.50)' color='rgb( 0, 158, 115)'/>
<use xlink:href='#gpPt1' transform='translate(437.3,52.7) scale(4.50)' color='rgb( 0, 158, 115)'/>
</g>
</g>
<g fill="none" color="#FFFFFF" stroke="rgb( 0, 158, 115)" stroke-width="2.00" stroke-linecap="butt" stroke-linejoin="miter">
</g>
<g fill="none" color="black" stroke="currentColor" stroke-width="2.00" stroke-linecap="butt" stroke-linejoin="miter">
</g>
<g fill="none" color="black" stroke="black" stroke-width="1.00" stroke-linecap="butt" stroke-linejoin="miter">
</g>
<g fill="none" color="black" stroke="currentColor" stroke-width="1.00" stroke-linecap="butt" stroke-linejoin="miter">
<path stroke='black' d='M53.9,16.7 L53.9,342.4 L475.0,342.4 L475.0,16.7 L53.9,16.7 Z '/></g>
<g fill="none" color="black" stroke="currentColor" stroke-width="1.00" stroke-linecap="butt" stroke-linejoin="miter">
</g>
</g>
</svg>
(ns adhoc.hysteresis)
(def iterations 10000)
(defn simulate
[trip recover failure-rate]
(let [min-window (max trip recover)
;; Server up/down state over time
updown (->> (concat
;; Fake a recent history of being healthy
(repeat (dec min-window) true)
;; Lazy seq of future healthcheck results
(repeatedly iterations #(< failure-rate (rand))))
;; Chop into rolling windows of healthcheck results
(partition min-window 1)
;; Statefully map healthchecks into server in/out
(reductions
(fn new-health [in-service? window]
(if in-service?
(not (every? #(= % false) (take-last trip window)))
(every? #(= % true) (take recover window))))
;; Initial state: In service
true)
;; Drop initial service state
(rest))
;; Analysis
up-periods (count (filter identity updown))
uptime (/ up-periods iterations)]
{:updown updown
:uptime uptime
:effective-failure-rate (* uptime failure-rate)
:state-changes (count (partition-by identity updown))
;; Record settings
:iterations iterations
:trip trip
:recover recover
:failure-rate failure-rate}))
(defn report
[results]
(let [{:keys [uptime state-changes iterations effective-failure-rate]} results]
(printf "Server in service %.03f of the time with %s state changes "
(float uptime)
state-changes)
(printf "(out of %s healthcheck intervals)\n" iterations)
(printf "Effective undiluted error rate: %.03f\n"
(float effective-failure-rate))))
(comment
(doseq [failure-rate (range 0 1.001 0.01)]
(apply printf "%.02f\t%.05f\t%.05f\n"
(map float ((juxt :failure-rate :uptime :effective-failure-rate)
(simulate 2 10 failure-rate)))))
;; gnuplot -e "set terminal svg size 500,400 background rgb 'white'; set xlabel 'Server failure rate'; set xrange [0:1]; set yrange [0:1]; plot 'output.tsv' using 1:2 title 'server uptime', 'output.tsv' using 1:3 title 'effective failure rate'" > output.svg
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment