Performance Tuning Checklist
Performance Tuning Checklist
Regular performance optimization tasks:
# Optimize Apache
apache2ctl -t -D DUMP_MODULES | grep -E "(cache|deflate|expires|headers)"
apache2ctl -t -D DUMP_CONFIG | grep -E "(KeepAlive|Timeout|MaxRequestWorkers)"
# Optimize Nginx
nginx -T | grep -E "(worker_processes|worker_connections|keepalive_timeout)"
nginx -T | grep -E "(gzip|cache|limit_req)"
# System optimization
# Increase file descriptors
echo "* soft nofile 65535" >> /etc/security/limits.conf
echo "* hard nofile 65535" >> /etc/security/limits.conf
# TCP optimization
cat >> /etc/sysctl.conf << EOF
# TCP optimization
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 0
net.core.somaxconn = 65535
net.core.netdev_max_backlog = 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.ipv4.tcp_max_tw_buckets = 65535
net.ipv4.tcp_fastopen = 3
net.ipv4.tcp_slow_start_after_idle = 0
EOF
sysctl -p
Optimizing web server performance while maintaining security requires careful configuration and ongoing monitoring. The configurations in this chapter provide a foundation for high-performance, secure web servers. Regular testing and adjustment ensure your optimizations remain effective as traffic patterns and security threats evolve. The next chapter will explore log monitoring and intrusion detection to maintain visibility into both performance and security.## Log Monitoring and Intrusion Detection
Effective log monitoring and intrusion detection form the eyes and ears of your web server security infrastructure. This chapter provides comprehensive guidance on configuring logging for Apache and Nginx, implementing real-time monitoring solutions, deploying intrusion detection systems (IDS), and creating automated response mechanisms. By mastering these techniques, you'll gain deep visibility into your server's operation, detect attacks as they happen, and respond quickly to security incidents.