文档

定时升级Redis实例临时带宽

更新时间:

功能背景

在数据驱动的现代业务环境中,Redis以其卓越的性能和灵活性,已成为众多企业关键基础设施的重要组成部分。Redis广泛应用于处理缓存、会话管理、消息队列等多种数据密集型和响应敏感型的场景,对业务连续性和用户体验贡献巨大。然而,每当企业遇到大规模的营销活动、产品上市或其他预定的高流量事件时,原有的带宽配置可能面临巨大的挑战。在这些关键时刻,即使是微小的延迟也可能对企业造成不利的市场影响和用户留存损失。

为解决上述问题,系统运维管理OOS推出了定时升级Redis临时带宽的功能(您还可以通过OOS对带宽临时升级定时升级EIP实例临时带宽进行临时带宽升级),这一功能使得您能够根据业务负载预测,提前规划并实施带宽的定时升级,从而保障关键时刻应用的性能和稳定性,同时优化成本。

关键特性

  • 定时触发:用户可根据业务需求预设特定日期和时间,实现带宽的自动升级。

  • 自动回退:在设定的时长结束后,带宽自动恢复至原定标准,有效避免非高峰期的成本浪费。

  • 成本优化:通过只在需要时升级带宽,帮助企业在保证服务质量的同时,显著降低运营成本。

  • 简洁操作:用户友好的界面设计,仅需几步操作即可轻松完成带宽升级的设置。

应用场景

  • 电商平台促销活动:在大促销活动期间预设带宽升级,应对用户访问量激增的挑战。

  • 大型游戏更新:在游戏发布新版本或大型更新时升级带宽,保证玩家下载体验。

  • 节假日流量高峰:针对节假日期间可能出现的访问高峰,事先安排带宽提升。

  • 数据密集型任务执行:在进行大规模数据迁移或分析作业时,临时增加带宽,加快任务完成速度。

操作步骤

  1. 登录OOS控制台

  2. 在左侧导航栏找到“自动化任务-公共任务模板”,搜索"ACS-Redis-ScheduleToUpgradeInstanceBandwidth",点击创建执行。

image.png

  1. 点击下一步:设置参数,选择定时类型。

这里定时类型有“立即执行、仅在指定时间执行一次、周期性重复执行”三种方式。其中“立即执行”会在创建任务后立即进行重启操作,“仅在指定时间执行一次”只会在您设定的某个时间点执行一次,“周期性重复执行”则会安装一定的规则重复执行,如每一小时执行一次。image.png

  1. 设置Redis实例所在地域, 通过手动选择实例、指定实例标签、指定实例资源组、上传CSV文件、选择全部几种方式选择您要操作的目标Redis实例、填写需要增加的带宽值带宽升级时间(最少1小时),选择一个具有Redis权限的角色,点击确定-创建,此时定时升级Redis临时带宽的任务就创建完成了,当到达设定的时间后就会自动对Redis带宽进行升级,并且在持续设定的时间后降低到原有带宽。

image.png

附录

执行流程图

整体执行流程图:

image.png

其中升级EIP实例带宽流程

image.png

模板

上述步骤中使用的模板“ACS-Redis-ScheduleToUpgradeInstanceBandwidth”内容如下(模板链接):

FormatVersion: OOS-2019-06-01
Description:
  en: Scheduled upgrade of the temporary bandwidth of a Redis instance
  zh-cn: 定时升级Redis实例临时带宽
  name-en: ACS-Redis-ScheduleToUpgradeInstanceBandwidth
  name-zh-cn: 定时升级Redis实例临时带宽
Parameters:
  RegionId:
    Type: String
    Label:
      en: RegionId
      zh-cn: 地域ID
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  Targets:
    Type: Json
    Label:
      en: TargetInstance
      zh-cn: 目标实例
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: ALIYUN::Redis::Instance
      RegionId: regionId
  TimerTrigger:
    Type: Json
    Label:
      en: TimerTrigger
      zh-cn: 定时类型
    AssociationProperty: ALIYUN::OOS::Component::TimerTrigger
    AssociationPropertyMetadata:
      MinuteInterval: 30
  Bandwidth:
    Type: Number
    Label:
      en: Bandwidth
      zh-cn: 要增加的带宽
    Description:
      en: Unit:MB/s. The maximum incoming bandwidth is 6 times the default bandwidth of this instance specification, but the upper limit is 192MB/s. For example, the default bandwidth of an instance is 10 MB/s, and the value range of this parameter is 0~60.
      zh-cn: 单位:MB/s。最大可传入该实例规格默认带宽的 6 倍,但上限为 192MB/s。例如实例默认带宽为 10 MB/s,本参数的取值范围为 0~60。
    MinValue: 1
    MaxValue: 192
  DurationHour:
    Label:
      en: DurationHour
      zh-cn: 带宽升级持续时间
    Description:
      zh-cn: 单位:小时。持续时间最少1小时
      en: Unit:Hour. The bandwidth upgrade should last at least 1 hours
    Type: Number
    MinValue: 1
    Default: 1
  RateControl:
    Label:
      en: RateControl
      zh-cn: 任务执行的并发比率
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 10
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: OOS扮演的RAM角色
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: TimerTrigger
    Action: ACS::TimerTrigger
    Description:
      en: Triggers a task as scheduled by specifying type and expression
      zh-cn: 通过指定触发类型和表达式按计划触发任务
    Properties:
      Type:
        Fn::Select:
          - type
          - '{{ TimerTrigger }}'
      Expression:
        Fn::Select:
          - expression
          - '{{ TimerTrigger }}'
      EndDate:
        Fn::Select:
          - endDate
          - '{{ TimerTrigger }}'
      TimeZone:
        Fn::Select:
          - timeZone
          - '{{ TimerTrigger }}'
  - Name: GetInstance
    Description:
      en: Get the redis instances
      zh-cn: 获取Redis实例
    Action: ACS::SelectTargets
    Properties:
      ResourceType: ALIYUN::Redis::Instance
      RegionId: '{{ RegionId }}'
      Filters:
        - '{{ Targets }}'
    Outputs:
      InstanceIds:
        Type: List
        ValueSelector: Instances.Instance[].InstanceId
  - Name: UpgradeRedisInstanceBandwidth
    Action: ACS::Redis::UpgradeRedisInstanceBandwidth
    Description:
      en: Modify redis instance bandwidth
      zh-cn: 调整Redis实例的带宽
    Properties:
      RegionId: '{{ RegionId }}'
      InstanceId: '{{ ACS::TaskLoopItem }}'
      Bandwidth: '{{ Bandwidth }}'
      DurationHour: '{{ DurationHour }}'
    Loop:
      RateControl: '{{ RateControl }}'
      Items: '{{ GetInstance.InstanceIds }}'
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - TimerTrigger
        Label:
          default:
            zh-cn: 定时设置
            en: Timer Trigger Configure
      - Parameters:
          - RegionId
          - Targets
          - Bandwidth
          - DurationHour
        Label:
          default:
            zh-cn: 选择实例
            en: Select Instances
      - Parameters:
          - RateControl
          - OOSAssumeRole
        Label:
          default:
            zh-cn: 高级选项
            en: Control Options

其中Action: ACS::Redis::UpgradeRedisInstanceBandwidth内容如下:

FormatVersion: OOS-2019-06-01
Description:
  en: Upgrade of the temporary bandwidth of a Redis instance
  zh-cn: 升级Redis实例临时带宽
  name-en: ACS::Redis::UpgradeRedisInstanceBandwidth
  name-zh-cn: 升级Redis实例临时带宽
Parameters:
  RegionId:
    Type: String
    Label:
      en: RegionId
      zh-cn: 地域ID
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  InstanceId:
    Type: String
    Label:
      en: InstanceId
      zh-cn: Redis实例ID
  Bandwidth:
    Type: Number
    Label:
      en: Bandwidth
      zh-cn: 要增加的带宽
    Description:
      en: Unit:MB/s. The maximum incoming bandwidth is 6 times the default bandwidth of this instance specification, but the upper limit is 192MB/s. For example, the default bandwidth of an instance is 10 MB/s, and the value range of this parameter is 0~60.
      zh-cn: 单位:MB/s。最大可传入该实例规格默认带宽的 6 倍,但上限为 192MB/s。例如实例默认带宽为 10 MB/s,本参数的取值范围为 0~60。
    MinValue: 1
    MaxValue: 192
  DurationHour:
    Label:
      en: DurationHour
      zh-cn: 带宽升级持续时间
    Description:
      zh-cn: 单位:小时。持续时间最少1小时
      en: Unit:Hour. The bandwidth upgrade should last at least 1 hours
    Type: Number
    MinValue: 1
    Default: 1
Tasks:
  - Name: UpgradeRedisInstanceBandwidth
    Action: ACS::ExecuteApi
    Description:
      en: Upgrade redis instance bandwidth
      zh-cn: 升级Redis实例的带宽
    Properties:
      Service: r-kvstore
      API: EnableAdditionalBandwidth
      Parameters:
        RegionId: '{{ RegionId }}'
        InstanceId: '{{ InstanceId }}'
        Bandwidth: '{{ Bandwidth }}'
        AutoPay: true
  - Name: DurationHour
    Action: ACS::Sleep
    Description:
      en: Bandwidth upgrade duration
      zh-cn: 带宽升级持续时间
    Properties:
      Duration: '{{ DurationHour }}H'
  - Name: RecoverRedisInstanceBandwidth
    Action: ACS::ExecuteAPI
    Description:
      en: Recover redis instance bandwidth
      zh-cn: 恢复redis实例的带宽
    Properties:
      Service: r-kvstore
      API: EnableAdditionalBandwidth
      Parameters:
        RegionId: '{{ RegionId }}'
        InstanceId: '{{ InstanceId }}'
        Bandwidth: 0
        AutoPay: true
  • 本页导读