본문 바로가기

프로젝트

mysql docker vs rds 어떻게 사용할 것인가?

 

상황


 

프로젝트를 시작하는 중이다. 

이전에 해보지 못했던, 

docker를 활용해 시작 해보려고 한다. 

 

docker를 사용하는 목적은 


같은 환경에서 협업시 개발 진행을 위해 많이 사용되고 있으며, 

실행환경 구축이나 버전관리가 용이하며

scale in , out이 쉬워서이다. 

 

만일 큰 프로젝트를 경험하기 위해 혹은 나의 프로젝트가 

큰 규모가 될 것을 대비하기 위해 사용해 보려고 한다. 

 

 

현재의 고민은? 


현재까지 경험해 봤던 3번의 협업 프로젝트에서는 

sql을 RDS를 활용했던 적이 많았다. 

그러나 그것은 Docker를 아직 활용하지 않았기에 그렇고, 

지금 나는 docker container를 활용하여 세팅중인데, 

 

만일 docker container에 mysql 컨테이너를 띄워 

백엔드 서버와 통신을 하게 한다면 

비용적인 측면에서 더 우수하지 않을까.

또한 아무래도 같은 도커 내부이므로 좀더 빠르지 않을까? 

 

그런데 다음의 stackoverflow 에서는

RDS와 docker container중 무엇을 선택하는 것이 좋을까 라는 질문이었는데도

RDS의 장점만을 나열해 놓고 있었다. 

 

 

 

RDS를 썼을때의 장점


 

 

 

mysql - Why do we need RDS when we can use docker image for mysql

From my understanding, Aws RDS facilitate backup for the mysql database, but it is not cheap. While using docker image for mysql may save us more in terms of cost? Because we only need to download ...

stackoverflow.com

 

 

 

 

 

 

 

  • RDS is managed service, so all OS updates, MySQL patches are managed by AWS and you don't have to worry about them.
  • RDS supports storage auto-scaling - you can start with small db, and RDS will extend storage automatically as needed.
  • Point-in-time recovery allowing you to "rewind" your recent db changes.
  • Read replicas - you can create up to 5 read replicas of your database to off-load read intensive applications from your primary db instance.
  • Cross-region read replica - you can have your replica in different region which is good for disaster recovery (entire AWS region goes down)
  • Automated and manual backups, including backups to a different region.
  • IAM authentication to your db instead of regular username/password.
  • Multi-AZ - RDS can keep a stand-by replica of your primary database instance in different availability zone, for quick recovery if it fails.
  • CloudWatch integrated db metrics and logs.
  • RDS event notifications allow you for straight-forward development of automations e.g. invoke lambda automatically for every backup, or if something fails.
  • Easier integration with other services, e.g. use of RDS Proxy in Lambda functions.

 

 

 

 

Docker에 mysql 띄우기


 

 

Docker에 MySQL 띄우기

Docker에 MySQL 띄우기 Docker에 MySQL이 담긴 Container를 띄운다. 1. Docker란? 도커는 컨테이너 기반의 가상화 플랫폼이다. 여기서 컨테이너란 컨테이너가 실행되고 있는 호스트 os의 기능을 그대로 사용

hipopatamus.tistory.com

 

 

내 로컬 환경에 설치된 MySQL과 독립적으로 DB를 운영하고 싶은 경우 도커를 이용할 수 있다.도커로 MySQL을 띄우면 외부와 연결되는 포트번호를 지정해 줄 수 있고 독립적인 환경에서 실행되기 때문에 위와 같은 문제를 해결할 수 있다.

 

 

 

 

 

그래서 무얼 선택할까? 


 

정리해 보자면

저렴하고 독립적으로 활용할 수 있는 Docker container와 

비용이 들지만 직접 스케일등을 관리해주고 뛰어난 보안성이 있는 RDS .

 

무엇을 선택할것인가? 

지금 docker를 사용하는 이유는 

언젠가 있을 확장성에 대비해 사용하는 것도 있다. 

그렇다면 

직접 관리해주는 확장 기능 등으로 관리 비용을 줄일 수 있는 RDS가 오히려 나중에는 

저렴한 선택이라고 할 수 있겠다.

 

그러나 docker compose기능을 사용하여

Docker container간의 연결을 수립하는 부분을 공부해보는것도 

나쁘진 않겠다. 

그러므로 Docker에 sql을 활용해보도록 하자