Last active
July 19, 2021 13:56
-
-
Save holly/a2ffe258d65c0c9735f82a987087902a to your computer and use it in GitHub Desktop.
sysctl tuning
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #net.ipv4.ip_forward = 1 | |
| #net.ipv4.conf.all.forwarding=1 | |
| net.ipv6.conf.all.disable_ipv6=1 | |
| net.ipv6.conf.default.disable_ipv6=1 | |
| net.ipv6.conf.lo.disable_ipv6=1 | |
| # 共有メモリの最大サイズ。サーバーの搭載メモリ(1GB)に合わせて変更 | |
| ##kernel.shmmax = 1073741824 | |
| # システム全体の共有メモリ・ページの最大数 | |
| ##kernel.shmall = 262144 | |
| # システム全体のプロセス数の上限 | |
| # https://qiita.com/opuntia/items/9df5ec6865a51ef8f3cd tuningしない方向で | |
| # kernel.threads-max = 1060863 | |
| # システム全体のファイルディスクリプタの上限 | |
| ##fs.file-max = 5242880 | |
| # RFC1323のTCPウィンドウ スケーリングを有効にする。 | |
| # 64K以上のTCP windowを使えるようになる。 | |
| # 巨大なファイルを転送する時に問題になった場合は無効にすると解決されることもある。 | |
| net.ipv4.tcp_window_scaling = 1 | |
| # 受信用ウィンドウ・サイズの最大値。 | |
| net.core.rmem_max = 16777216 | |
| # 送信用ウィンドウ・サイズの最大値。 | |
| net.core.wmem_max = 16777216 | |
| # データ受信バッファ サイズ | |
| net.ipv4.tcp_rmem = 4096 349520 16777216 | |
| # データ送信バッファ サイズ | |
| net.ipv4.tcp_wmem = 4096 65536 16777216 | |
| # ESTABLISHEDのリストの最大数(OS側の管理数) ubuntu20から無くなっている | |
| ##net.nf_conntrack_max = 1053616 | |
| # RFC1337に準拠させる。 | |
| # TIME_WAIT状態のときにRSTを受信した場合、TIME_WAIT期間の終了を待たずにそのソケットをクローズする | |
| net.ipv4.tcp_rfc1337=1 | |
| # FIN-WAIT2からTIME_WAITに遷移する時間の設定(秒) | |
| net.ipv4.tcp_fin_timeout=10 | |
| # TIME_OUT 状態のコネクションを再利用。tcp_tw_recycleは廃止 | |
| net.ipv4.tcp_tw_reuse=1 | |
| # NAT下でのソケット再利用時の問題などがあるので0にしておくのが吉 | |
| net.ipv4.tcp_timestamps=0 | |
| #tcpのSYNを送信するリトライ回数。この回数SYNを送ってもダメなら諦める | |
| net.ipv4.tcp_syn_retries = 3 | |
| # 接続を受付側としてオープンするとき、 カーネルは SYN に ACK を詰め込んで送り、先に受けとった SYN を確認する | |
| net.ipv4.tcp_synack_retries = 3 | |
| # CLOSE_WAITを減らす対策 | |
| # アイドル接続状態のTCP接続に対し検査する頻度 | |
| net.ipv4.tcp_keepalive_time=10 | |
| # TCP/IP が、既存の接続で応答されていないキープアライブ・メッセージを再送する回数 | |
| net.ipv4.tcp_keepalive_probes = 2 | |
| # 相手側からのキープアライブ応答から受信されない場合に、TCP/IP がキープアライブ送信を繰り返す頻度 | |
| net.ipv4.tcp_keepalive_intvl = 3 | |
| #こちらからクローズしたTCPコネクションを終了する前の再送回数。 | |
| #webサーバだとリソースを消費する可能性があるため、低くしたほうが良い | |
| net.ipv4.tcp_orphan_retries = 0 | |
| #システムが同時に保持するtime-waitソケットの最大数。DoS攻撃を防げるため、低くするのはやめたほうが良い | |
| net.ipv4.tcp_max_tw_buckets = 2000000 | |
| # TCP/IPの送信用ポート範囲の変更 | |
| net.ipv4.ip_local_port_range = 1024 65535 | |
| # SYN flood攻撃対策 | |
| net.ipv4.tcp_syncookies = 1 | |
| # TCPソケットが受け付けた接続要求を格納するキューの最大長 | |
| net.core.somaxconn=65535 | |
| # カーネルがキューイング可能なパケットの最大個数 | |
| net.core.netdev_max_backlog=8192 | |
| # ソケット当たりのSYNを受け付けてACKを受け取っていない状態のコネクションの保持可能数 | |
| net.ipv4.tcp_max_syn_backlog=4096 | |
| # ネットワークのルート・メトリクスの保持を無効化する。 | |
| net.ipv4.tcp_no_metrics_save=1 | |
| # スプーフィング対策 送信元IPの偽装防止 | |
| net.ipv4.conf.all.rp_filter = 1 | |
| # 現代的設定:1 極力swapしない | |
| vm.swappiness=1 | |
| # メモリオーバーコミットを無効 | |
| #vm.overcommit_memory = 2 | |
| # mallocにより確保するメモリ量の上限(%)を指定 | |
| #vm.overcommit_ratio = 99 | |
| # HugePage数。1ページ2048KBでシステムで必要な容量を見積もる | |
| vm.nr_hugepages = 200 | |
| # pthread は 1スレッドあたり、2つのメモリマップを必要とするようです。 | |
| # 1つのプロセスで使えるメモリマップの数には上限があります。 | |
| vm.max_map_count = 200000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment