{"action":"opened","issue":{"url":"https://api.github.com/repos/ZHHBeHappy/Learn-Spring/issues/16","repository_url":"https://api.github.com/repos/ZHHBeHappy/Learn-Spring","labels_url":"https://api.github.com/repos/ZHHBeHappy/Learn-Spring/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/ZHHBeHappy/Learn-Spring/issues/16/comments","events_url":"https://api.github.com/repos/ZHHBeHappy/Learn-Spring/issues/16/events","html_url":"https://github.com/ZHHBeHappy/Learn-Spring/issues/16","id":358062171,"node_id":"MDU6SXNzdWUzNTgwNjIxNzE=","number":16,"title":"Ngnix的负载均衡策略","user":{"login":"ZHHBeHappy","id":28640351,"node_id":"MDQ6VXNlcjI4NjQwMzUx","avatar_url":"https://avatars3.githubusercontent.com/u/28640351?v=4","gravatar_id":"","url":"https://api.github.com/users/ZHHBeHappy","html_url":"https://github.com/ZHHBeHappy","followers_url":"https://api.github.com/users/ZHHBeHappy/followers","following_url":"https://api.github.com/users/ZHHBeHappy/following{/other_user}","gists_url":"https://api.github.com/users/ZHHBeHappy/gists{/gist_id}","starred_url":"https://api.github.com/users/ZHHBeHappy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ZHHBeHappy/subscriptions","organizations_url":"https://api.github.com/users/ZHHBeHappy/orgs","repos_url":"https://api.github.com/users/ZHHBeHappy/repos","events_url":"https://api.github.com/users/ZHHBeHappy/events{/privacy}","received_events_url":"https://api.github.com/users/ZHHBeHappy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-07T13:13:53Z","updated_at":"2018-09-07T13:13:53Z","closed_at":null,"author_association":"OWNER","body":":pencil: Problem\r\n\r\n- ngnix所采用的几种负载均衡策略\r\n\r\n:pill: Solution\r\n\r\n**轮询**\r\n\r\n- 每个请求按照时间顺序依次分配给后台的服务器，如果服务器down掉了，能自动剔除；\r\n- 虽然这种方式简便、成本低廉。但缺点是：可靠性低和负载分配不均衡。适用于图片服务器集群和纯静态页面服务器集群。\r\n\r\n**权重（weight）**\r\n\r\n- 指定每隔服务器被轮询的几率。用于后端服务器性能不均的情况。\r\n\r\n**哈希（ip_hash）**\r\n\r\n- （一致性hash）每个请求按照访问 ip 的 hash 结果分配，这样每个客户端可以访问唯一的后端服务器。一定程度上解决session共享问题。\r\n- 分布式的session共享可以使用redis集群。\r\n\r\n**公平（fair）**\r\n\r\n- 按照后端服务器的响应时间分配请求。响应时间短的优先分配。\r\n- 需要第三方插件\r\n\r\n**URL哈希（url_hash）**\r\n\r\n- 按访问url的hash结果来分配请求，使每个url定向到同一个后端服务器，后端服务器为缓存时比较有效。\r\n- 需要第三方插件\r\n\r\n:four_leaf_clover: Summary\r\n"}}
{"actor":{"display_login":"ZHHBeHappy"}}