Operations 8 min read

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.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
9 Essential Linux Server Optimization Tips for Faster, Safer Operations

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>&1

2. 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 -p

3. 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 = 5000

Explanation: 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 -p

4. 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 = 1

Then run:

/sbin/sysctl -p

5. 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 65535

Note: 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 off

7. 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-eth0

8. 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 restart

9. 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.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

networkperformance tuningLinuxSysadminserver optimizationKernel Parameters
MaGe Linux Operations
Written by

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.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.