How can we create TCP connection with a droplet more than 2000

Iam not able to create TCP(MQTT) connections above 50K with EMQX on a droplet. It is a Ubuntu 22.04 (LTS) x64, Can any one help fix this VM.

I have configured the droplet with the following:

sysctl -w net.ipv4.tcp_max_tw_buckets=1048576
sysctl -w net.ipv4.tcp_fin_timeout=30
sysctl -w net.core.netdev_max_backlog=16384
sysctl -w net.core.rmem_default=262144
sysctl -w net.core.wmem_default=262144
sysctl -w net.core.rmem_max=16777216
sysctl -w net.core.wmem_max=16777216
sysctl -w net.core.optmem_max=16777216
sysctl -w net.ipv4.ip_local_port_range="1024 65534"
sysctl -w fs.file-max=2097152
sysctl -w fs.nr_open=2097152
sysctl -w net.core.somaxconn=32768
sysctl -w net.ipv4.tcp_max_syn_backlog=16384
sysctl -w net.ipv4.tcp_rmem='1024 4096 16777216'
sysctl -w net.ipv4.tcp_wmem='1024 4096 16777216'
sysctl net.ipv4.netfilter.ip_conntrack_max
sysctl -w net.ipv4.netfilter.ip_conntrack_max=1048576
sysctl -w net.core.netdev_max_backlog=200000
sysctl -w net.ipv4.tcp_max_syn_backlog=200000

Configured files

  1. /etc/sysctl.conf
fs.file-max = 262144
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 12582912 16777216
net.ipv4.tcp_wmem = 4096 12582912 16777216
net.ipv4.ip_local_port_range = 1024 65534
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 4096
net.core.somaxconn = 8192
net.ipv4.tcp_fin_timeout = 30
net.core.netdev_max_backlog = 200000
net.ipv4.tcp_max_syn_backlog = 204800
net.core.netdev_max_backlog = 5000
net.netfilter.nf_conntrack_max = 1048576
net.nf_conntrack_max = 1048576
  1. /etc/security/limits.conf
*      soft   nofile      262144
*      hard   nofile      262144
*      soft   nproc       65535
*      hard   nproc       65535
root    hard   nofile      500000
root    soft   nofile      500000
  1. /etc/systemd/system.conf

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I was able to Make 50K tcp connections when i tried connecting to Emqx from the same droplet.But not able to make the connections from external machine. can any one let me know if there is any firewall setting that has to be changed

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel