阿里云(一)云服务器ESC——负载均衡

携手创作,共同成长!这是我参与「掘金日新计划 · 8 月更文挑战」的第1天,点击查看活动详情

正常来看的情况下,一台云服务器能做的事情是有上限的,如果请求量特别高的情况下,我们一般都会配置负载均衡来解决这个问题。

自己配置服务器的负载均衡,请移步《nginx(一)nginx配置反向代理与负载均衡》这里我大概记录了一下自己配置负载均衡的过程。

这里主要介绍一下,阿里云为我们提供的负载均衡的配置流程。

一:ESC示例

首先,我们至少需要有两台以上的ESC云服务器。以供负载均衡实例转发请求使用。

二:创建SLB负载均衡实例

1:登录阿里云账号,点击控制台,点击负载均衡,如下图所示:

1.png

2:进入负载均衡管理平台,点击示例,看到创建负载均衡按钮。

2.png

3:进入创建页面

在选择创建地域的时候请注意,负载均衡不支持跨地域使用,因此负载均衡示例要与ESC云服务器示例在同一地域,剩下的信息,按你自己的需求填写。

3.png

4:负载均衡实例创建成功(图片仅做参考,实际上我使用的是下边的传统型负载均衡)

4.png

其余的部分,我这里就不做截图展示了。

大概就是,创建监听规则,创建过程中会让你选择服务器组(就是这个规则要监听哪几台服务器)。

没有服务器组则按照引导创建,将你想要使用的服务器添加至服务器组中。

我这里创建两个index.html文件: index.html:

<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

index.html:

<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!8.140</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

最后,访问负载均衡实例的公网IP即可得到下图所示的结果:

5.png

6.png

当然,我这里只是单纯的创建和配置演示,具体在实际使用过程中,还会遇到一些很实际的问题,比如,我们需要将同一IP段访问的请求转发至同一台服务器上,避免SESSION失效等问题。

这些问题具体的解决及配置方法后面会说到。

更多详情请参考阿里云文档:

help.aliyun.com/document_de…

有好的建议,请在下方输入你的评论。

欢迎访问个人博客 guanchao.site

欢迎访问我的小程序:打开微信->发现->小程序->搜索“时间里的”

猜你喜欢

转载自juejin.im/post/7124815699339395079