# Perfect sysctl.conf

**URL:** <https://forums.percona.com/t/perfect-sysctl-conf/934>\
**Category:** Other MySQL® Questions\
**Created:** [September 19, 2008, 11:41am UTC](https://forums.percona.com/t/perfect-sysctl-conf/934 "2008-09-19T11:41:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcusherou](https://avatars.discourse-cdn.com/v4/letter/m/a87d85/32.png) [@marcusherou](https://forums.percona.com/u/marcusherou)\
**Post date:** [September 19, 2008, 11:41am UTC](https://forums.percona.com/t/perfect-sysctl-conf/934/1 "2008-09-19T11:41:08Z")

</div>

Hi.

Been googling like crazy for sysctl tweaks which would be suitable for a loaded database system but have not found any why I’m turning to the forum.

I’ve created a quite nice sysctl.conf which I use with my lighttpd webservers but want something tweaked for databases.

I guess the vm should be tweaked in regards to overcommit etc and as well the net buffers but I’m not sure where to start.

Anyone ?

# Tcp memory

net.core.rmem\_max=16777216  
net.core.wmem\_max=16777216  
net.ipv4.tcp\_rmem=4096 87380 16777216  
net.ipv4.tcp\_wmem=4096 65536 16777216

# Increase the number of incoming connections that can queue up before dropping

net.core.somaxconn = 262144

# Big queue for the network device

net.core.netdev\_max\_backlog=30000

# Apache Scaling suggests 1000 ?

net.ipv4.tcp\_max\_orphans = 262144  
net.ipv4.tcp\_max\_syn\_backlog = 262144  
net.ipv4.tcp\_synack\_retries = 2  
net.ipv4.tcp\_syn\_retries = 2

# Lots of local ports for connections

net.ipv4.tcp\_max\_tw\_buckets = 1000000  
net.ipv4.ip\_local\_port\_range = 1024 65000  
net.ipv4.tcp\_sack = 1  
net.ipv4.tcp\_keepalive\_time = 300  
net.ipv4.tcp\_synack\_retries = 0

# These ensure that TIME\_WAIT ports either get reused or closed fast.

net.ipv4.tcp\_fin\_timeout = 1  
net.ipv4.tcp\_tw\_recycle = 1

# Security

net.ipv4.tcp\_syncookies = 1  
net.ipv4.tcp\_rfc1337 = 1

# Disables IP source routing

net.ipv4.conf.all.accept\_source\_route = 0  
net.ipv4.conf.lo.accept\_source\_route = 0  
net.ipv4.conf.eth0.accept\_source\_route = 0  
net.ipv4.conf.eth1.accept\_source\_route = 0  
net.ipv4.conf.default.accept\_source\_route = 0

# Decrease the time default value for tcp\_fin\_timeout connection

net.ipv4.tcp\_fin\_timeout = 30

# Tuning the FS

fs.file-max = 5049800

# Tuning the VM - According to [http://kb.pert.geant2.net/PERTKB/ApacheScaling](http://kb.pert.geant2.net/PERTKB/ApacheScaling)

vm.min\_free\_kbytes = 204800  
vm.page-cluster = 20

# Apache tuning suggests 200…

vm.swappiness = 10

---

<div class="post-metadata">

**Author:** ![artur8ur](https://avatars.discourse-cdn.com/v4/letter/a/9f8e36/32.png) [@artur8ur](https://forums.percona.com/u/artur8ur)\
**Post date:** [September 28, 2008, 3:05pm UTC](https://forums.percona.com/t/perfect-sysctl-conf/934/2 "2008-09-28T15:05:49Z")

</div>

| [B]Quote:[/B] |
| 

net.core.rmem\_max=16777216  
net.core.wmem\_max=16777216  
net.ipv4.tcp\_rmem=4096 87380 16777216  
net.ipv4.tcp\_wmem=4096 65536 16777216

 |

Well,.. I am not an experienced Syscontroll optimizer… but aren’t this number a little bit big?

16777216 = 16 MB,.. this is enough for a 1280 MBit/s connection with a RTT of 100ms… Just to remember, default is 128K !

| [B]Quote:[/B] |
| 
# Increase the number of incoming connections that can queue up before dropping

net.core.somaxconn = 262144

 |

When do you plan to answer the connections... if you queue so many up?

The same for the other numbers…  
The default might not be ideal, but yours a so big, i don’t know if it really help increasing performance?!?
