Trying out the B/G Deploy feature available with Amazon Aurora
This is Oniumi (@fat47) from the Service Reliability Group (SRG) of the Technology Headquarters.
#SRG(Service Reliability Group) is a group that mainly provides cross-sectional support for the infrastructure of our media services, improving existing services, launching new ones, and contributing to OSS.
This article is located in SRGDBWGWe will publish materials regarding the database provided by the DB Working Group for the entire company.
I hope this helps in some way.
What is the B/G Deployment function?NoteB/G environment construction procedureEnable binary logging on the blue clusterCreating a Green EnvironmentTry switching between B/G while writing to the Blue environment every secondthoughtsConclusion
What is the B/G Deployment function?
This is a new feature available in RDS and Aurora that was announced at the recent Re:Invent 2022.
The documentation isHere
I think this article from Classmethod is well organized and easy to understand.
To summarize the function flow:
- You can easily create a mirror environment (Green) from the production environment (Blue) from the console.
- Logical replication is established between Blue and Green, so updates are synchronized.
- Switch from Blue to Green from the console
- The endpoint seen by the application does not need to be changed, but the destination within the endpoint changes.
- During switching, both B/G are blocked from writing.
- If the B/G switch is not completed within the specified time, it will automatically switch back.
- After the switchover, the Blue environment will remain as a standalone environment.
Image of the overall configuration
![[AWS公式ドキュメントから画像引用]](https://s3.ap-northeast-1.amazonaws.com/wraptas-prod/ca-srg/ac84cdee-b145-4a56-b2e0-a989cbd15389/48643fedde1841f1e1cb49e0023b5018.png)
Note
The following points may cause the operation to become unstable:
The case has been reported to AWS and they are investigating.
Known Issues
- If the source instance size is t3.small, the B/G environment construction stops midway.
- If the source cluster subnet is in 2AZ, the B/G environment construction stops midway.
B/G environment construction procedure
This time, we will test upgrading MySQL using B/G.
Enable binary logging on the blue cluster
Set "binlog_format" to MIXED or ROW in the DB cluster parameter group.
Please note that the instance will need to be restarted for the changes to take effect.
Creating a Green Environment
ブルー/グリーンデプロイの作成

Create it by specifying the identifier and engine version of the Green environment.

Once creation is complete, the Blue/Green notation will appear as shown below.

Try switching between B/G while writing to the Blue environment every second
Create a suitable table on the Blue side and try switching between B/G while inserting every second.
切り替え

A confirmation screen will appear displaying information for each B/G.
You can set the timeout here. If the switchover is not completed within this time,
The switch will be reverted without any change.
切り替え

A notification like this will be displayed during the switchover.

Looking at the log of the script that was writing every second during the switchover,
First, the Blue environment becomes Read Only and writes are blocked,
You can see that writing resumed about two minutes after the connection failed.
thoughts
Previously, we had to manually set up a separate cluster and set up binary log replication, but now we can do this with just one button on the console, which I thought was great.
The official announcement states that the switchover was completed within one minute, but we were unable to communicate for about two minutes, so further verification is required to determine whether this was due to the t3.medium instance being used.
Personally, I think it would be great if the B/G revert function could be enabled even after the B/G switch has been successful, because sometimes after a version upgrade, a problem is discovered and it becomes necessary to revert.
However, in that case, it would require a non-recommended replication from Aurora v3 to Aurora v2, so I think it might be difficult to achieve.
This B/G feature is now generally available, but it's marked as (Beta) on the console, so we're looking forward to seeing how it evolves in the future.
Although I did not test it this time, I think that if the restrictions on ALTER to the Green environment were relaxed, the number of situations in which it could be used would increase.
Conclusion
SRG is looking for people to work with us! If you're interested, please contact us here!