-
제발 내 Request를 Response해줘....프로젝트/쌍토끼 2021. 3. 17. 19:01
결론부터 이야기하자면 마지막 어플로 빌드할 때까지 모델에 대한 수정은 계속 진행됐다.
잘 되다가도 광량이나 배경에 따라 많이 결과가 달라졌기 때문에 다른 방법이 필요했는데 팀원 형 중에 한 명이
조용히 계속 붙잡고 있더니 딥러닝 모델이 적용되는 부위를 전체에서 눈두덩이 쪽만 잡히게 코드를 짜냈다.
오우..... 대단했다.
그 형은 결론처럼 마지막까지 책임지고 계속해서 수정을 해주었다. 덕분에 더 탄탄하고 마음에 드는 결과물들을
받아볼 수 있었고 나도 어서 API를 완료해야겠다고 생각이 들었다.
딥러닝 연산은 GPU 자원을 정말 미치게 많이 사용한다. 테스트했던 GPU가 RTX 2080 super 12GB였는데
요청 하나를 받아서 연산을 돌리면 3기가를 사용하는 것이었다. 그럼 터지기 직전까지 운 좋으면 4명,
평소엔 3명밖에 사용을 못한다는 것이었다. 이건 정말 어쩔 수 없었다. 만족스러운 결과를 얻기 위해서는 그래야만 했고
차후에 딥러닝 연산을 미치게 잘하는 GPU로 세대가 교체가 되면 훨씬 많은 요청을 빠르게 해결할 수 있었을 것이다.
아무튼 동시 요청수가 정해져 있었기에 요청을 컨트롤하는 것이 필요했고 나는 찾아보다가 gunicorn이라는 녀석을 발견
하게 되었고 들어오는 요청을 관리하고 스레드 환경까지 구현할 수 있다는 것을 알았다. Locust를 사용해서 확인해보니
아주 잘 일해주었다. 그러나 이 과정에서 flask + gunicorn + nginx로 구축하는 블로그의 글들을 많이 보게 되었고
우리도 써야 하는지에 대한 의문을 가지게 되었다.
기존에는 아파치라는 웹서버를 많이 사용하였으나 Nginx의 등장으로 아파치의 점유율을 먹어가고 있다고 한다.
그만큼 괜찮은 녀석인가 싶었다.(그 당시엔 몰랐지만) 아무튼 서버를 가동하면 누가 언제 요청을 보내고 잘 응답했는지
또는 에러가 난다면 에러를 저장해야 한다. 그 과정을 Nginx를 사용하면 편리하게 서버를 관리할 수 있었고 다른 용도로
Nginx를 프록시 서버로 사용했는데 마치 컨트롤 타워처럼 먼저 요청이 무수히 들어오면 Nginx가 요청을 받아내고
Nginx가 직접 미들웨어인 Gunicorn으로 요청을 분배해준다는 것이다.
아무튼 이 세 개를 엮는 과정이 나에겐 첫번째 장벽이었다. 계속 서로가 연결도 안되고 환경세팅도 어려웠고 가이드없이
하기에 시간이 많이 필요했고 프로젝트 과정 중 가장 많이 오류를 본 시기이다. 어찌저찌 연결을 하긴했지만 Docker에
올리니 또.... 안되는 것이다...
제발 내 요청에 응답해줘.....
728x90반응형LIST'프로젝트 > 쌍토끼' 카테고리의 다른 글
쌍토끼 출시!! (0) 2021.05.23 원인을 해결하다. (0) 2021.04.30 프로젝트 시작 (0) 2021.03.09 어떻게 시작해야했을까? (0) 2021.03.03 생애 첫 개발프로젝트를 시작하다 (0) 2021.03.02