9 Essential Linux Server Optimization Tips for Faster, Safer Operations
This article presents nine practical Linux server optimization techniques—including time synchronization, SYN cookie activation, Squid and Nginx tuning, increasing file descriptor limits, disabling unnecessary services, turning off IPv6, enabling RHEL NIC ONBOOT, and understanding memory management—to achieve precise, stable, efficient, and secure server performance.
1. Time Synchronization
Accurate time is critical; for a mail server using Dovecot, time drift caused service stops. 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 kernel SYN cookies: echo "1" > /proc/sys/net/ipv4/tcp_syncookies Apply immediately:
/sbin/sysctl -p3. Fix Slow Squid Server
When Squid slows down, run:
netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'Adjust 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 = 5000Apply:
/sbin/sysctl -p4. Nginx Server Settings
For Nginx load balancers or Nginx+PHP5 web servers, enable:
net.ipv4.tcp_tw_reuse = 1 # reuse TIME-WAIT sockets
net.ipv4.tcp_tw_recycle = 1 # fast recycle TIME-WAIT socketsApply:
/sbin/sysctl -p5. Increase Max Open Files
Modify /etc/security/limits.conf and add:
* soft nofile 60000
* hard nofile 65535Note: ulimit -SHn or editing /etc/rc.d/rc.local cannot change the system limit.
6. Run Only Required Services
Enable essential services only, e.g.:
crond irqbalance microcode_ctl network random sshd syslogCheck services at runlevel 5:
chkconfig --list | awk '{print $1 " " $7}' | grep 5:onStop and disable unnecessary services such as cups:
service cups stop
chkconfig cups off7. Disable IPv6
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 ONBOOT
For RHEL, edit /etc/sysconfig/network-scripts/ifcfg-eth0 (or eth1) and set: ONBOOT=YES Then restart network:
service network restart9. Linux Memory Management
Linux uses available memory aggressively; it employs buffer cache and page cache to speed up disk I/O. The default behavior is generally optimal, so manual tuning is rarely needed.
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.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
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.
