title: Using Haproxy to delay data flow to Postgres database
body: <p>I'm trying to delay traffic between an application and my Postgres database to test how the application deals with latency. I decided to use a HAproxy in the middle and introduced a tcp delay on the requests with the below config. Its only delaying the initial connections though and everything using that connection is not being delayed.</p>
  <p>All the applications use a Hikari pool which basically opens up X amount of connections when the app starts. Once it initializes the DB connection it keeps them in the cache pool and whenever application needs to query DB it gets a connection from the pool and uses that to talk to the DB.</p>
  <p>So basically all my configuration is doing is adding a delay when a new connection is requested. Its not going to delay my applications talking to the database. Does anyone know if what I am trying to achieve is possible with haproxy or with something else?</p>
  <pre><code>global
  log /dev/log local0
  
  defaults
  log global
  option tcplog
  mode tcp
  timeout client 10s
  timeout connect 10s
  timeout server 10s
  timeout check 5s
  
  frontend postgresDB
  bind *:5432
  tcp-request inspect-delay 5000ms
  tcp-request content accept if WAIT_END
  mode tcp
  log global
  option tcplog
  default_backend postgresDB
  
  backend postgresDB
  mode tcp
  server pdb 172.18.29.133:5432  check inter 5s rise 2 fall 3
  </code></pre>