Problem:
The client reported issues with Keepalived crashes leading to high availability disruptions and application errors, particularly connection timeouts with the PostgreSQL server. Initial investigations revealed suspicions of network instability and outdated software versions contributing to the problem.
Process:
- Requesting initial information for further investigation of the problem
- The number of servers in the HAProxy and Keepalived pool.
- HAProxy and Keepalived configurations from all servers.
- Full, unfiltered /var/log/messages files from all servers.
- “dmesg” logs from all servers.
- Details on the deployment of HAProxy, Keepalived, and Postgres.
- “iptables” configurations from all servers.
- Screenshots or instructions for enabling HAProxy admin.
- Installation and running of dstat utility on all servers.
- A code snippet to enable HAProxy admin interface.
- Investigation of Network Issues
The process began with suspecting network issues causing intermittent problems with an application hosted on different VMs. The team checked the network interfaces for errors using commands like “ip -a” and “ifconfig <interface>”. Additionally, the logs for connections from backend servers were examined to correlate them with application failures.
- Troubleshooting Keepalived Version 2.1.5.
The analysis then focused on Keepalived version 2.1.5, identified as an older version causing timer expiration issues leading to split brain scenarios. The expert recommended upgrading Keepalived to a stable version (2.2.8) due to the issues found. A GitHub issue (https://github.com/acassen/keepalived/issues/2066) was referenced to provide further context and potential solutions for the timer expiration problem.
- System Configuration Review
There was an emphasis on reviewing system configurations, including parameters related specifically to Keepalived. As for default parameters, Keepalived doesn’t typically require much tuning due to its simple VRRP protocol running over IP.
- Bug Impact and Resolution
It was supposed that a bug in the Keepalived system was causing the issue. It was recommended to update Keepalived as a temporary fix and suggested upgrading HAproxy to version 2.6 for better stability. Restarting the system was considered as a quick workaround, but it could impact existing connections; changing VM options was another way to alleviate the issue with the older Keepalived version.
- System Compatibility and Recommendations
Upgrading HAProxy to version 2.6 was recommended due to security issues with the current version. Addressing minor issues related to OS updates was also emphasized.
- Impact of Restarting Services
The analysis covered how restarting services would impact existing connections, particularly at the database level, including active connections, transactional workloads, and connection pools on the application and database sides.
Solution:
Keepalived and HAProxy Upgrades:
The client proceeded with the upgrade of Keepalived to the latest stable version, addressing timer expiration issues and improving the overall stability of the high availability configuration. Simultaneously, HAProxy was migrated to version 2.6, mitigating security risks and leveraging performance optimizations to enhance load balancing capabilities.
Network and System Configuration Optimization:
Configuration adjustments were implemented based on the recommendations to optimize network settings, CPU and memory allocation, and load balancing algorithms. These optimizations aimed to improve resource utilization, reduce latency, and enhance the overall resilience of the infrastructure.
VM Snapshot Adjustments:
Changes were made to the snapshot schedules for affected virtual machines to minimize the impact on system performance and prevent potential freezes during snapshot operations. Staggered snapshot schedules were introduced to distribute resource-intensive tasks more evenly, ensuring smoother operation and mitigating risks associated with snapshot-related disruptions.
Conclusion:
The collaborative efforts and thorough analysis undertaken have successfully identified and addressed the root causes of Keepalived crashes and application errors. By proposing adjustments to the VM snapshot schedule and exploring hypervisor-level backup mechanisms, we have laid a foundation for enhancing system stability and preventing future disruptions. Continued vigilance and adherence to recommended best practices will be essential in ensuring sustained system reliability and performance.