Skip to content

Instantly share code, notes, and snippets.

@shadyabhi
Created September 27, 2023 22:12
Show Gist options
  • Select an option

  • Save shadyabhi/fc511449600092364b08e58e2b07079f to your computer and use it in GitHub Desktop.

Select an option

Save shadyabhi/fc511449600092364b08e58e2b07079f to your computer and use it in GitHub Desktop.
HAproxy sessions experiment, what does it really mean?
global
stats socket /tmp/haproxy.sock
frontend stats
mode http
bind *:8081
stats enable
stats uri /stats
stats refresh 1s
frontend http
mode http
bind :::8080
default_backend default_backend
backend default_backend
balance roundrobin
mode http
server rgw1 localhost:8090 check
@shadyabhi
Copy link
Author

Backend code that supports keep-alive.

package main

import (
        "fmt"
        "net/http"
)


func main() {
        http.HandleFunc("/hello", func(w http.ResponseWriter, req *http.Request) {
                fmt.Fprintf(w, "hello\n")
        })
        http.ListenAndServe(":8090", nil)
}

@shadyabhi
Copy link
Author

hey command to test connections and status codes:-

hey -z 100s -c 1 -q 1 http://localhost:8080/hello
  • -z 100s: Run for 100s
  • -c 1: Only one TCP connection
  • -q 1: Rate limit HTTP transactions to 1 per second.

@shadyabhi
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment