0

On Db2 v11.5.8.0 Linux x86_64 database every few months some application opens up a lot of connections and it free them up pretty quickly like in 10 mins.

I assume it has to be fat client application from Windows, because for WAS applications number of connections are restricted at application server level.

Checking high water mark I get:

db2 get snapshot for dbm | grep "High water mark for agents registered"

High water mark for agents registered = 4296

What is the best way to limit number of connections by (unknown) IP address? For example I want to restrict maximum number of connection from particular IP address to 100 connections. Bear in mind that I don't know the IP address, it can be any.

1
  • I don't know of any way to do this within Db2, but it should be possible to do in your firewall. Something like: iptables -A INPUT -p tcp --syn --dport 50000 -m connlimit --connlimit-above 15 --connlimit-mask 32 -j REJECT --reject-with tcp-reset Jan 5, 2023 at 8:29

1 Answer 1

3

You may use so called connect procedure for this.

--#SET TERMINATOR @
CREATE PROCEDURE MYSCHEMA.CONN_PROC ()
BEGIN
  IF 
    (
    SELECT COUNT (1) 
    FROM TABLE (MON_GET_CONNECTION (NULL, -2)) 
    WHERE CLIENT_IPADDR = SYSIBM.CLIENT_IPADDR
    ) > 100 
  THEN
    SIGNAL SQLSTATE '75000' 
      SET MESSAGE_TEXT = 'Too many connections from the same IP';
  END IF;
END
@

GRANT EXECUTE ON PROCEDURE MYSCHEMA.CONN_PROC TO PUBLIC@

UPDATE DB CFG USING CONNECT_PROC MYSCHEMA.CONN_PROC@
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.