9 Essential Linux Server Optimization Tips for Faster, Safer Operations
This guide presents nine practical Linux server optimization techniques—including time synchronization, SYN‑cookie protection, Squid and Nginx tuning, file‑descriptor limits, service minimization, IPv6 disabling, NIC activation, and memory‑management insights—to boost precision, stability, performance, and security.
1. Time Synchronization
Accurate time is critical for Linux servers; Dovecot may stop if the clock drifts. Edit /etc/crontab and add a daily NTP sync:
14 04 * * * root /usr/sbin/ntpdate ntp.api.bz > /dev/null 2>&12. Enable SYN Cookie Protection
Activate SYN cookies to mitigate SYN‑flood attacks: echo "1" > /proc/sys/net/ipv4/tcp_syncookies Apply the change immediately:
/sbin/sysctl -p3. Squid Server Slowdown Fix
When a Squid cache server becomes sluggish, first inspect connections:
netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'Then tune kernel parameters in /etc/sysctl.conf:
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_max_tw_buckets = 5000Explanation: tcp_tw_reuse reuses TIME‑WAIT sockets; tcp_tw_recycle recycles them quickly; tcp_fin_timeout shortens FIN‑WAIT‑2; tcp_keepalive_time reduces keepalive interval; ip_local_port_range expands outbound ports; tcp_max_syn_backlog enlarges the SYN queue; tcp_max_tw_buckets caps TIME‑WAIT sockets.
Apply the new settings:
/sbin/sysctl -p4. Nginx Server Settings
For Nginx load balancers or Nginx+PHP5 web servers, enable the same TIME‑WAIT optimizations:
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1Then run:
/sbin/sysctl -p5. Increase Maximum Open Files
Default file‑descriptor limits are low for high‑load services. Edit /etc/security/limits.conf and add:
* soft nofile 60000
* hard nofile 65535Note: using ulimit -SHn or editing /etc/rc.d/rc.local will not change the system limit.
6. Run Only Required Services
Disable unnecessary daemons and keep only essential ones such as:
crond, irqbalance, microcode_ctl, network, random, sshd, syslog.
iptables can be disabled if a hardware firewall is present. List services at runlevel 5: chkconfig --list | awk '{print $1 " " $7}' | grep 5:on Stop and disable unwanted services, e.g.:
service cups stop
chkconfig cups off7. Disable IPv6
Most production CentOS 64‑bit servers do not use IPv6. To turn it off, edit /etc/modprobe.conf and append:
alias net-pf-10 off
alias ipv6 off
echo "IPV6INIT=no" >> /etc/sysconfig/network-scripts/ifcfg-eth08. Enable RHEL NIC Activation (ONBOOT)
For RHEL systems, ensure network interfaces start on boot. Edit /etc/sysconfig/network-scripts/ifcfg-eth0 (and ifcfg‑eth1 for a second NIC) and set: ONBOOT=YES Restart the network service to apply:
service network restart9. Linux Memory Management
Linux uses available memory aggressively; free memory is often low because caches are active. The kernel employs dentry cache, Buffer Cache, and Page Cache to speed up I/O. No special tuning is required—let the system manage memory naturally.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
