大网数据广告活动
服务器运维问答

How to load balance with respect to memory, disk usage, and other attributes

· 52CE 我爱测

I've found load balancers such as NGINX but those seem to work only by keeping in mind CPU usage and network traffic. How would I load balance with respect to other variables such as the amount of disk available at each node, or …

问题原文

原帖链接 · user3325789 · CC BY-SA 3.0

I've found load balancers such as NGINX but those seem to work only by keeping in mind CPU usage and network traffic. How would I load balance with respect to other variables such as the amount of disk available at each node, or the amount of memory available?

Would I have to write my own request handling service in order to take advantage of those variables when deciding which node to send the request to?

This is my use case, I am building a distributed filesystem for erasure codes and would like the load balancer to send a write of a file to node that can handle the traffic, CPU load, has sufficient disk for the IO operation and has sufficient memory for the expected operation. As I understand, having a load balancer can only tackle the traffic and the CPU portions but how would I further augment the requirements of the load balancer?

Thank you for helping with my first question.

社区高分解答

原帖链接 · GregL · CC BY-SA 3.0

Rob-d mentions that load-balancers must perform health checks on the backend servers to ensure they're healthy and can serve requests. This is absolutely true and I think it's what would enable you to do what you want (checking other metrics and having the LB make routing choices based on those).

Assuming you're load-balancing HTTP, most load-balancers will perform an HTTP GET or HEAD to a certain page to check their status as a viable backend. This page could be a static image, a CSS file, or even an HTML page.

But it could also be a PHP/ASP/Java/Python page. Some might argue that it should even be a page that can perform some sort of sanity check on your application's stack (SQL, NoSQL, helper services, etc..).

There's no reason you couldn't write a script which implements your complex load-balancing algorithm, and simply returns an HTTP/1.1 200 OK, or HTTP/1.1 503 Service Unavailable depending on whether or not the server is able to serve requests.

I know of at least one load-balancer that can perform a secondary agent-check, which is able to return more details than simply UP/DOWN, allowing a server's weight to be dynamically changed at configured intervals based on anything the server's agent decides. I think this would be exactly what you're looking for.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-04-21)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。