15I. ElastiCache Redis ํด๋ฌ์คํฐ Read Replica ์์ฑํ๊ธฐ
15I. ElastiCache Redis ํด๋ฌ์คํฐ Read Replica ์์ฑํ๊ธฐ ๊ด๋ จ

.Redis ํด๋ฌ์คํฐ์ Read Replica๋ฅผ ์์ฑํ์ฌ ์ฝ๊ธฐ ์ฑ๋ฅ์ ๋์ด๊ณ , ์ฅ์ ์ ์๋์ผ๋ก ๋์ฒํ๋ Failover ๊ธฐ๋ฅ์ ์ฌ์ฉํ ์ ์์ต๋๋ค. ์๋น์ค์์ ์ฝ๊ธฐ ์์ฃผ์ ์์ ์ด ๋ง์ ๊ฒฝ์ฐ Read Replica๋ฅผ ์ฌ๋ฌ ๊ฐ(์ต๋ 5๊ฐ) ๋ง๋ค์ด ๋ถํ๋ฅผ ๋ถ์ฐ์ํฌ ์ ์์ต๋๋ค. ์ฆ ์ฐ๊ธฐ ์์ ์ ๋ง์คํฐ ์บ์ ๋ ธ๋์ ํ๊ณ ์ฝ๊ธฐ ์์ ์ Read Replica์ธ ์ฌ๋ ์ด๋ธ ์บ์ ๋ ธ๋์์ ์ค์ํ๋ค๋ฉด ๋ง์คํฐ ์บ์ ๋ ธ๋์ ๋ถํ๋ฅผ ์ค์ผ ์ ์์ต๋๋ค.
๋ง์คํฐ ์บ์ ๋ ธ๋์ ์ฐ๊ธฐ๋ฅผ ํ๋ฉด ์๋์ผ๋ก ์ฌ๋ ์ด๋ธ ์บ์ ๋ ธ๋๋ก ๋ฐ์ดํฐ๊ฐ ๋ณต์ ๋ฉ๋๋ค. ๋จ ์ฐ๊ธฐ ์์ ์ ์ค์ํ ์ฆ์ ๋ณต์ ๋๋ ๊ฒ์ ์๋๋ฉฐ ์ฝ๊ฐ์ ์๊ฐ์ฐจ๊ฐ ์์ต๋๋ค.
Redis ํด๋ฌ์คํฐ์ ์บ์ ๋ ธ๋
2014๋ 8์ ๊ธฐ์ค์ผ๋ก Redis ํด๋ฌ์คํฐ๋ ์บ์ ๋ ธ๋๋ฅผ 1๊ฐ๋ง ๊ฐ์ง๊ณ ์๊ณ , ๋ ์ถ๊ฐํ ์ ์์ต๋๋ค. ๋ฐ๋ผ์ ๋ง์คํฐ ํด๋ฌ์คํฐ์ ๋ง์คํฐ ์บ์ ๋ ธ๋๋ ์ฌ์ค์ ๊ฐ์ ์๋ฏธ์ ๋๋ค.
ElastiCache ํด๋ฌ์คํฐ(exampleredis
)์ Read Replica๋ฅผ ์์ฑํด๋ณด๊ฒ ์ต๋๋ค.

[Amazon ElastiCache]
โ [Replication Groups]
)์ผ๋ก ์ด๋ํ์ฌ ์์ชฝ [Create Replication Group]
๋ฒํผ์ ํด๋ฆญํฉ๋๋ค.Replication Group์ ์์ฑํฉ๋๋ค.
- Primary Cluster ID: ๋ง์คํฐ Redis ํด๋ฌ์คํฐ์
๋๋ค. ์์์ ์์ฑํ
exampleredis
๋ฅผ ์ ํํฉ๋๋ค. - Replication Group ID: Replication Group์ ์ด๋ฆ์
๋๋ค.
examplereplication
์ ์ ๋ ฅํฉ๋๋ค. - Replication Group Description: Replication Group์ ์ค๋ช
์
๋๋ค.
examplereplication
์ ์ ๋ ฅํฉ๋๋ค.

[Create]
๋ฒํผ์ ํด๋ฆญํฉ๋๋ค.ElastiCache Replication Group ๋ชฉ๋ก์ Replication Group์ด ์์ฑ๋์์ต๋๋ค. ์์ ํ ์์ฑ๋๊ธฐ๊น์ง 10์ด ์ ๋ ์์๋ฉ๋๋ค.

examplereplication
)์ ์ ํํ๊ณ ์์ชฝ [Add Read Replica]
๋ฒํผ์ ํด๋ฆญํฉ๋๋ค.Replication Group์ Read Replica๋ฅผ ์ถ๊ฐํฉ๋๋ค.
- Replication Group: Read Replica๋ฅผ ์ถ๊ฐํ Replication Group์ ์ค์ ํฉ๋๋ค.
examplereplication
์ด ์ ํ๋์๋์ง ํ์ธํฉ๋๋ค. - Read Replica ID: Read Replica์ ์ด๋ฆ์
๋๋ค.
exampleredis-read-1
์ ์ ๋ ฅํฉ๋๋ค. - Availability Zone: Availability Zone: Read Replica๊ฐ ์์ฑ๋ ๊ฐ์ฉ ์์ญ(Availability Zone)์
๋๋ค. ์ถํ ๊ฐ์ ์ํฉ์ ๋ง๊ฒ ๋ฆฌ์ ์ ์ํ AZ๋ฅผ ์ ํํ๋ฉด ๋ฉ๋๋ค.
ap-northeast-1a
๋ฅผ ์ ํํฉ๋๋ค.

[Add]
๋ฒํผ์ ํด๋ฆญํฉ๋๋ค.
examplereplication
์ ์ ํํ๋ฉด ์๋ ์ธ๋ถ ๋ด์ฉ์ Primary ์๋ํฌ์ธํธ ์ฃผ์๊ฐ ํ์๋ฉ๋๋ค.exampleredis
๊ฐ ๋ง์คํฐPrimary์ด๊ณ , exampleredis-read-1
์ด ์ฌ๋ ์ด๋ธRead Replica ์
๋๋ค. ์ดํ ๋ง์คํฐ์ ์ฅ์ ๊ฐ ๋ฐ์ํ๋ฉด Failover ๊ธฐ๋ฅ์ด ์๋ํ์ฌ ์ฌ๋ ์ด๋ธ์ธ exampleredis-read-1
๊ฐ ๋ง์คํฐ๋ก ์น๊ฒฉ๋ฉ๋๋ค.
ํ์์๋ Primary ์๋ํฌ์ธํธ ์ฃผ์๊ฐ ๋ง์คํฐ์ธ exampleredis๋ฅผ ๊ฐ๋ฆฌํค๊ณ ์์ต๋๋ค. ๊ทธ๋์ ์ฐ๊ธฐ ์์
์ Primary ์๋ํฌ์ธํธ ์ฃผ์์ ์ ์ํ์ฌ ์ค์ํ๋ฉด ๋ฉ๋๋ค. Failover ๊ธฐ๋ฅ์ด ๋์ํ๋ฉด ์๋์ผ๋ก Primary ์๋ํฌ์ธํธ ์ฃผ์๋ ์ฌ๋์ด๋ธ์ธ exampleredis-read-1
์ ๊ฐ๋ฆฌํค๊ฒ ๋๊ณ ์ฐ๊ธฐ ์์
์ ์ํํฉ๋๋ค. ๋ฐ๋ผ์ Failover๋ฅผ ์ํ ์์
์ ๋ฐ๋ก ํ์ง ์์๋ ๋ฉ๋๋ค.
Demote, Promote
Demote ๊ธฐ๋ฅ์ ๋ง์คํฐ Redis ํด๋ฌ์คํฐ๋ฅผ ๋ค๋ฅธ ๋ง์คํฐ Redis ํด๋ฌ์คํฐ์ Read Replica๋ก ๋ง๋๋ ๊ธฐ๋ฅ์ ๋๋ค. Apply Immediately๋ฅผ Yes๋ก ์ค์ ํ๋ฉด ๊ณง ๋ฐ๋ก Read Replica๋ก ๋ง๋ค๋ฉฐ No๋ก ์ค์ ํ๋ฉด Maintenance Window์ ์ค์ ๋ ์๊ฐ์ ์คํ๋ฉ๋๋ค.

Promote ๊ธฐ๋ฅ์ Read Replica Redis ํด๋ฌ์คํฐ๋ฅผ ์๋ก์ด ๋ง์คํฐ Redis ํด๋ฌ์คํฐ๋ก ์น๊ฒฉpromote์ํค๋ ๊ธฐ๋ฅ์ ๋๋ค. ์ด ๊ธฐ๋ฅ์ ์ฌ์ฉํ๋ฉด ์ด์ ๋ง์คํฐ Redis ํด๋ฌ์คํฐ์์ ๋ณต์ ๊ด๊ณ๋ ๋์ด์ง๊ณ , ๋ณ๊ฐ์ Redis ํด๋ฌ์คํฐ๊ฐ ๋ฉ๋๋ค. Apply Immediately๋ฅผ Yes๋ก ์ค์ ํ๋ฉด ๊ณง ๋ฐ๋ก ๋ง์คํฐ Redis ํด๋ฌ์คํฐ๋ก ๋ง๋ค๋ฉฐ No๋ก ์ค์ ํ๋ฉด Maintenance Window์ ์ค์ ๋ ์๊ฐ์ ์คํ๋ฉ๋๋ค.

Promote ๊ธฐ๋ฅ์ ์๋น์ค๋๊ณ ์๋ ์บ์ ํด๋ฌ์คํฐ์ ๋์ผํ ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ง ๊ฐ๋ฐ ๋ฐ ํ ์คํธ์ฉ ์บ์ ํด๋ฌ์คํฐ๋ฅผ ์์ฑํ๊ณ ์ถ์ ๋, ์ง์ญ์ด๋ ์ธ์ด๋ณ๋ก ์๋น์ค๋ฅผ ๋ถ๋ฆฌํ ๋ ํ์ฉํ ์ ์์ต๋๋ค.
ElastiCache ์บ์ ํด๋ฌ์คํฐ ๋ชฉ๋ก([Amazon ElastiCache]
โ [Cache Clusters]
)์ผ๋ก ์ด๋ํฉ๋๋ค.

.Redis ํด๋ฌ์คํฐ Read Replica(exampleredis-read-1
)๊ฐ ์์ ํ ์์ฑ๋ ๋ค ๋ฅผ ํด๋ฆญํ์ฌ ์ธ๋ถ ์ ๋ณด๋ฅผ ํ์ธํฉ๋๋ค. Replication Group์ด examplereplication
๋ก ์ค์ ๋์ด ์์ต๋๋ค. ๊ทธ๋ฆฌ๊ณ ์บ์ ํด๋ฌ์คํฐ ๋ชฉ๋ก์์ exampleredis
์ exampleredis-read-1
์ด ๊ฐ์ Replication Group(examplereplication
)์ผ๋ก ์ค์ ๋์ด ์์ต๋๋ค.

exampleredis-read-1
์ 1 node ๋งํฌ๋ฅผ ํด๋ฆญํ๋ฉด exampleredis-read-1
์ ์บ์ ๋
ธ๋๋ฅผ ๋ณผ ์ ์๊ณ , ์บ์ ๋
ธ๋์ ์๋ํฌ์ธํธ ์ฃผ์๊ฐ ํ์๋ฉ๋๋ค.Read Replica์ Endpoint์ ์ ์ํ๋ฉด ๋ง์คํฐ Redis ํด๋ฌ์คํฐ์ ๋์ผํ ๋ฐ์ดํฐ๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค. ๋จ ์ฝ๊ธฐ ์ ์ฉ์ด๋ฏ๋ก Redis์ ์ฐ๊ธฐ ๊ด๋ จ ๋ช ๋ น์ด๋ ์ฌ์ฉํ ์ ์์ต๋๋ค.